Using ffmpeg to change framerate

前端 未结 6 1814
猫巷女王i
猫巷女王i 2020-11-29 01:42

I am trying to convert a video clip (MP4, yuv420p) from 30 fps to 24 fps. The number of frames is correct so my output should change from 20 minutes at 30fps to 25 minutes a

6条回答
  •  感动是毒
    2020-11-29 01:47

    To the best of my knowledge you can't do this with ffmpeg without re-encoding. I had a 24fps file I wanted at 25fps to match some other material I was working with. I used the command ffmpeg -i inputfile -r 25 outputfile which worked perfectly with a webm,matroska input and resulted in an h264, matroska output utilizing encoder: Lavc56.60.100

    You can accomplish the same thing at 6fps but as you noted the duration will not change (which in most cases is a good thing as otherwise you will lose audio sync). If this doesn't fit your requirements I suggest that you try this answer although my experience has been that it still re-encodes the output file.

    For the best frame accuracy you are still better off decoding to raw streams as previously suggested. I use a script for this as reproduced below:

    #!/bin/bash
    #This script will decompress all files in the current directory, video to huffyuv and audio to PCM
    #unsigned 8-bit and place the output #in an avi container to ease frame accurate editing.
    for f in *
    do
    ffmpeg -i "$f" -c:v huffyuv -c:a pcm_u8 "$f".avi
    done
    

    Clearly this script expects all files in the current directory to be media files but can easily be changed to restrict processing to a specific extension of your choosing. Be aware that your file size will increase by a rather large factor when you decompress into raw streams.

提交回复
热议问题