From 0d1fbe09d6aadf8fbf82a8bb3b267182cf991ad9 Mon Sep 17 00:00:00 2001 From: Arona Jones Date: Sun, 7 Feb 2021 23:18:23 +0000 Subject: [PATCH] Munger actually fully working :p --- lecturemunger.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lecturemunger.py b/lecturemunger.py index 4222890..59def81 100644 --- a/lecturemunger.py +++ b/lecturemunger.py @@ -20,6 +20,7 @@ import sys from pathlib import Path import dateutil.parser as dparser import re +import time # TODO path_to_destreamer = os.path.abspath(sys.argv[1]) @@ -103,6 +104,7 @@ def mkdir_if_not_exists(directory): def do(): mkdir_if_not_exists(working_dir) if working_dir: + print("WARNING: MUNGING IN PROGRESS") # Setup #os.chdir(working_dir) downloaded = mkdir_if_not_exists(working_dir + "/downloaded") @@ -135,26 +137,31 @@ def do(): print ("Source: " + source) print ("Dest: " + dest) shutil.copy(source, dest) - + time.sleep(5) # Extract audio, process it, add it back to the video video_in = dest processed_audio = os.path.join(processed_audio_dir, filename.split(".")[0] + ".wav") final_output_name = os.path.join(final, filename) # do_command("Help: Command=Popmute") do_command("Import2: Filename={}".format(video_in)) + time.sleep(5) do_command("SelectAll:") - do_command('Popmute: thresh=-0.5 floor=-100') + do_command('Amplify: Ratio=2') + time.sleep(1) do_command("SelectAll:") - do_command('Amplify:') + do_command('Popmute: thresh=10 floor=100') + time.sleep(1) + do_command("Export2: Filename={} NumChannels=2".format(processed_audio)) + time.sleep(5) do_command("SelectAll:") - do_command("Export2: Filename={}".format(processed_audio)) - do_command("SelectAll") - do_command("RemoveTracks") + do_command("RemoveTracks:") + time.sleep(5) # do_command('Close:') # final_output_name = "output-" + # TODO Folderisation of output by lecture - print("Combining video with audio at {}".format(processed_audio)) - call('ffmpeg -i {} -i {} -acodec copy -vcodec copy {}'.format(video_in, processed_audio, final_output_name), shell=True) + print("Combining video at {} with audio at {}".format(video_in, processed_audio)) + # https://superuser.com/questions/277642/how-to-merge-audio-and-video-file-in-ffmpeg + call('ffmpeg -i {} -i {} -acodec copy -vcodec copy -map 0:v:0 -map 1:a:0 {}'.format(video_in, processed_audio, final_output_name), shell=True) print("\033[92mDone! Result is at {}".format(final_output_name)) do()