bruh moment
This commit is contained in:
parent
c8ccfd939b
commit
bc8fe94eda
@ -7,7 +7,7 @@ def run_command(command, mode="silent"):
|
|||||||
return os.popen(command).read()
|
return os.popen(command).read()
|
||||||
|
|
||||||
def detect_fps(input_path):
|
def detect_fps(input_path):
|
||||||
output = os.popen(f"ffprobe -v error -select_streams v -of default=noprint_wrappers=1:nokey=1 -show_entries stream=r_frame_rate {input_path}").read()
|
output = os.popen(f'ffprobe -v error -select_streams v -of default=noprint_wrappers=1:nokey=1 -show_entries stream=r_frame_rate "{input_path}"').read()
|
||||||
if "/" in output:
|
if "/" in output:
|
||||||
try:
|
try:
|
||||||
return int(output.split("/")[0]) // int(output.split("/")[1])
|
return int(output.split("/")[0]) // int(output.split("/")[1])
|
||||||
@ -17,23 +17,23 @@ def detect_fps(input_path):
|
|||||||
|
|
||||||
|
|
||||||
def set_fps(input_path, output_path, fps):
|
def set_fps(input_path, output_path, fps):
|
||||||
os.system(f"ffmpeg -i {input_path} -filter:v fps=fps={fps} {output_path}")
|
os.system(f'ffmpeg -i "{input_path}" -filter:v fps=fps={fps} "{output_path}"')
|
||||||
|
|
||||||
|
|
||||||
def create_video(video_name, fps, output_dir):
|
def create_video(video_name, fps, output_dir):
|
||||||
os.system(f"ffmpeg -framerate {fps} -pattern_type glob -i '{output_dir}/*.png' -c:v libx264 -pix_fmt yuv420p -y {output_dir}/output.mp4")
|
os.system(f'ffmpeg -framerate {fps} -pattern_type glob -i "{output_dir}/*.png" -c:v libx264 -pix_fmt yuv420p -y "{output_dir}/output.mp4"')
|
||||||
|
|
||||||
|
|
||||||
def extract_frames(input_path, output_dir):
|
def extract_frames(input_path, output_dir):
|
||||||
os.system(f"ffmpeg -i {input_path} '{output_dir}/%04d.png'")
|
os.system(f'ffmpeg -i "{input_path}" "{output_dir}/%04d.png"')
|
||||||
|
|
||||||
|
|
||||||
def add_audio(current_dir, output_dir, target_path, keep_frames, output_file):
|
def add_audio(current_dir, output_dir, target_path, keep_frames, output_file):
|
||||||
video = target_path.split("/")[-1]
|
video = target_path.split("/")[-1]
|
||||||
video_name = video.split(".")[0]
|
video_name = video.split(".")[0]
|
||||||
save_to = output_file if output_file else current_dir + "/swapped-" + video_name + ".mp4"
|
save_to = output_file if output_file else current_dir + "/swapped-" + video_name + ".mp4"
|
||||||
os.system(f"ffmpeg -i {output_dir}/output.mp4 -i {output_dir}/{video} -c:v copy -map 0:v:0 -map 1:a:0 -y {save_to}")
|
os.system(f'ffmpeg -i "{output_dir}/output.mp4" -i "{output_dir}/{video}" -c:v copy -map 0:v:0 -map 1:a:0 -y "{save_to}"')
|
||||||
if not os.path.isfile(current_dir + "/swapped-" + video_name + ".mp4"):
|
if not os.path.isfile(save_to):
|
||||||
shutil.move(output_dir + "/output.mp4", save_to)
|
shutil.move(output_dir + "/output.mp4", save_to)
|
||||||
if not keep_frames:
|
if not keep_frames:
|
||||||
shutil.rmtree(output_dir)
|
shutil.rmtree(output_dir)
|
||||||
|
Loading…
Reference in New Issue
Block a user