Active Topics

 


Reply
Thread Tools
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:
Posts: 1,048 | Thanked: 1,127 times | Joined on Jan 2010 @ Amsterdam
#2
Can't promote ffmpeg enough as the tool to use when encoding. Thanks for the clear instructions.
 
www.rzr.online.fr's Avatar
Posts: 1,348 | Thanked: 1,863 times | Joined on Jan 2009 @ fr/35/rennes
#3
why not suggest a patent free output format ? like ogv theora or webm ? but will those codec be hardware accelerated ?

--
http://rzr.online.fr/q/codec
__________________
Current obsession:

https://purl.org/rzr/abandonware

Please help to list all maemo existing apps :

https://github.com/abandonware/aband...ment-578143760

https://wiki.maemo.org/Apps#

I am looking for " 4 inch TFT LCD display screen " for Nokia n950 HandSet

http://rzr.online.fr/q/lcd


Also, I need online storage to archive files :

http://db.tt/gn5Qffd6#

https://my.pcloud.com/#page=register...e=g8ikZmcfEJy#
 

The Following User Says Thank You to www.rzr.online.fr For This Useful Post:
Posts: 230 | Thanked: 302 times | Joined on Oct 2009 @ Helsinki, Suomi (Finland)
#4
Originally Posted by www.rzr.online.fr View Post
why not suggest a patent free output format ? like ogv theora or webm ? but will those codec be hardware accelerated ?

--
http://rzr.online.fr/q/codec
I wanted to get smoothly playing 854x480 video and I presume that other formats are not HW accelerated (See the developer wiki, link in the first post). The audio codec is likewise chosen only because it's the only one supported for surround sound on the N9.

Using patent free formats would be better in every other respect. I hope someone wants to experiment with them to find out the best quality that we can play on our N9's and add to this thread.

Last edited by ladoga; 2012-12-23 at 08:18.
 
Moderator | Posts: 6,215 | Thanked: 6,400 times | Joined on Nov 2011
#5
ladoga,

For the second command I think you mean to put it as -vb 1024k instead of 1536k


Edit: I know you hate resolutions higher than the stock but i tried and it works perfectly fine with 1280x720; will now attempt to use movgrab to download a file and encode it to 720p baseline at the same time so that one file can be played across your desktop and device...


Edit 2: I missed out on the "" marks in the movgrab stage and it wasn't working but it works now

Code:
~ $ X=input.mp4 ; movgrab -o "$X" -f mp4:1280x720 "http://www.youtube.com/watch?v=xxxxxxx" ; ffmpeg -i $X -s 1280x720 -r 25 -g 25 -vcodec libx264 -vb 1024k -vprofile baseline -acodec ac3 -ab 192k -ac 6 output.mp4 ; rm -rf $X

Edit 3: Update second edit with a cleaner command and changed fps to 25fps with 1 I-frame being created per second as per ladoga's method which results in smoother seeking in the video.


Edit 4: Just realized that the command in edit 2 says 1024k for the video bitrate; it can be safely increased to 1536k as per ladoga's first post.

Last edited by thedead1440; 2012-12-26 at 04:02. Reason: Edited one-line command for better usability
 

The Following 3 Users Say Thank You to thedead1440 For This Useful Post:
Posts: 230 | Thanked: 302 times | Joined on Oct 2009 @ Helsinki, Suomi (Finland)
#6
Seems like burning srt subtitles into movies using ffmpeg is possible: http://ffmpeg.org/trac/ffmpeg/wiki/H...%20the%20video

Though with v.1.0.1 trying "-vf subtitles=whatever.srt" spits out "No such filter: 'subtitles'" in bold red
 

The Following User Says Thank You to ladoga For This Useful Post:
Moderator | Posts: 6,215 | Thanked: 6,400 times | Joined on Nov 2011
#7
Originally Posted by ladoga View Post
Seems like burning srt subtitles into movies using ffmpeg is possible: http://ffmpeg.org/trac/ffmpeg/wiki/H...%20the%20video

Though with v.1.0.1 trying "-vf subtitles=whatever.srt" spits out "No such filter: 'subtitles'" in bold red
Using that worked for me; maybe its the version of ffmpeg?

I'm using 7:201212231432-git-1 which seems to be after the 29/11/12 date the man page states for 'subtitles' support... I had followed the instructions here to get that version...


Edit: Hmmm I think I spoke too early; I first tried with a .sub file everything processed but at the end it sayed subtitle=0 so then tried with a .srt file which was detected but the resulting output.avi for some reason doesn't playback in VLC or GNOME Mplayer... Again in the video that used the .srt file the output said subtitle:0

Another thing I noticed was the dramatic down-sizing of the file; my input.avi was 732.4MB but the output.avi came to only a paltry 288.9MB... I have used it just like in the manpage:
Code:
ffmpeg -i input.avi -vf subtitles=/path/to/.srt/file output.avi
I think maybe an option or two in the command is missing


Edit 2: Just noticed when doing the above command this is what I got exactly:
Neither PlayResX nor PlayResY defined. Assuming 384x288

So it means the output.avi has to be defined? Will try later when I have some time on my hands

Last edited by thedead1440; 2012-12-26 at 05:00.
 

The Following User Says Thank You to thedead1440 For This Useful Post:
Posts: 230 | Thanked: 302 times | Joined on Oct 2009 @ Helsinki, Suomi (Finland)
#8
Originally Posted by thedead1440 View Post
Using that worked for me; maybe its the version of ffmpeg?
Or maybe it's about the version of libavfilter? I'll probably wait until debian multimedia gets newer ones. Meanwhile I can use (K)MPlayer on N9 to view subtitles.

or GNOME Mplayer
If you need a good MPlayer frontend for desktop I suggest you to try out SMPlayer. Last time I checked (few years ago) the playback quality and subtitle rendering in MPlayer were noticeably better than in VLC. VLC has nice GUI though, but SMPlayer isn't bad either. My favorite feature is automated subtitle download/upload from opensubtitles.org.

I think you told earlier about audio video sync problems when playing some files on N9 with KMPlayer using MPlayer as backend. Here is a likely remedy for that. Try autosync=30 in ~/.mplayer/config to use more agressive a/v sync. Also you can look for "mc" flag (sets maximum allowed correction in seconds) in the documentation.

Last edited by ladoga; 2012-12-26 at 12:18.
 

The Following User Says Thank You to ladoga For This Useful Post:
Posts: 231 | Thanked: 143 times | Joined on Feb 2012 @ Tallinn, Estonia
#9
Thanks! Just converted some videos to "x264 baseline profile and 6 channel ac3 audio" and they work fine on N9. Just I found command line ffmpeg to difficult to use and used WinFF user interface: http://winff.org/html_new/downloads.html where I added custom preset as follows:

Preset Name: NokiaN9
Preset Label: Nokia N9
Preset command line parameters: $ -s 854x480 -r 25 -g 25 -vcodec libx264 -vb 1536k -vprofile baseline -acodec ac3 -ab 192k -ac 6
Output file extension: mp4
 
Posts: 78 | Thanked: 28 times | Joined on Apr 2012 @ Curitiba-PR . Brasil
#10
Originally Posted by ladoga View Post
Seems like burning srt subtitles into movies using ffmpeg is possible: http://ffmpeg.org/trac/ffmpeg/wiki/H...%20the%20video

Though with v.1.0.1 trying "-vf subtitles=whatever.srt" spits out "No such filter: 'subtitles'" in bold red
using ffmpeg version git-2012-11-25-b473c99
-
ffmpeg -i input.mp4 -i input.srt -scodec copy output.mp4
-
with a bonus of 33% lower compared to the original file
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 09:10.