I'm working on video machine learning and have a directory with plenty of small (1min up to 14min) *.avi files with different sizes and aspect ratios, slightly different frame rates (e.g. 25 Hz, 22 Hz, 30 Hz) and sometimes (unnecessary) audio. I want to equalize them so that I can quickly read the frames as training data without further preprocessing.

For the problem we are working on it is most important that temporal accuracy is preserved, i.e. the converted video must have the same duration and content must appear at the same time as in the original video. As we are doing action recognition we can not tolerate speed changes.

As we have to shrink the videos to 224x224 it should not be a problem if small visual artefacts are introduced.

In short, I want to:

  • vertically scale to 224px

  • center-crop to 224px (it is common to use square input)

  • change frame rate to 23 Hz

  • strip audio to save some space

I came up with this:

ffmpeg -i input_video.avi -filter:v scale=-1:224 crop=224:in_h:exact=1:keep_aspect=1 -r 23 -an output_video.avi


  • Is this the current best / recommended option for the quality target (temporal accuracy with minor visual artefacts)?

  • Can I avoid transcoding here at all?

I've read quite some older SE posts on ffmpeg but the number of options (and apparent differences across versions) confuses me.

  • Changing frame rates will affect temporal accuracy. In a constant 10 fps video, frames are shown at 0, 0.1, 0.2, 0.3 ... seconds. If you change it to 25 fps, frames can be shown at 0, 0.04, 0.08, 0.12 ... seconds. The frame at 0.1 has to be shifted to either 0.08 or 0.12 seconds. – Gyan Sep 24 '19 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.