show me available ...

ffmpeg -formats
ffmpeg -codecs
ffmpeg -decoders
ffmpeg -encoders
ffmpeg -filters

getting file info

ffmpeg -i video.mpg

extract audio track only

ffmpeg -i video.flv -vn -c:a copy audio.mp3

encode from a sequence of pictures

ffmpeg -f image2 -i image%d.jpg –r 25 video.flv
ffmpeg -framerate 1/5 -i image%03d.jpg video.avi

build a video from a sequence of frame with a name like image1.jpg,image2.jpg,..,imageN.jpg

decode a video into a sequence of frames

ffmpeg -i video.mp4 –r 25 image%d.jpg

decodes the video in a sequence of images (25 images per second) with names like image1, image2, image 3, … , imageN.jpg

ffmpeg –i video.mp4 –r 0.1 image%3d.jpg

decodes a picture every 10 seconds (1/0.1=10). useful to create a thumbnail gallery for your video

ffmpeg –i video.mp4 –r 0.1 –t 20 image%3d.jpg

extracts 2-3 images from the first 20 seconds of the source

extract a slice

ffmpeg -i input -ss 00:01:00 -t 00:01:00 -c:a copy -c:v copy output.mp4

change container

ffmpeg –i input.mp4 –c:a copy –c:v copy output.flv

add metadata

ffmpeg -i input.flv -c:v copy -c:a copy -metadata title=”MyVideo” output.flv


-f fmt (input/output)
force input or output file format. The format is normally auto detected for input files and guessed from the file extension for output files, so this option is not needed in most cases

-r[:stream_specifier] fps (input/output,per-stream)
set frame rate (Hz value, fraction or abbreviation)

-ar[:stream_specifier] freq (input/output,per-stream)
set the audio sampling frequency. For output streams it is set by default to the frequency of the corresponding input stream. For input streams this option only makes sense for audio grabbing devices and raw demuxers and is mapped to the corresponding demuxer options


from several files

first of all, content of the 'input.lst' file is:
file 'input_file_1.flv'
file 'input_file_2.flv'
file 'input_file_3.flv'
file 'input_file_4.flv'
file 'input_file_5.flv'
file 'input_file_6.flv'
  ffmpeg -f concat -i input.lst -codec copy output_file.flv
remember - all input files MUST have just the same video and audio params!


"-t" option of ffmpeg is used to specify how much footage you want to convert. you can either specify the duration as a whole number of seconds ("-t 90" if you want 1½ minutes of video) or you can use hh:mm:ss.sss notation ("-t 00:02:37.200" for 2 minutes and 37.2 seconds of footage)

you don't have to start the conversion at the beginning of the source video. you can instruct ffmpeg to skip a certain time of the movie before it starts converting. this is done with the "-ss" option, and it takes an argument in the same format as "-t" (whole number of seconds or hh:mm:ss.sss)

most modern video codecs work in a way that that is far more efficient and less wasteful if both the horizontal and vertical pixel sizes are multiples of 16

how to increase/decrease volume?

to turn the audio volume up or down, you may use AudioFilter. if you want for example that the volume to be half of the input volume:
  ffmpeg -i input.wav -af 'volume=0.5' output.wav

how to remove all metadata?

the easiest way to do this is to set -map_metadata to use one of the input streams, rather than using global metadata. 99% of the time this should work
  ffmpeg -i input.mp4 -map 0 -map_metadata 0:s:0 -c copy output.mp4



ffmpeg -i file1.mp4 -vf scale="640x360" -strict -2 file2.mp4
  -vf = use video filter

ffmpeg -i input.avi -vf scale="'if(gt(iw,400),400,iw)':-1" output.flv
  iw = input width
  -1 = whatever height preserves the aspect ratio

ffmpeg -ss 01:15:50 -t 00:09:37 -i /media/2013/01.asf -q:v 5 -s 640x360 /tmp/new_01.flv
  -q:v 5 = quality (from 1 to 34 [best to worse])

ffmpeg -i someinputfile.flv -vf crop=640:272:0:44 -v:q 1 someoutputfile.flv

ffmpeg -f x11grab -s 1152x720 -framerate 25 -i :0.0 /tmp/out.mpg
  0.0 is display.screen number of your X11 server, same as the DISPLAY environment variable

ffmpeg -i audiofile.mp3 -i videofile.flv -map 1:0 -map 0:0 -map 1:1 outputfile.avi

ffmpeg -i audiofile.mp3 -i videofile.flv -filter_complex "[0:0] [1:1] amerge" outputfile.flv

#!/bin/bash ws=/tmp/cache rm -rf $ws mkdir -p $ws for i in `seq 300`; do N=$(printf %03d $i) convert -size 640x480 -background white -fill black -pointsize 120 -gravity center label:$i $ws/frame-$N.jpg done ffmpeg -y -r 2/1 -i $ws/frame-%03d.jpg -r 30/1 count.avi rm -rf $ws
ffmpeg -i hello00.mp3 -ar 22050 -ab 64k -af 'volume=2' hello01.mp3 ffmpeg -i goodbye1.flv -vf crop=480:316:0:0 -v:q 1 -vcodec h264 goodbye2.flv ffmpeg -i myfilein.flv -vf crop=160:120:10:10 -sameq /tmp/myfileout.mp4 ffmpeg -i af00.flv -ss 0:56 -t 1:27 -af 'volume=0.5' -codec copy af01.flv ffmpeg -y -i goodbye3.flv -pix_fmt gray -vcodec rawvideo goodbye4.avi ffmpeg -i kic.mpg -t 02:41 -af "volume=4" -s 640x512 -q:v 0 -strict -2 kic2.mp4 ffmpeg -framerate 1/20 -i pic%03d.jpg -i soundfile.mp3 videofile.avi # to interchange channels ffmpeg -i file_in.mp4 -map 0:1 -map 0:0 file_out.mp4 # to extract keyframes from video to imagefiles ffmpeg -i inputfile.ogg -vf select="eq(pict_type\,PICT_TYPE_I)" -vsync 2 -f image2 foo/bar-%04d.jpeg the constant of the filter is “pict_type” and the value “ PICT_TYPE_I” so ffmpeg is only passing key frames to the output -vsync 2 prevents ffmpeg to generate more than one copy for each key frame.