FFmpeg is a multi-purpose multimedia tool which can convert between an amazing variety of different file formats and audio and video CoDecs. Its development is done in common with that of MPlayer.
FFmpeg is undergoing continual development. Hence, any copy included with your distro is guaranteed to be out of date. Instead, always get the latest version via SubVersion from the repository linked from the FFmpeg home page (below).
Basic usage:
ffmpeg input-spec [input-spec ...] output-spec [output-spec ...] [mapping-options]
where each input-spec consists of
-i input-filename
possibly preceded by options that apply to that input file (e.g. overriding format, sample rate etc if FFmpeg guesses wrong), and each output-spec consists of
output-filename
possibly preceded by options to be applied in generating that output file.
FFmpeg does not concatenate multiple input files, it multiplexes them. Thus, you can specify an input video-only file and an input audio-only file, and get a combined video-plus-audio output file. Or you can demultiplex the input into multiple output files, for example video-only into one output file, audio-only into another, or different encodings of the same video or audio input into different outputs.
The mapping-options allow the specification of which streams from whicn input file(s) are mapped onto which streams in the output file(s). These are only necessary if FFmpeg can't figure out the right thing to do.
ffmpeg -i Videofile.mp4 -vn -acodec mp3 audiofile.mp3
Result on Ubuntu 9.04:
Unknown encoder 'mp3'
Fail!
You could follow the advice in this bug report, but why bother. Just do this:
ffmpeg -i Videofile.mp4 -vn -acodec vorbis audiofile.ogg
ffmpeg -ss hh:mm:ss:cc -t 00:00:00.01 -i input-filename -f mjpeg output-name.jpeg
For example, extract the frame at time 3 minutes and 51.04 seconds into the input video file:
ffmpeg -ss 00:03:51.04 -t 00:00:00.01 -i my-doggie.mpg -f mjpeg my-doggie-thumbnail.jpeg
NrChannels=2 SampleRate=48000 NrSeconds=1 # above parameters can be changed as appropriate ffmpeg -ar $SampleRate -acodec pcm_s16le -f s16le -ac $NrChannels \ -i <(dd if=/dev/zero bs=$(($SampleRate * $NrChannels * 2)) count=$NrSeconds) \ silence.wav
This takes a single still frame (probably best to stick to JPEG format, certainly PNG didn't work) and turns it into an MPEG-2 output movie with a silent soundtrack. The movie is of one-second duration, which is sufficient because it can be set to loop during the DVD authoring process:
ffmpeg -loop_input -t 1.0 -i stillframename \ -ar 48000 -f s16le -i <(dd if=/dev/zero bs=192000 count=1) \ -target pal-dvd outputmoviename
where pal-dvd can be replaced with ntsc-dvd if authoring an NTSC disc rather than PAL.
In this example, 64 seconds (determined by trial and error while observing lip sync) was trimmed from the start of the audio track. The video track happens to come first in the list; the source movie is specified twice, once with the appropriate offset applied, and the -map option is used to select the appropriate audio and video streams to combine into the output movie: the first -map specification says that the first (video) output stream is to come from the first stream of the second input file (stream 1.0), while the second -map specification says that the second (audio) output stream is to come from the second stream of the first input file (stream 0.1). Note the use also of -vcodec copy and -acodec copy to ensure that no re-encoding of audio or video data takes place:
ffmpeg \ -ss 00:01:04.00 -i srcmovie \ -i srcmovie \ -vcodec copy -acodec copy dstmovie \ -map 1.0 -map 0.1
3 pages link to FFmpeg: