Sunday, 26 August 2012

ffmpeg commands

$  which ffmpeg                                  gives you path to ffmpeg

 $  ffmpeg                                              give you stats on ffmpeg

 $  ffmpeg --version                             gives you version

 $  ffmepg --help                                   give you the help menu

 $  ffmpeg --formats                              gives you a list of formats




This is a list of conversion commands within ffmpeg:

Getting info from a video file:

                                 $ ffmpeg -i video.avi

Turn X images to a video sequence

                           $ ffmpeg -f image2 -i image%d.jpg video.mpg

            This command will transform all the images from the current directory (named image1.jpg, image2.jpg, etc…) to a video file named video.mpg.

Turn a video to X images

                       $ ffmpeg -i video.mpg image%d.jpg

This command will generate the files named image1.jpg, image2.jpg, …

The following image formats are also available : PGM, PPM, PAM, PGMYUV, JPEG, GIF, PNG, TIFF, SGI.

Encode a video sequence for the ipad/iphone/ipod

$ ffmpeg -i source_video.avi input -acodec aac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -s 320x180 -title X final_video.mp4

Explanations :

Source : source_video.avi
Audio codec : aac
Audio bitrate : 128kb/s
Video codec : mpeg4
Video bitrate : 1200kb/s
Video size : 320px par 180px
Generated video : final_video.mp4

Encode video for the PSP

$ ffmpeg -i source_video.avi -b 300 -s 320x240 -vcodec xvid -ab 32 -ar 24000 -acodec aac final_video.mp4

Explanations :

Source : source_video.avi
Audio codec : aac
Audio bitrate : 32kb/s
Video codec : xvid
Video bitrate : 1200kb/s
Video size : 320px par 180px
Generated video : final_video.mp4

Extracting sound from a video, and save it as Mp3

$ ffmpeg -i source_video.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 sound.mp3

Explanations :

Source video : source_video.avi
Audio bitrate : 192kb/s
output format : mp3Generated sound : sound.mp3

Convert a wav file to Mp3

$ ffmpeg -i son_origine.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 son_final.mp3

Convert .avi video to .mpg

$ ffmpeg -i video_origine.avi video_finale.mpg

Convert .mpg to .avi

$ ffmpeg -i video_origine.mpg video_finale.avi

Convert .avi to animated gif(uncompressed)

$ ffmpeg -i video_origine.avi gif_anime.gif

Mix a video with a sound file

$ ffmpeg -i son.wav -i video_origine.avi video_finale.mpg

Convert .avi to .flv

$ ffmpeg -i video_origine.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv video_finale.flv

Convert .avi to dv

$ ffmpeg -i video_origine.avi -s pal -r pal -aspect 4:3 -ar 48000 -ac 2 video_finale.dv

Or:

$ ffmpeg -i video_origine.avi -target pal-dv video_finale.dv

Convert .avi to mpeg for dvd players

$ ffmpeg -i source_video.avi -target pal-dvd -ps 2000000000 -aspect 16:9 finale_video.mpeg

Explanations :

target pal-dvd : Output format
ps 2000000000 maximum size for the output file, in bits (here, 2 Gb)
aspect 16:9 : Widescreen

Compress .avi to divx

$ ffmpeg -i video_origine.avi -s 320x240 -vcodec msmpeg4v2 video_finale.avi

Compress Ogg Theora to Mpeg dvd

$ ffmpeg -i film_sortie_cinelerra.ogm -s 720x576 -vcodec mpeg2video -acodec mp3 film_terminée.mpg

Compress .avi to SVCD mpeg2

NTSC format:

$ ffmpeg -i video_origine.avi -target ntsc-svcd video_finale.mpg

PAL format:

$ ffmpeg -i video_origine.avi -target pal-svcd video_finale.mpg

Compress .avi to VCD mpeg2

NTSC format:

$ ffmpeg -i video_origine.avi -target ntsc-vcd video_finale.mpg

PAL format:

$ ffmpeg -i video_origine.avi -target pal-vcd video_finale.mpg

Multi-pass encoding with ffmpeg

$ ffmpeg -i fichierentree -pass 2 -passlogfile ffmpeg2pass fichiersortie-2


convert a live stream

$ ffmpeg -i http://serveraddress/streamvideo.asf -target ntsc-dvd -aspect 1.3333 -s 176x108 yourvideo.flv');

 or

$ ffmpeg -i rtmp://severaddress/myApp/myStream -acodec copy -vcodec copy -y myStream.flv   (red5)

combine two flv's with mencoder

$ mencoder.exe -fps 29.97 1.flv -fps 29.97 2.flv -o combine.flv -of lavf -ovc copy -oac copy


get movie duration with ffmpeg

function duration($videofile)
{
ob_start();
passthru("ffmpeg.exe -i "". $videofile . "" 2>&1");
$duration = ob_get_contents();
ob_end_clean();
preg_match('/Duration: (.*?),/', $duration, $matches);
$duration = $matches[1];
return($duration);
}


Extract a Video Clip on the Command-Line with avconv (ffmpeg)




If you want a quick and easy way to extract a clip from a larger video it doesn't get much simplier than using avconv (the new ffmpeg.) All you need to know is the start time and duration of the section you'd like to extract. Once you have those you can plug them in to the following command.
avconv -ss <start-time> -t <duration> -i long-video.mp4 -codec copy funny-clip.mp4
If for example you'd like to take a 48 second clip starting at 32 minutes and 15 seconds you'd use the following.
avconv -ss 00:32:15 -t 00:00:48 -i long-video.mp4 -codec copy funny-clip.mp4
Of course you can use any of the conversion capabilities of avconv in the process, here we're preserving the input codecs.
If you happen to be on an older system with ffmpeg the you'll need to make a slight modification to the command and specify copy for both audio and video.
ffmpeg -ss 00:32:15 -t 00:00:48 -i long-video.mp4 -vcodec copy -acodec copy funny-clip.mp4


----------------------------------------
Re. FFmpeg ffmpeg and avconv

when I run ffmpeg on ubuntu, it shows:
ffmpeg 
ffmpeg version v0.8, Copyright (c) 2000-2011 the Libav developers
  built on Feb 28 2012 13:27:36 with gcc 4.6.1
This program is not developed anymore and is only provided for compatibility. Use avconv instead (see Changelog for the list of incompatible changes).
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'
I found avconv on http://libav.org, I am just perplexed by them





This message is rather misleading and understandably is a source of confusion. Ubuntu now uses libav which is a fork of the FFmpeg project. The fork was basically a non-amicable result of conflicting personalities and development styles within the FFmpeg community. (It is worth noting that the maintainer for Debian/Ubuntu switched from FFmpeg to libav on his own accord probably due to being involved with the libav fork.)
For a while both libav and FFmpeg separately developed their own versions of ffmpeg. libav then renamed their ffmpeg to avconv to distance themselves from the FFmpeg project. During the transition period the message you see was displayed to tell users to start using avconv instead their version of ffmpeg. This confuses some users into thinking that FFmpeg (the project) is dead, which is not true. Unfortunate wording, but I can't imagine libav not expecting such a response by general users.
This message was removed upstream when ffmpeg was finally removed from the libav source, but it still shows up in Ubuntu because the libav source Ubuntu uses is from the ffmpeg-to-avconv transition period. After some back-and-forth it was decided to change the wording, but as of 2012-05-15 the fix is still currently "in progress" for Ubuntu Precise (see Ubuntu bug #939863).
share|improve this answer
see http://rpm.pbone.net/index.php3/stat/45/idpl/16986939/numer/1/nazwa/avconv for manual


If anyone would like to add to this list please comment below and it will be added.

No comments: