Log in

View Full Version : Ffmpeg too slow when simultaneously splits and reencode videos


kromak
6th February 2020, 00:38
Hello, I frequently only need to reencode part of video files, so I try to use the ffmpeg command to split while also instruct ffmpeg to reencode it. Something like this:

ffmpeg -i input.mkv -c:a libmp3lame -b:a 48k -ac 1 -vf scale=720:-2 -c:v mpeg4 -vtag xvid -b:v 969k -ss 2:19:00 -t 3000 input.avi

The problem is that when I try to do so, it seems ffmpeg becomes stuck in a line like this frame= 0 fps=0.0 q=0.0 size= 10kB time=00:00:00.00 bitrate=N/A speed= 0x

Due to the enormous time it take when the starting point is far away from the beginning, the impression I have is that ffmpeg is re-encoding since the start of the video file, which is perhaps quite unnecessary?

I don't know a way to avoid it, except by first to split the video, and then re-encode the second half. Which, unfortunately, is usually not acceptable, since I frequently do not have the spare space to store the intermediate split file so.

communist
6th March 2020, 21:10
The order of parameters is important. Put the -ss further up. This way ffmpeg will skip up to that point and then start encoding:
ffmpeg -ss 2:19:00 -i input.mkv -c:a libmp3lame -b:a 48k -ac 1 -vf scale=720:-2 -c:v mpeg4 -vtag xvid -b:v 969k -t 3000 input.avi

In your command it will not encode for a long time as it is decoding the input file up the 'start time'. You will notice that the bitrate stays around zero with your command until it hits the 'start time'.