raw.mp4
- Your input videoout.mp4
- Your output video-r 30
- The framerate of your videos.%04d
- The format of your image sequence.images
- The folder with your image sequence
Dump all video frames into a folder.
Set the number of zeroes as needed (%04d
->0001.png
,%06d
->000001.png
, etc).
ffmpeg -i raw.mp4 images\%04d.png
For further processing / as input for other software.
ffmpeg -r 30 -i images\%04d.png -c:v libx264 -crf 15 out.mp4
Same as above, but take the audio track from the original video.
Replace raw.mp4
to use different audio track source.
ffmpeg -i raw.mp4 -r 30 -i images\%04d.png -map 0:a:0 -map 1:v:0 -c:v libx264 -crf 15 out.mp4
Useful for exporting your video. Adjust quality by changing -crf 21
.
Higher values = worse video, sensible values are 18-32.
ffmpeg -i raw.mp4 -r 30 -i images\%04d.png -map 0:a:0 -map 1:v:0 -c:v libx264 -pix_fmt yuv420p -crf 21 out.mp4
Change -b:v 2M
to match the filesize you need. Formula is [target size in MB]/[video length in seconds]*8
.
You can also just use -crf
like the command above.
See the wiki for more options.
ffmpeg -i raw.mp4 -r 30 -i images\%04d.png -map 0:a:0 -map 1:v:0 -c:a libvorbis -c:v libvpx-vp9 -pix_fmt yuv420p -b:a 96K -b:v 2M out.webm
Replace transparency with a specific color:
Can't find the stackoverflow answer I got parts of this from.
Adjust resolution/framerate for the color plane.
ffmpeg -f lavfi -i color=c=white:s=768x768:r=30 -r 30 -i images\%04d.png -filter_complex "[0:v][1:v]overlay=shortest=1,format=yuv420p[out]" -map "[out]" -c:v libx264 -crf 15 out.mp4