On the FFmpeg documentation (here, and here) I read that, by default, FFmpeg
chooses to extract frames at 25 frames per second (otherwise you can specify a framerate with the -r
option)
My problem is that I have a folder with dozens of videos, each of them recorded at different frame rates, so my question is:
Is there a way to ask FFmpeg
to extract frames from a video at the "native" frame rate (i.e. the original frame rate at which the video was recorded)?
In case it matters, I am working with MP4
files
To get the original frame rate:
ffmpeg -i file.mp4 2>&1 | grep -o '[0-9]\{1,3\}\sfps'
Example Output:
25 fps
You can futher pipe it to sed ... | sed 's/\sfps//'
to keep only the 25
, and store it into a variable, so you can use that variable to convert the videos e.g. ffmpeg -r $originalFps
.
grep -o
will extract the match, instead of the whole line containing the match.
[0-9]\{1,3\}
will match one to three digits
\sfps
will match a white space followed by 'fps'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With