[FFmpeg-user] Better way to cut parts out of a long video?
Cecil Westerhof
Cecil at decebal.nl
Mon Jun 13 12:40:09 EEST 2022
I know that because of iframes you need to put the inputfile before
the start and to parameters if you want to sure that the start time is
correctly used. Because of this I defined the following function.
function doConvert {
echo "Convert $1 to $2"
time nice -n 19 ionice -c3 \
ffmpeg -y -i $1 \
-ss $3 -to $4 \
-vcodec libx264 -crf 26 \
-acodec libmp3lame \
-qscale:a 9 \
-preset veryfast $2
}
Normally this is not a problem: I do not have to cut from a video very
often and mostly the video is not very long. But this weekend I needed
to cut three parts out of a long video and this took more as 1½ hour
and my processor was (on my system) completly hogged:
doConvert Original/00233-00239.MTS improvisatieVoorEnTegenDeTienGeboden.mkv 2658 2748
doConvert Original/00233-00239.MTS improvisatieWelOfNietOntbijten.mkv 2757 2846
doConvert Original/00233-00239.MTS improvisatieWatWeetJeOverIjsheiligen.mkv 4620 4682
The time output was (the first one I find a bit strange):
real 45m33.66s
user 63m9.35s
sys 1m0.51s
perc 140.83
real 23m18.92s
user 60m39.46s
sys 0m52.01s
perc 263.88
real 29m36.04s
user 88m38.41s
sys 1m4.94s
perc 303.11
This is because ffmpeg spends all its time seeking the start of the
video. In the last case that is more as 1¼ hour into the video.
I am not using ffmpeg that much so maybe I am asking something stupid.
Would it not be possible to skip to the last iframe before the start?
Or should I be doing things completly differently?
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
More information about the ffmpeg-user
mailing list