I was trying to rewrite a bash script I had and found that the command line version I was using is way faster compared to the script using python. This mkv file is 1.5GB big.
time ffmpeg -hide_banner -loglevel error -ss 12:12 \
-i video.mkv \
-t 1 \
-an \
-filter:v fps=23.976,scale=720:540:flags=lanczos \
-y "output_manual.mp4"
________________________________________________________
Executed in 265.38 millis fish external
usr time 1.13 secs 0.00 micros 1.13 secs
sys time 0.14 secs 670.00 micros 0.14 secs
The code in python I used was:
stream = ffmpeg.trim(stream, start=start_time, duration=duration)
stream = ffmpeg.filter(stream, "framerate", 23.976)
stream = ffmpeg.filter(stream, "scale", width=720, height=540, flags="lanczos")
video_output = "output_python.mp4"
stream = ffmpeg.output(stream, video_output)
stream = ffmpeg.overwrite_output(stream)
print(stream.get_args())
which gives:
['-an', '-i', 'video.mkv', '-filter_complex', '[0]trim=duration=1.0:start=12\\\\:12[s0];[s0]framerate=23.976[s1];[s1]scale=flags=lanczos:height=540:width=720[s2]', '-map', '[s2]', 'output_python.mp4', '-y']
But that takes much longer. If I use those parameters and run it myself:
time ffmpeg -an -i video.mkv -filter_complex "[0]trim=duration=1.0:start=12\\\\:12[s0];[s0]framerate=23.976[s1];[s1]scale=flags=lanczos:height=540:width=720[s2]" -map [s2] output_code.mp4 -y
________________________________________________________
Executed in 12.88 secs fish external
usr time 169.18 secs 788.00 micros 169.18 secs
sys time 2.05 secs 0.00 micros 2.05 secs
There is about a 50x difference in speed. On top of that the sha1 of both files is different. Am I doing something blatantly wrong and noticing it?
I was trying to rewrite a bash script I had and found that the command line version I was using is way faster compared to the script using python. This mkv file is 1.5GB big.
The code in python I used was:
which gives:
['-an', '-i', 'video.mkv', '-filter_complex', '[0]trim=duration=1.0:start=12\\\\:12[s0];[s0]framerate=23.976[s1];[s1]scale=flags=lanczos:height=540:width=720[s2]', '-map', '[s2]', 'output_python.mp4', '-y']But that takes much longer. If I use those parameters and run it myself:
There is about a 50x difference in speed. On top of that the sha1 of both files is different. Am I doing something blatantly wrong and noticing it?