Skip to content

Instantly share code, notes, and snippets.

@nkokkos
Forked from vtypal/ffmpeg_short_guide.textile
Created January 30, 2010 13:33
Show Gist options
  • Save nkokkos/290551 to your computer and use it in GitHub Desktop.
Save nkokkos/290551 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.

Documentation

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


Added this too from http://createdigitalmotion.com/2010/01/ffmpeg-recipes-building-on-your-os-splitting-video-audio/:

1. To copy video and remove audio from a file:

 ffmpeg -i [inputfile] -an -vcodec copy [outputfile] 

This switches off the audio (-an) and simply copies the video data without touching it (-vcodec copy).

2. To copy audio of the video, transcoding to WAV:

ffmpeg -i [input file] -acodec adpcm_ima_wav [output file] 

This copies just the audio, and sets the audio codec to a standard PCM wav readable on Windows and other OSes.

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