Volume down done

pull/1590/head
Lucas 2 years ago
parent a21c17ef55
commit 405b1f89eb

@ -5,7 +5,7 @@ from pathlib import Path
from random import randrange from random import randrange
from typing import Any, Tuple,Dict from typing import Any, Tuple,Dict
from moviepy.editor import VideoFileClip,AudioFileClip from moviepy.editor import VideoFileClip,AudioFileClip,afx
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
from pytube import YouTube from pytube import YouTube
from pytube.cli import on_progress from pytube.cli import on_progress
@ -115,13 +115,24 @@ def chop_background(
video_choice = f"{background_config['video'][2]}-{background_config['video'][1]}" video_choice = f"{background_config['video'][2]}-{background_config['video'][1]}"
audio_choice = f"{background_config['audio'][2]}-{background_config['audio'][1]}" audio_choice = f"{background_config['audio'][2]}-{background_config['audio'][1]}"
id = re.sub(r"[^\w\s-]", "", reddit_object["thread_id"]) id = re.sub(r"[^\w\s-]", "", reddit_object["thread_id"])
# audioclip = audioclip.fx( volumex, 0.2)
# final_audio = mpe.CompositeAudioClip([final.audio, audioclip])
# # lowered_audio = audio_background.multiply_volume( # todo get this to work
# # VOLUME_MULTIPLIER) # lower volume by background_audio_volume, use with fx
# final.set_audio(final_audio)
background_video = VideoFileClip(f"assets/backgrounds/video/{video_choice}") background_video = VideoFileClip(f"assets/backgrounds/video/{video_choice}")
background_audio = AudioFileClip(f"assets/backgrounds/audio/{audio_choice}") background_audio = AudioFileClip(f"assets/backgrounds/audio/{audio_choice}")
start_time_video, end_time_video = get_start_and_end_times(video_length, background_video.duration) start_time_video, end_time_video = get_start_and_end_times(video_length, background_video.duration)
start_time_audio, end_time_audio = get_start_and_end_times(video_length, background_audio.duration) start_time_audio, end_time_audio = get_start_and_end_times(video_length, background_audio.duration)
background_audio.subclip(start_time_audio,end_time_audio) #background_audio.set_start(start_time_audio)
#background_audio.set_end(end_time_audio)
background_audio = background_audio.fx(afx.volumex,0.1)
#background_audio = background_audio.subclip(start_time_audio,end_time_audio)
background_audio.write_audiofile(f"assets/temp/{id}/background.mp3")
background_video.set_audio(background_audio) background_video.set_audio(background_audio)
try: try:
ffmpeg_extract_subclip( ffmpeg_extract_subclip(
f"assets/backgrounds/video/{video_choice}", f"assets/backgrounds/video/{video_choice}",
@ -135,7 +146,7 @@ def chop_background(
new = video.subclip(start_time_video, end_time_video) new = video.subclip(start_time_video, end_time_video)
new.write_videofile(f"assets/temp/{id}/background.mp4") new.write_videofile(f"assets/temp/{id}/background.mp4")
print_substep("Background video chopped successfully!", style="bold green") print_substep("Background video chopped successfully!", style="bold green")
return background_config[2] return background_config["video"][2]
# Create a tuple for downloads background (background_audio_options, background_video_options) # Create a tuple for downloads background (background_audio_options, background_video_options)
background_options = load_background_options() background_options = load_background_options()

@ -14,5 +14,53 @@
"background_credit": "", "background_credit": "",
"reddit_title": "skipped", "reddit_title": "skipped",
"filename": "" "filename": ""
},
{
"subreddit": "",
"id": "12u5j7a",
"time": "1682116292",
"background_credit": "",
"reddit_title": "skipped",
"filename": ""
},
{
"subreddit": "",
"id": "12twuvx",
"time": "1682118162",
"background_credit": "",
"reddit_title": "skipped",
"filename": ""
},
{
"subreddit": "",
"id": "12tir3d",
"time": "1682121760",
"background_credit": "",
"reddit_title": "skipped",
"filename": ""
},
{
"subreddit": "",
"id": "12u60fn",
"time": "1682122061",
"background_credit": "",
"reddit_title": "skipped",
"filename": ""
},
{
"subreddit": "",
"id": "12txuo4",
"time": "1682123020",
"background_credit": "",
"reddit_title": "skipped",
"filename": ""
},
{
"subreddit": "AskReddit",
"id": "12uei9x",
"time": "1682123178",
"background_credit": "bbswitzer",
"reddit_title": "People who pick up trash on the sides of roads what is the coolest grossestmost interesting thing youve found",
"filename": "People who pick up trash on the sides of roads what is the coolest grossestmost interesting thing youve found.mp4"
} }
] ]

@ -4,7 +4,7 @@ import re
import shutil import shutil
from os.path import exists # Needs to be imported specifically from os.path import exists # Needs to be imported specifically
from typing import Final from typing import Final
from typing import Tuple, Any from typing import Tuple, Any, Dict
import ffmpeg import ffmpeg
import translators as ts import translators as ts
@ -108,7 +108,7 @@ def make_final_video(
number_of_clips: int, number_of_clips: int,
length: int, length: int,
reddit_obj: dict, reddit_obj: dict,
background_config: Tuple[str, str, str, Any], background_config: Dict[str,Tuple[str, str, str, Any]],
): ):
"""Gathers audio clips, gathers all screenshots, stitches them together and saves the final video to assets/temp """Gathers audio clips, gathers all screenshots, stitches them together and saves the final video to assets/temp
Args: Args:
@ -300,7 +300,7 @@ def make_final_video(
f"Thumbnail - Building Thumbnail in assets/temp/{reddit_id}/thumbnail.png" f"Thumbnail - Building Thumbnail in assets/temp/{reddit_id}/thumbnail.png"
) )
text = f"Background by {background_config[2]}" text = f"Background by {background_config['video'][2]}"
background_clip = ffmpeg.drawtext( background_clip = ffmpeg.drawtext(
background_clip, background_clip,
text=text, text=text,
@ -347,7 +347,7 @@ def make_final_video(
pbar.update(100 - old_percentage) pbar.update(100 - old_percentage)
pbar.close() pbar.close()
save_data(subreddit, filename + ".mp4", title, idx, background_config[2]) save_data(subreddit, filename + ".mp4", title, idx, background_config['video'][2])
print_step("Removing temporary files 🗑") print_step("Removing temporary files 🗑")
cleanups = cleanup(reddit_id) cleanups = cleanup(reddit_id)
print_substep(f"Removed {cleanups} temporary files 🗑") print_substep(f"Removed {cleanups} temporary files 🗑")

Loading…
Cancel
Save