From 32dd09dca47c288050123308dc70ff67551ce7fb Mon Sep 17 00:00:00 2001 From: MrBesen Date: Thu, 12 Dec 2019 11:12:07 +0100 Subject: [PATCH] Added --fmpeg_binary option to choose a difrent ffmpeg version useful if you have more than one ffmpeg version installed or ffmpeg is not available over the PATH variable. --- jumpcutter.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/jumpcutter.py b/jumpcutter.py index 8b59e3d..8994ae0 100644 --- a/jumpcutter.py +++ b/jumpcutter.py @@ -63,6 +63,7 @@ def deletePath(s): # Dangerous! Watch out! parser.add_argument('--sample_rate', type=float, default=44100, help="sample rate of the input and output videos") parser.add_argument('--frame_rate', type=float, default=30, help="frame rate of the input and output videos. optional... I try to find it out myself, but it doesn't always work.") parser.add_argument('--frame_quality', type=int, default=3, help="quality of frames to be extracted from input video. 1 is highest, 31 is lowest, 3 is the default.") +parser.add_argument('--ffmpeg_binary', type=str, default="ffmpeg", help="the ffmpeg binary, ffmpeg is the default.") args = parser.parse_args() @@ -72,6 +73,7 @@ def deletePath(s): # Dangerous! Watch out! SAMPLE_RATE = args.sample_rate SILENT_THRESHOLD = args.silent_threshold FRAME_SPREADAGE = args.frame_margin +FFMPEG_BINARY = args.ffmpeg_binary NEW_SPEED = [args.silent_speed, args.sounded_speed] if args.url != None: INPUT_FILE = downloadFile(args.url) @@ -92,14 +94,14 @@ def deletePath(s): # Dangerous! Watch out! createPath(TEMP_FOLDER) -command = "ffmpeg -i "+INPUT_FILE+" -qscale:v "+str(FRAME_QUALITY)+" "+TEMP_FOLDER+"/frame%06d.jpg -hide_banner" +command = FFMPEG_BINARY + " -i "+INPUT_FILE+" -qscale:v "+str(FRAME_QUALITY)+" "+TEMP_FOLDER+"/frame%06d.jpg -hide_banner" subprocess.call(command, shell=True) -command = "ffmpeg -i "+INPUT_FILE+" -ab 160k -ac 2 -ar "+str(SAMPLE_RATE)+" -vn "+TEMP_FOLDER+"/audio.wav" +command = FFMPEG_BINARY + " -i "+INPUT_FILE+" -ab 160k -ac 2 -ar "+str(SAMPLE_RATE)+" -vn "+TEMP_FOLDER+"/audio.wav" subprocess.call(command, shell=True) -command = "ffmpeg -i "+TEMP_FOLDER+"/input.mp4 2>&1" +command = FFMPEG_BINARY + " -i "+TEMP_FOLDER+"/input.mp4 2>&1" f = open(TEMP_FOLDER+"/params.txt", "w") subprocess.call(command, shell=True, stdout=f) @@ -197,7 +199,7 @@ def deletePath(s): # Dangerous! Watch out! copyFrame(int(audioSampleCount/samplesPerFrame)-1,endGap) ''' -command = "ffmpeg -framerate "+str(frameRate)+" -i "+TEMP_FOLDER+"/newFrame%06d.jpg -i "+TEMP_FOLDER+"/audioNew.wav -strict -2 "+OUTPUT_FILE +command = FFMPEG_BINARY + " -framerate "+str(frameRate)+" -i "+TEMP_FOLDER+"/newFrame%06d.jpg -i "+TEMP_FOLDER+"/audioNew.wav -strict -2 "+OUTPUT_FILE subprocess.call(command, shell=True) deletePath(TEMP_FOLDER)