Knowledge Base

Useful commands for FFmpeg

Here is a collection of various useful commands for FFmpeg that perhaps some day may come in handy for you. It also shows a tiny bit of the endless possibilities that FFmpeg has.

1. Extract frames as images from a video

ffmpeg -i video.mp4 filename%04d.jpg

2. Make video from a set of images

ffmpeg -framerate 25 -i ./filename%4d.png video.mp4

3. Extract xx seconds clip from a long video

ffmpeg -ss 00:00:55 -i video.mp4 -t 00:00:10 -vcodec copy -acodec copy videoclip.mp4

4. Extract an save audio from a video file

ffmpeg -i video.mp4 -vn -acodec copy audio.aac

5. Add audio to a video

ffmpeg -y -i video.mp4 -i audio.aac -c copy -map 0:v:0 -map 1:a:0 video-with-audio.mp4

6. Join two video side by side

  • for horizontal stacking of the videos
ffmpeg -i video1.mp4 -i video2.mp4 -filter_complex hstack -c:v ffv1 output.mp4
  • for vertical stacking of the videos
ffmpeg -i ./sample-1.mp4 -i ./sample-out-image1.mp4 -filter_complex vstack -c:v ffv1 output.mp4

More coming soon!

Table of Contents