Skip to content

Instantly share code, notes, and snippets.

@vtypal
Last active September 4, 2015 06:14
Show Gist options
  • Save vtypal/276021 to your computer and use it in GitHub Desktop.
Save vtypal/276021 to your computer and use it in GitHub Desktop.

ffmpeg short guide

Supported input formats

$ ffmpeg -formats

Sub-clip Creation

$ ffmpeg -i input_file -ss timecode -t timecode -vcodec copy -acodec copy  output_file 

ex:
ffmpeg -i recorder_A.vob -ss 00:03:00 -t 00:30:15 -vcodec mpeg4 -acodec aac recorder_A.mp4

Audio Volume Modification

ffmpeg -i input_file -vol audio_volume -acodec audio_codec  output_file 

Transcode decrypted VOBs

ffmpeg -i snatch_1.vob -f avi -vcodec mpeg4 -b 800k -g 300 -bf 2 -acodec libmp3lame -ab 128k snatch.avi

This is a typical DVD ripping example; the input is a VOB file, the output an AVI file with MPEG-4 video and MP3 audio. Note that in this command we use B-frames so the MPEG-4 stream is DivX5 compatible, and GOP size is 300 which means one intra frame every 10 seconds for 29.97fps input video. Furthermore, the audio stream is MP3-encoded so you need to enable LAME support by passing —enable-libmp3lame to configure. The mapping is particularly useful for DVD transcoding to get the desired audio language.

Extracting images from a video

ffmpeg i foo.avi -r 1 -s WxH -f image2 foo%03d.jpeg

This will extract one video frame per second from the video and will output them in files named `foo-001.jpeg’, `foo-002.jpeg’, etc. Images will be rescaled to fit the new WxH values.

Creating a video from many images

ffmpeg f image2 -i foo%03d.jpeg -r 12 -s WxH foo.avi

The syntax foo-%03d.jpeg specifies to use a decimal number composed of three digits padded with zeroes to express the sequence number. It is the same syntax supported by the C printf function, but only formats accepting a normal integer are suitable.

Extract audio stream from a video (mp4 or flv)

ffmpeg.exe -i input.mp4 -vn -acodec copy output.aac

Documentation

http://ffmpeg.org/ffmpeg-doc.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment