Skip to content

Instantly share code, notes, and snippets.

@gnat
Created July 23, 2022 21:29
Show Gist options
  • Save gnat/6a504e6e77b1ae412c3c71d34df86791 to your computer and use it in GitHub Desktop.
Save gnat/6a504e6e77b1ae412c3c71d34df86791 to your computer and use it in GitHub Desktop.
FFMPEG Quickstart
  • FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. Typically you can use it in command lines or GUI, and many popular video editors are developed based on FFmpeg. Some usage examples are as follows:
    • Transcoding: ffmpeg -i input.mp4 output.avi
    • Video clipping: ffmpeg -i input.mkv -ss 11 -to 15 out.mkv to get a video clip from 11 second to 15 second. You can also replace -ss 11 -to 15 with -ss 00:00:11 -to 00:00:15 or -ss 00:11 -to 00:15 or -ss 00:11 -t 5 where parameter -t devotes time duration.
    • Video Frame screenshot: ffmpeg -i input.mkv -ss 5 -vframes 1 img.jpg to get the 1st frame in the selected second.
    • Watermark: ffmpeg -i input.mkv -i logo.png -filter_complex "[1]scale=192:108[b];[0][b]overlay=20:20" output.mkv with parameter scale for resizing watermark and overlay for watermark location (top-left pixel location). Use -filter_complex "overlay=20:20" instead if you don't need to scale watermark.
    • Extract audio from video: ffmpeg -i input.mkv -vn -acodec copy aout.m4a
    • Remove audio from video: ffmpeg -i input.mkv -vcodec copy -an vout.mkv
    • Generate animated GIF: ffmpeg -i input.mkv -ss 11 -to 15 -s 640x320 -r 15 out.gif with paramter -s for frame scaling and -r for frame rate resetting.
    • Use FFplay to play a video or audio: ffplay input.mkv, press Q key to quit when finished.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment