How can the speed of an AVI file be changed?

I want to change the speed of an AVI video file such that it takes twice as long to play as it did originally. I have attempted to do this with ffmpeg, but this results in a very low quality video:

ffmpeg -i in.avi -filter:v "setpts=2.0*PTS" out.avi

How should this be done on Ubuntu 15.10 without this loss of quality?


I suspect that your copy of FFmpeg is also re-encoding using the defaults for the avi container, which can be a little unforgiving. Try running the following simple additions to your commandline:

ffmpeg -i in.avi \
       -filter:v "setpts=2.0*PTS" \
       -c:v mpeg4 -q:v 2 \
       -an \
       out.avi

The driving part of this commandline is the 'quality' setting: -q:v 2 which can be set from 1-31 with the highest quality being 1 and the lowest being 31. Note as well that I have used -an to bar use of the audio stream.

If this effectively increases the quality of your output video you could consider adding the following flags to your video line:

-vtag XVID -f avi -mbd rd -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2 -g 300

I routinely use these flags when encoding for an older device and they do produce a significantly better result...

References:

  • FFmpeg Trac: MPEG-4 Encoding Guide
  • FFmpeg Trac: Speeding up/slowing down video