Skip to content

Instantly share code, notes, and snippets.

@meisa233
Last active July 9, 2024 06:54
Show Gist options
  • Save meisa233/e1b043f1ba83badeda69f31c2faa768f to your computer and use it in GitHub Desktop.
Save meisa233/e1b043f1ba83badeda69f31c2faa768f to your computer and use it in GitHub Desktop.
use ffmpeg to extract frames and convert image sequence to video

extract fixed number frames

ffmpeg -ss 00:00:00 -i input.mp4 -vsync 0 -an -vframes 600 -f image2 -start_number 0 %05d.png

start time: 00:00:00
frame number: 600
output format: %05d.png
start_number: start number of output images
extract frames by specified duration

ffmpeg -ss 00:00:00 -i input.mp4 -t 2 -f image2 -vsync 0 %05d.png

convert image sequence to video(.avi)

ffmpeg -f image2 -start_number 1000 -i %d.png -c:v copy -r 25 output.avi

Note that cfr will provent constant bitrate(-x264-params "nal-hrd=cbr:force-cfr=1" -b:v 88M -minrate 88M -maxrate 88M -bufsize 88M)

ffmpeg -i mimituzhi_restorage.avi -c:v libx264 -x264-params "nal-hrd=cbr:force-cfr=1" -b:v 88M -minrate 88M -maxrate 88M -bufsize 88M mimituzhi_264_.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment