View Single Post
Posts: 230 | Thanked: 302 times | Joined on Oct 2009 @ Helsinki, Suomi (Finland)
#1
I was playing with ffmpeg on my laptop trying to figure out good settings in encoding video for the N9. Settings that would also play nicely with Harmattan's default video player and support Dolby 5.1 surround when possible. I used Nokia Developer Wiki as a reference.

Encoding/Transcoding

For x264 baseline profile and 6 channel ac3 audio (ca. 700MB/h):
Code:
$ ffmpeg -i infile.mp4 -s 854x480 -r 25 -g 25 -vcodec libx264 -vb 1536k -vprofile baseline -acodec ac3 -ab 192k -ac 6 outfile.mp4
If you need a smaller file size (ca. 500MB/h) 1024kb/s video bit rate is also very watchable:
Code:
$ ffmpeg -i infile.mp4 -s 854x480 -r 25 -g 25 -vcodec libx264 -vb 1024k -vprofile baseline -acodec ac3 -ab 192k -ac 6 outfile.mp4
Ripping a DVD

One method to rip a DVD is to concatenate VOB files and pipe the output to ffmpeg:
Code:
$ cat VTS_02_1.VOB VTS_02_2.VOB VTS_02_3.VOB | ffmpeg -i - -r 25 -g 25 -vcodec libx264 -vb 1536k -vprofile baseline -acodec ac3 -ab 192k -ac 6 ~/outfile.mp4
You will often spot the correct VOB files on a DVD by simply looking at the filesize (larger ones usually contain the main movie, while the smaller ones are menus and extras). If unsure, play a VOB file with mplayer (or your player of choice) to see what it contains.

If you want to remove black borders when ripping a DVD you can play a VOB file using "mplayer -vf cropdetect" and simply copy & paste the crop filter string from its output (for example -vf crop=704:432:10:72) into your ffmpeg command.

Sometimes DVDs have several audio tracks for different languages and by default ffmpeg rips only the first one. If you need to select another audio track you can do that by using -map flags. For more information see: http://howto-pages.org/ffmpeg/#map

Legend

Flags in use (as of ffmpeg v.1.0.1):
-i = input file *
-s = video resolution
-r = frame rate **
-g = I-frame interval (frames) ***
-vcodec = video codec
-vb = video bit rate
-vprofile = video profile ****
-acodec = audio codec
-ab = audio bit rate
-ac = audio channels

* Most video formats/containers will work as input.
** Practical framerate limits for smooth playback are 30fps@854x480 and 25fps@1280x720. [thanks thedead1440]
*** More frequent I-frames improve error correction and seek performance at cost of filesize. (The Nokia Developer Wiki recommends one I-frame/s.)
**** -vpre in older versions, you can also try -profile

Any improvements/corrections/alternative methods are more than welcome.

Last edited by ladoga; 2012-12-25 at 21:11.
 

The Following 11 Users Say Thank You to ladoga For This Useful Post: