You will recieve your password to this address. Address is not made public.

Your preferred username that is used when logging in.

Perfecting h264 conversion with ffmpeg Created Jan 1, 2009

This thread is solved

Views: 40668     Replies: 55     Last reply yesterday 01:04  
You must login first before you can use this feature

Liam Gooding
Custom swf skins, custom swf plugins, custom JS plugins, video CMS - http://goodingsmedia.com

Posts: 359

Registered:
Dec 16, 2008

Perfecting h264 conversion with ffmpeg

Posted: Jan 1, 2009

Hi,

Following an idea from Edge, I'd like to post an experiment here. I've added Hi-Def quality to my site, so any uploaded videos that are HD will also have a HD MP4 version converted, as well as 2 different FLV versions.

I'm wanting to perfect the MP4 conversion first though, so I'm testing with 720p .mov trailer from Apple.

http://www.apple.com/trailers/wb/inkheart/
Filesize: 94.4MB
Length: 2:08
Size: 1280x544
Video Bitrate: 5750kbps
Audio Bitrate: 132kbps

Grab it and have a go with ffmpeg and then paste the results.

ffmpeg documentation is sketchy, and there's countless different command line floating around the net, but often with very little explanation. I'm assuming most people using flowplayer will at some point wish to create some MP4 video, and many (like me) will need to do it on linux server side so that it can be automated.

Once we get a perfect formula, I can write it into my server side conversion tutorial I'm writing.

My current one is here:

http://www.fightnightlive.co.uk/mp4/87-1.mp4
Filesize: 19MB
Size: 1280x544
Video Bitrate: 1088kbps (not sure why its not 1600k)
Audio Bitrate: 96kbps

Conversion Line

ffmpeg -y -i trailerTest.mov -acodec libfaac -ar 44100 -ab 96k -coder ac -me full -me_range 16 -subq 5 -sc_threshold 40 -vcodec libx264 -s 1280x544" -b 1600k -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -i_qfactor 0.71 -keyint_min 25 -b_strategy 1 -g 250 -r 20 87.mp4;

Paramaters I can explain (or understand)
-y :: overwrite the output file if it already exists
-i trailerTest.mov :: the input video file
-acodec libfaac :: using the aac codec
-ar 44100 :: the audio sampling rate
-ab 96k :: the audio bitrate
-vcodec libx264 :: use the x264 codec
-s 1280x540 :: the size of the output video
-b 1600k :: the bitrate of the output video
-g 250 :: frequency of keyframes
-r 20 :: the frame rate
87.mp4 :: the output file

The others are just bits that I've found through Google. I have little idea what they actually do...

So, ffmpeg gurus, lets have a go at getting the perfect balance between filesize and quality to stream an MP4 file in H-Definition to a regular broadband user!

Liam Gooding
Custom swf skins, custom swf plugins, custom JS plugins, video CMS - http://goodingsmedia.com

Posts: 359

Registered:
Dec 16, 2008

» Perfecting h264 conversion with ffmpeg

Posted: Jan 2, 2009

Reply to: Perfecting h264 conversion with ffmpeg, from LiamGooding

ffmpeg -y -i input.mov -acodec libfaac -ar 44100 -ab 96k -vcodec libx264 -level 41 -crf 20 -bufsize 20000k -maxrate 25000k -g 250 -r 20 -s 1280x544 -coder 1 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +brdo+dct8x8+bpyramid -me umh -subq 7 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq 'blurCplx^(1-qComp)' -bf 16 -b_strategy 1 -bidir_refine 1 -refs 6 -deblockalpha 0 -deblockbeta 0 output.mp4

http://www.fightnightlive.co.uk/mp4/87-2.mp4
File: 49.5MB
Video: 2987kbps
Audio: 96kbps

Quality is identical (to my eye) to the 90MB original APART FROM I think the original has slightly richer color in places. At an average of 25MB per minute of video though, it's a little to hungry on BW for me...

Tero
Author of jQuery Tools and this website + JavaScript developer of Flowplayer.

Posts: 1831

Registered:
Nov 16, 2007

» Perfecting h264 conversion with ffmpeg

Posted: Jan 2, 2009

Reply to: Perfecting h264 conversion with ffmpeg, from LiamGooding
liam/edge. good stuff. you seem to know these areas. I'm expecting a tutorial from edge so that you can share this expertise to everyone (including me).

Liam Gooding
Custom swf skins, custom swf plugins, custom JS plugins, video CMS - http://goodingsmedia.com

Posts: 359

Registered:
Dec 16, 2008

» Perfecting h264 conversion with ffmpeg

Posted: Jan 2, 2009

Reply to: Perfecting h264 conversion with ffmpeg, from LiamGooding
Latest:

http://www.fightnightlive.co.uk/mp4/87.mp4
file: 24MB

Quality is almost identical to the 90MB one. I can't spot any difference between this and the 87-2.mp4 file (which is double filesize)

Tero
Author of jQuery Tools and this website + JavaScript developer of Flowplayer.

Posts: 1831

Registered:
Nov 16, 2007

» » Perfecting h264 conversion with ffmpeg

Posted: Jan 2, 2009

Reply to: » Perfecting h264 conversion with ffmpeg, from LiamGooding
amazing optimizations. this knowledge is golden.

rmarnold

Posts: 2

Registered:
Jan 14, 2009

WOW

Posted: Jan 14, 2009

Reply to: » Perfecting h264 conversion with ffmpeg, from LiamGooding
http://www.fightnightlive.co.uk/mp4/87.mp4

What flags did you use to accomplish that compression? It looks really good.

Liam Gooding
Custom swf skins, custom swf plugins, custom JS plugins, video CMS - http://goodingsmedia.com

Posts: 359

Registered:
Dec 16, 2008

» WOW

Posted: Jan 15, 2009

Reply to: WOW, from rmarnold
It's basically this:



ffmpeg -y -i input.mov -acodec libfaac -ar 44100 -ab 96k -vcodec libx264 -level 41 -crf 20 -bufsize 20000k -maxrate 25000k -g 250 -r 20 -s 1280x544 -coder 1 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +brdo+dct8x8+bpyramid -me umh -subq 7 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq 'blurCplx^(1-qComp)' -bf 16 -b_strategy 1 -bidir_refine 1 -refs 6 -deblockalpha 0 -deblockbeta 0 output.mp4

But I adjusted the -crf flag to read -crf 25

The drop in quality was unoticeable to my eye, but the filesize halved. One important thing though, I'm working with the very best input source.

I've run this conversion with a medium HD input source, of which the results can be seen here:

http://www.fightnightlive.co.uk/video-104/high/test-hd/

There's some strange things going on with the sound... need to look at that. I think for now I may drop down my resolution to non-HD as I've been checking out the ON2 site at their latest codecs for HD, and the results are amazing! Though it will come with a price tag into the $$$$ :-(

rmarnold

Posts: 2

Registered:
Jan 14, 2009

WOW

Posted: Jan 16, 2009

Reply to: » WOW, from LiamGooding
How long does it take you to render your videos?

Have you tried using the "-threads" flag. If you have a quad core type "-threads 4". speeds up rendering!

christos

Posts: 2

Registered:
Oct 28, 2008

latest ffmpeg

Posted: Mar 14, 2009

Reply to: » WOW, from LiamGooding
I had to remove +brdo from -flags2 and change -me to -me_method to get this to work with the latest ffmpeg... subq 7 activates B-Frames

http://ffmpeg.x264.googlepages.com/mapping

doofus

Posts: 1

Registered:
Aug 22, 2009

» » WOW

Posted: Aug 22, 2009

Reply to: » WOW, from LiamGooding
I tried to create a file with these flags -- producing both .mpg and .mp4 as output files.

Neither of the outputs were playable by mplayer nor vlc.

Mplayer, in particular, had the following to say:
MPlayer 1.0rc2-4.2.1 (C) 2000-2007 MPlayer Team
CPU: Dual Core AMD Opteron(tm) Processor 275 (Family: 15, Model: 33, Stepping: 2)
CPUflags: MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 1
Compiled for x86 CPU with extensions: MMX MMX2 3DNow 3DNowEx SSE SSE2

Playing /meow/tmp/KU.mp4.
libavformat file format detected.
LAVF: no audio or video headers found - broken file?
RAWDV file format detected.
VIDEO: [DVSD] 720x480 24bpp 29.970 fps 0.0 kbps ( 0.0 kbyte/s)
==========================================================================
Requested video codec family [qdv] (vfm=dshow) not available.
Enable it at compilation.
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffdv] vfm: ffmpeg (FFmpeg DV decoder)
==========================================================================
==========================================================================
Opening audio decoder: [libdv] Raw DV Audio Decoder
Unknown/missing audio format -> no sound
ADecoder init failed :(
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
Cannot find codec 'dvaudio' in libavcodec...
ADecoder init failed :(
ADecoder init failed :(
Cannot find codec for audio format 0x56444152.
Read DOCS/HTML/en/codecs.html!
Audio: no sound
Starting playback...
VDec: vo config request - 720 x 480 (preferred colorspace: Planar 411P)
Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
VDec: using Planar 411P as output csp (no 0)
Movie-Aspect is undefined - no prescaling applied.
SwScaler: reducing / aligning filtersize 1 -> 4
SwScaler: reducing / aligning filtersize 5 -> 4
SwScaler: reducing / aligning filtersize 1 -> 1
SwScaler: reducing / aligning filtersize 9 -> 8
[swscaler @ 0xd40780]SwScaler: BICUBIC scaler, from yuv411p to yuv420p using MMX2
[swscaler @ 0xd40780]SwScaler: using 4-tap MMX scaler for horizontal luminance scaling
[swscaler @ 0xd40780]SwScaler: using 4-tap MMX scaler for horizontal chrominance scaling
[swscaler @ 0xd40780]SwScaler: using 1-tap MMX "scaler" for vertical scaling (YV12 like)
[swscaler @ 0xd40780]SwScaler: 720x480 -> 720x480
VO: [xv] 720x480 => 720x480 Planar YV12 [fs]
AC EOB marker is absent pos=74
AC EOB marker is absent pos=64
AC EOB marker is absent pos=75
AC EOB marker is absent pos=65
AC EOB marker is absent pos=109
AC EOB marker is absent pos=64
AC EOB marker is absent pos=64
AC EOB marker is absent pos=65
AC EOB marker is absent pos=64
AC EOB marker is absent pos=81
AC EOB marker is absent pos=64
AC EOB marker is absent pos=64
AC EOB marker is absent pos=109
AC EOB marker is absent pos=68
AC EOB marker is absent pos=64
AC EOB marker is absent pos=64
AC EOB marker is absent pos=65
...

Buzz
Author of 'Wordpress Flowplayer', jQuery.saiweb http://saiweb.co.uk Problems, requests? Please log a ticket at: http://trac.saiweb.co.uk

Posts: 265

Registered:
Dec 17, 2008

» Perfecting h264 conversion with ffmpeg

Posted: Jan 5, 2009

Reply to: Perfecting h264 conversion with ffmpeg, from LiamGooding
Hi Liam,
I agree ffmpeg documentation is very poor, it is one topic I have ment to pick back up.

Thanks for sharing your results, for reference (i.e. anyone searching to forum), you can find my (somewhat limited) information regarding FFMPEG and setup here:http://www.saiweb.co.uk/?s=ffmpeg

Would you mind if I posted your results in a blog entry?

And if I can post the results where do you want the credit link pointing to?

Cheers

Buzz

Buzz
Author of 'Wordpress Flowplayer', jQuery.saiweb http://saiweb.co.uk Problems, requests? Please log a ticket at: http://trac.saiweb.co.uk

Posts: 265

Registered:
Dec 17, 2008

» » Perfecting h264 conversion with ffmpeg

Posted: Jan 5, 2009

Reply to: » Perfecting h264 conversion with ffmpeg, from DBusby
Also, have you tried the -sameq flag in your ffmpeg runs?

How does this affect your filesize?

Going from memory a quick output would be:


ffmpeg -y -i input_file.mov -r 20 -g 40 -acodec libfaac -ar 44100 -ab 96k -vcodec libx264 -sameq output_file.mp4

Assuming of course FFMPEG (or rather libx264) at this point does not complain about the video dimensions not being devisible by x, it should output an identical quality file, it has been a long time since used ffmpeg (aug 08) so forgive me if the above line doesn't work :-P

Also I usually go by the keyframe every other second, so g = 2r, I'd be interested to know if setting different keyframe frequencies had any effect on the file at all.

Liam Gooding
Custom swf skins, custom swf plugins, custom JS plugins, video CMS - http://goodingsmedia.com

Posts: 359

Registered:
Dec 16, 2008

» » » Perfecting h264 conversion with ffmpeg

Posted: Jan 5, 2009

Reply to: » » Perfecting h264 conversion with ffmpeg, from DBusby
Hey Buzz,

RE a blog entry of course you can mate. Feel free to add a link over tohttp://www.goodingsweb.com :P

I'll have a test with -sameq later this evening and post the results. I had already come across your blog posts RE making a HD Youtube, but it seems like other things have got the better of your time recently (i.e. the WP plugin)

RE keyframes, one every 2 seconds is way to high for the web IMO. I haven't experimented with the exact filesize increase though.

One thing to mention, is I can't get 2 pass to work with libx264. It doesn't seem to take any notice of the log file parameter. (I've seen the bug mentioned with a bit of googling) If I could get 2 pass working, I'm sure the quality or filesize would become even better!

Also, the latest example I posted had almost double the processing time on the server. So for high volume upload sites it'll need something pretty beasty to crunch it all.

Buzz
Author of 'Wordpress Flowplayer', jQuery.saiweb http://saiweb.co.uk Problems, requests? Please log a ticket at: http://trac.saiweb.co.uk

Posts: 265

Registered:
Dec 17, 2008

» » » » Perfecting h264 conversion with ffmpeg

Posted: Jan 5, 2009

Reply to: » » » Perfecting h264 conversion with ffmpeg, from LiamGooding
Hey Liam,

Cool expect a post soon, and yeh HD Youtube write up kinda hit a wall, it is planned to be back being as I have now a dedi ready to go for it :-)

RE: Keyframes to high? My understanding of keyframes is that they are much like indexes in a database and aid in seeking, am I wrong?

Care to elaborate on keyframes a bit for me? :D

RE: 2 pass encoding, I haven't been able to get it to work either! One example I saw sent the first pass to /dev/null ... which seemed entirely pointless and confused the hell out of me.

RE: Processing time

I am in the fortunate situation of having a multi cored server :-) I know ffmpeg has a -threads flag (or similar), if you have a multi cored server and are worried about load on the CPU, it may be worth forcing ffmpeg to one thread, it'll take longer to encode but it's only hammering one core.

Liam Gooding
Custom swf skins, custom swf plugins, custom JS plugins, video CMS - http://goodingsmedia.com

Posts: 359

Registered:
Dec 16, 2008

» » » » » Perfecting h264 conversion with ffmpeg

Posted: Jan 5, 2009

Reply to: » » » » Perfecting h264 conversion with ffmpeg, from DBusby
yeah, basically when seeking you can only seek to the nearest keyframe. So, a keyframe every 2 seconds means your users can seek with a precision of 2seconds.

However, in web video this type of precision isn't really needed. Each key frame adds a tiny chunk of filesize, so ideally we want as few keyframes as possible without sacrificing on usability.

I'm half way through writing a general kind of PHP CMS/ffmpeg conversion tutorial for the FP.org tuts. I'll drop it over when it's a little closer, will be a lot better to have someone else contribute to it too. TBH this hi-def coding was the main gap.

FightNightLive.co.uk is on a VPS on an 8 core server, but obviously with a cap. Bursts can use 4 cores I think though. I think the main issue would be if someone actually added this CMD line to their tube style site, where the usual philosophy is quantity over quality. In that case I think encoding HD to this quality would end up costing them more on CPU load than the end profit!

Buzz
Author of 'Wordpress Flowplayer', jQuery.saiweb http://saiweb.co.uk Problems, requests? Please log a ticket at: http://trac.saiweb.co.uk

Posts: 265

Registered:
Dec 17, 2008

» » » » » » Perfecting h264 conversion with ffmpeg

Posted: Jan 5, 2009

Reply to: » » » » » Perfecting h264 conversion with ffmpeg, from LiamGooding
Yeh I really need to get this HD Youtube code out the door then xD

I need a decent project name though, latin is letting me down and cavus eternus (Eternal Hole) I don't think will be suitable, suggestions?

It has a full 'queuing' system for uploads to be encoded, this removes the 'on the fly' aspect but allows to cope with volume or as you put it 'quantity over quality'.

And as entry level HD is 720p (1280x720) the 'application' will reject any resolutions below this level, as "upscaling" (as in enlarging not the losely termed DVD > HD conversion), never works out well via ffmpeg I find.

Buzz
Author of 'Wordpress Flowplayer', jQuery.saiweb http://saiweb.co.uk Problems, requests? Please log a ticket at: http://trac.saiweb.co.uk

Posts: 265

Registered:
Dec 17, 2008

» » » » Perfecting h264 conversion with ffmpeg

Posted: Jan 6, 2009

Reply to: » » » Perfecting h264 conversion with ffmpeg, from LiamGooding
http://www.saiweb.co.uk/linux/perfecting-h264-conversion-with-ffmpeg

Entry made, albeit a short one :-)

New flowplayer plugin settings workign well anyway hehe

Liam Gooding
Custom swf skins, custom swf plugins, custom JS plugins, video CMS - http://goodingsmedia.com

Posts: 359

Registered:
Dec 16, 2008

» » » » » Perfecting h264 conversion with ffmpeg

Posted: Jan 8, 2009

Reply to: » » » » Perfecting h264 conversion with ffmpeg, from DBusby
Cool blog entry :P

Although lets hope you don't get too much traffic to it as I actually stream my videos via a CDN normally.... hehe

RE conversion, yeah I'm checking for the vertical size using ffmpeg-php and then either make upto 3 different versions: 400kbps, 800kbps, 1600kbps (HD)

Still not overly impressed with the FLV quality of ffmpeg but I guess thats only because now I know better after seeing h264/mp4 videos.

If no one else has any additional command lines to offer, I'm going to mark this as solved as I think a 2min HD video in 24mb is about as good as it's going to get (using freeware ffmpeg)

Buzz
Author of 'Wordpress Flowplayer', jQuery.saiweb http://saiweb.co.uk Problems, requests? Please log a ticket at: http://trac.saiweb.co.uk

Posts: 265

Registered:
Dec 17, 2008

» » » » » » Perfecting h264 conversion with ffmpeg

Posted: Jan 8, 2009

Reply to: » » » » » Perfecting h264 conversion with ffmpeg, from LiamGooding
Indeed

Also as a side note I've been trying to get ffmpeg compiled as 64bit for about 4 hours (2hrs an evening over 2 days) ...

xD

All fun and games

Liam Gooding
Custom swf skins, custom swf plugins, custom JS plugins, video CMS - http://goodingsmedia.com

Posts: 359

Registered:
Dec 16, 2008

» » » » » » » Perfecting h264 conversion with ffmpeg

Posted: Jan 17, 2009

Reply to: » » » » » » Perfecting h264 conversion with ffmpeg, from DBusby
Have you seen this?

http://wordpress.org/extend/plugins/wordpresscom-video-server/

Just saw it. It looks like a lot of code and will probabaly be quicker to start from scratch rather than chop away the unwanted bits, but it shows a good way of incorporating it.

greener

Posts: 18

Registered:
Nov 4, 2008

» » » » » » » » Perfecting h264 conversion with ffmpeg

Posted: Jan 21, 2009

Reply to: » » » » » » » Perfecting h264 conversion with ffmpeg, from LiamGooding
server based encoding is definitely the way to go. For those of us that don't want to go through the trouble of configuring ffmpeg ourselves, I'd suggest looking at heywatch (www.heywatch.com). the configuration and options many, the api robust and they respond very quick to questions. And it's .10 cents per encode (.20 for 2-pass). definitely worth it in my mind. For others that want to get their hands dirty with ffmpeg. here are three great resources

http://ffmpeg.x264.googlepages.com/mapping

http://rob.opendot.cl/index.php/useful-stuff/x264-to-ffmpeg-option-mapping/

http://rob.opendot.cl/index.php/useful-stuff/ffmpeg-x264-encoding-guide/

cheers,
rg

fjaif

Posts: 24

Registered:
Jan 19, 2009

» » » » » » » » » Perfecting h264 conversion with ffmpeg

Posted: Jan 22, 2009

Reply to: » » » » » » » » Perfecting h264 conversion with ffmpeg, from greener
Dear All:

I have a question!. Is that possible to detect the video source as HD or non HD using ffmpeg commands?
I have a requirement to identify the file source and based on the source, if it is HD source of mp4,m4v,xyz extension with mp4 code, It will simply take a thumbnail and move the file, if any other source it will convert using ffmpeg.

I am planning this way to minimize the bandwidth and upload time while offering HD videos. ffmpeg conversion for HD is taking too much space and resources. Whoever wants to upload the HD video, they will covert offline using desktop tools?? good idea?

OR is there any other way?

Joust
Dissapointed with noone to fix aac hanging bug.

Posts: 57

Registered:
Jan 23, 2009

» » » » » » » » » » Perfecting h264 conversion with ffmpeg

Posted: Jan 24, 2009

Reply to: » » » » » » » » » Perfecting h264 conversion with ffmpeg, from fjaif
Query the file with:
ffmpeg -i somefile.mp4

Then parse the output with regex, ie:

/FFMpeg.*Input #0, (.*?),.*Duration: ([0-9.:]+).*bitrate: (d+) .*?Stream.*Video: (.*?),.*?, (d+xd+).*?, ([d.]+) tb(r)(.*?Stream.*Audio: (.*?), (d+) Hz, (.*?), (.*?), ([d]+))?/
This will extract all important data about video and audio. Use it with php's preg_match() or similar.

Liam Gooding
Custom swf skins, custom swf plugins, custom JS plugins, video CMS - http://goodingsmedia.com

Posts: 359

Registered:
Dec 16, 2008

» » » » » » » » » » Perfecting h264 conversion with ffmpeg

Posted: Jan 27, 2009

Reply to: » » » » » » » » » Perfecting h264 conversion with ffmpeg, from fjaif
Lets assume your using PHP in your upload system:

First, check the file extension:


<?php
/**
* simply rounds a number to the nearest multiple specified
**/
function round_nearest($no,$near) 
{ 
    return round($no/$near)*$near; 
} 

// by default, lets asusme the file isn't an mp4, mpeg4, m4v
$file_h264 = 0;
// lets assume it isn't HD
$file_HD = 0;

// now check the extension of the file that has been uploaded
if(substr(strtolower($_FILES['the_file']['name']), -4) == '.mp4') {
	$ext = '.mp4';
	$file_h264 = 1;
} elseif(substr(strtolower($_FILES['the_file']['name']), -6) == '.mpeg4') {
	$ext = '.mpeg4';
	$file_h264 = 1;
} elseif(substr(strtolower($_FILES['the_file']['name']), -4) == '.m4v') {
	$ext = '.m4v';
	$file_h264 = 1;
}

// now create a new ffmpeg object using ffmpeg-php
$ffmpegObj = new ffmpeg_movie($srcFile);

// now get the width and height
$srcWidth = round_nearest($ffmpegObj->getFrameWidth(), 2);
$srcHeight = round_nearest($ffmpegObj->getFrameHeight(), 2);

// here we assume a HD video to be wider than 1280px AND be of type mp4, m4v, mpeg4
if(($srcWidth >= 1280) && $file_h264 == 1){
	$file_HD = 1;
}

// now go on and use $file_HD = 1 to continue with your script :-)
?>

:-)

Although the above is chopped away from 3 seperate files on my standard script. I advise seperating the upload, the analysis and the conversion over 3 files to speed up the user upload experience.

Buzz
Author of 'Wordpress Flowplayer', jQuery.saiweb http://saiweb.co.uk Problems, requests? Please log a ticket at: http://trac.saiweb.co.uk

Posts: 265

Registered:
Dec 17, 2008

» » » » » » » » » » » Perfecting h264 conversion with ffmpeg

Posted: Jan 27, 2009

Reply to: » » » » » » » » » » Perfecting h264 conversion with ffmpeg, from LiamGooding
For reference HD resolutions can be found listed here:http://en.wikipedia.org/wiki/High-definition_television

720p 1280x720
1080i 1280x1080
1080p 1920×1080
2106p 3840×2160

fjaif

Posts: 24

Registered:
Jan 19, 2009

» » » » » » » » » » » » Perfecting h264 conversion with ffmpeg

Posted: Jan 29, 2009

Reply to: » » » » » » » » » » » Perfecting h264 conversion with ffmpeg, from DBusby
Thank you so much to Joust, Buzz and LiamGooding for links, code and advice. Appreciated your reply, I will prefix my convert code with similar logic.

Yes, I do have move upload file, init file, convert, grab image in 4 different action functions.

vinnypolston

Posts: 4

Registered:
Nov 19, 2008

Hey Laim, quick qustion.

Posted: Feb 14, 2009

Reply to: Perfecting h264 conversion with ffmpeg, from LiamGooding
First off, thank you so very much for your help so far!
I am completely new to ffmpeg and am in the process of compiling it...
But I wanted to ask you, if you don't mind. What configuration options do YOU use when building ffmpeg? I don't want to get this wrong..

Thanks,

Liam Gooding
Custom swf skins, custom swf plugins, custom JS plugins, video CMS - http://goodingsmedia.com

Posts: 359

Registered:
Dec 16, 2008

» Hey Laim, quick qustion.

Posted: Feb 14, 2009

Reply to: Hey Laim, quick qustion., from vinnypolston
In all honesty, if Im on a new VPS without it and its my own I get the company to do it for me Im paying for that kind of service so why not use it) but if I'm on someone elses machine I usually follow a pretty standard procedure.

http://www.nazly.net/post/installing-ffmpeg-and-ffmpeg-php-on-centos-230/

Runs through all the other important tools too such as flvtool2, ffmpeg-php etc.

This is CentOs, never used another flavour of linux myself so not sure on where it differs. Buzz is a LOT better on linux admin than me, he might be able to help.

sbmmm

Posts: 5

Registered:
Feb 6, 2009

» Perfecting h264 conversion with ffmpeg

Posted: Feb 18, 2009

Reply to: Perfecting h264 conversion with ffmpeg, from LiamGooding
Hello Liam,

GoodingsWeb seems to be offline, but check this out to see if you're able and interested http://flowplayer.org/forum/15/15462

BTW, I was following your encoding parameters for x264 in ffmpeg and I am wondering what's the benefit of using the appropriate presets. See great experience/info here http://rob.opendot.cl/index.php/useful-stuff/ffmpeg-x264-encoding-guide/

Liam Gooding
Custom swf skins, custom swf plugins, custom JS plugins, video CMS - http://goodingsmedia.com

Posts: 359

Registered:
Dec 16, 2008

» » Perfecting h264 conversion with ffmpeg

Posted: Feb 18, 2009

Reply to: » Perfecting h264 conversion with ffmpeg, from sbmmm
Hi,

Yeah Im waiting on some DNS updates, moving everything over to a new server.

I saw that project you posted but unfortunately I'm not a flash developer. Seem to have enough on with PHP/MySQL/JS/jQuery/Flowplayer before I start learning any AS3 :)

AFAIK Anssi is the only flash developer around here, and Im not sure how much time he has for custom flash projects. If there are other AS3 devs around, they need to let themselves be known! :)

sbmmm

Posts: 5

Registered:
Feb 6, 2009

» » » Perfecting h264 conversion with ffmpeg

Posted: Feb 18, 2009

Reply to: » » Perfecting h264 conversion with ffmpeg, from LiamGooding
That's all? ;-) Thanks for your response.

I hope the link on x264 to ffmpeg presets was useful. I am trying to figure out what's the best implemenation and why. At the bottom of the link he does provide parameters for 1 and 2 pass using the presets.

tailcast
a community for artists, writers and musicians. connect, create, collaborate!

Posts: 0

Registered:
Feb 17, 2009

perfecting h264 conversion wtih ffmpeg

Posted: Mar 4, 2009

Reply to: » » Perfecting h264 conversion with ffmpeg, from LiamGooding
Hi Liam, saw you splash page on flowplayerhttp://flowplayer.org/tutorials/ffmpeg.html re video conversion & H.264 in which you say "If there is much demand, I can put together a tutorial on how to implement a full conversion system in PHP/MySQL."

I would be very interested in this.

So far I have seen one for Python on Amazon using S3, EC2 and SQS but would be great to see one in php/mysql and quite a few amazon users would be interested too.

Best
Pete

DrMacak

Posts: 1

Registered:
Feb 26, 2009

» Perfecting h264 conversion with ffmpeg

Posted: Feb 26, 2009

Reply to: Perfecting h264 conversion with ffmpeg, from LiamGooding
Hi
Liam please can you send me version of ffmpeg on which you were runing this conversion? This look really great in comparsion with TMPGEnc. Do you run it on Linux? Im sorry for dumb questions but Im new in this kind of encoding. At least send please some links to make me more undestand.

den48248

Posts: 5

Registered:
Jan 20, 2009

» Perfecting h264 conversion with ffmpeg

Posted: Mar 12, 2009

Reply to: Perfecting h264 conversion with ffmpeg, from LiamGooding
Here's my version. Using mencoder, neroaacenc and mp4box.

http://http-2558.simplecdn.net/pwntube/angelsanddemonds.html

That's a 20,123kb file.

Edge
Vizmu Media ------------------- http://vizmu.com/

Posts: 577

Registered:
Nov 29, 2008

» Perfecting h264 conversion with ffmpeg

Posted: Aug 15, 2009

Reply to: Perfecting h264 conversion with ffmpeg, from LiamGooding
Hey folks. I've been afk/moving/extremely busy for a while. Sorry for not popping into this thread sooner ;)

I'll try and keep this short. Though I'll probably fail.

CRF-"Constant rate factor" in x264/libx264 Rocks, it's my fav. Liam hit the nail on the head with the CRF setting. Imo Its the most diverse rate setting available. The CRF option does an amazing job at figuring out where it can shave bits from to keep the file size down. Though admittedly I use 2 pass VBR for 90% of my local conversions. Their both good but CRF is defiantly the easiest way to get consistently good and fast 1 pass results.

B-frames: They improve image quality a ton. But the more bframes you use the harder it is to decode/playback. I've seen some videos use 80% of a core to render. On a laptop or a older machine it can make the video unplayable, appear jumpy or even lock up the browser.
Generally lots of B-Frames = Bad for streaming media and can slightly increase conversion times depending on other settings used. 1-4 is a good place to start.

However something worth noting is that Flowplayer deals Extremely well with higher numbers of bframes and reference frames.
Don't ask me how because I have no idea. But if you assemble a flash player in CS4 or use one of the many flash players available on the web, then toss in an mp4 with 16 bframes plus a pile of reference frames you'll see what I'm talking about.

I'm on a core 2 at 3.6ghz and a general flash player with a mp4@ 16 bframes/6+ reference frames and 1280x720 res will pin my cpu at 50-80%
However somehow flowplayer deals with this better than most flash players. Again I have no idea how it does it, but the cpu usage while being higher than a normal low bframe converted video is substantially lower than a standard run of the mill flash player. eg a 1280x720 video might use 30-50% with loads of bframes/ref frames.

Reference frames: Again loading on a ton of ref frames substantially increases the decoding requirements. Generally I never use more than 5 for any media I work with. But for web/streaming stuff I usually stick with 2 or 3 max and use the mixed refs option. "+mixed_refs add's to encoding time but it's only a slight increase and it's worth it quality wise imo."

It's also been said that using the high profile and levels of 4.1+ increases the decoding requirements. However after loads of testing it only seem to slightly increase the decoding requirements on a standard pc. If your converting for some specific device that's a different story. Currently I use the High profile and a level of 4.1 for everything I put in flowplayer.

-r "fps frames per second". Reducing the fps will reduce file size. But 90% of the time the resulting video is jumpy. I toyed around with setting all my conversions to 20 - 23.97. It failed. Now I don't touch the fps setting unless I have the time to re-convert it. Some source media can handle lower fps, some just can't. Best bet is don't mess with the fps unless you have some specific requirement to do so and the time to mess with re-encoding it over and over to find out just what it can handle.

Anamorphic and or changing the resolution:
As of late I have been downsizing all my conversions and using an Anamorphic res most of the time. Generally you will see a HUGE drop in conversion time with little loss in overall quality. Standard smaller hd res's 960x576 or even 720x480 can look extremely good using decent encoding settings.
Also reducing the res greatly increases your conversion fps/speed. Thus you can use higher settings for motion estimation, subme and trellis while keeping a somewhat sane conversion time.
Plus lower resolutions are easier to decode client side. I know everyone is all about HD everything but honestly there is very little true HD on the web. And what does exist is near impossible to watch/stream on a older machine or low end laptop.
So lower res = much faster encodes and easier to decode/watch.

Lately I've been using 848x352ish resolutions. Its tricky keeping the correct aspect ratio but its a really nice balance between 720x480 and 960x576. I use the fit scaling option in flowplayer. Word of caution flash with h264 can not to the best of my knowledge correctly display pixel aspect ratios for anamorphic resolutions. Keep a eye out for squishing lol. I've tried several players and all fail when using anything other than show all. I use the fit option in flowplayer but have to take care to make sure the resolution is mod 16, or correct for the true aspect ratio. I usually set PAR to 1x1. For local conversions use sx264 or Megui "links below" Both will calculate this correctly for you.

Here's an 16.6mb mp4 at only 720x304 3 ref's and 3 b-frames. The source was 1280x544 @ 105mb. Because it was converted at 720x304 the avg conversion fps was 40+ on a dual core cpu. And since its lower res and only 3 ref's and b-frames it will play pretty well on almost any pc with up-to-date flash.
I'm going for compatibility here not uber insane freaking amazing hd nor is it optimized for small file size.

http://static.bittnews.com/ink-2a.mp4
-Note: this was encoded with sx264 gui "link below" using 2 pass vbr. It would be the exact same size @ 1280x544 because of the settings used.

I'm currently stuck on a monitor with a max of 1440x900. In fullscreen its very watchable for me.

Edge
Vizmu Media ------------------- http://vizmu.com/

Posts: 577

Registered:
Nov 29, 2008

» » Perfecting h264 conversion with ffmpeg

Posted: Aug 15, 2009

Reply to: » Perfecting h264 conversion with ffmpeg, from edge
Had to do it in 2 posts lol...

Here's some settings I've been using. Its just a slightly modded preset file.
coder=1
flags=+loop
cmp=+chroma
partitions=+parti8x8+parti4x4+partp8x8+partb8x8
me=umh > I'm using hex for most of my recent converts. It's much faster and depending on the source and other settings looks fine.
subq=7 > A very important quality setting. But higher numbers greatly increase conversion time.
me_range=22
g=320 > yes 320... it reduces file size and can in some cases give better picture quality. There is no need for loads of keyframes. Unless you have some requirement for insanely accurate scrubbing.
keyint_min=25
sc_threshold=40
i_qfactor=0.71
b_strategy=1
qcomp=0.7 > higher qcomp is better for high motion scenes. But going too high will wreck low motion/stillframes. 0.6 - 0.8 is a good range. It's a very interesting setting. Worth reading up on.
-qmin=10
qmax=51
qdiff=4
bf=2
refs=3 > I often use refs=2
directpred=3
bidir_refine=1
trellis=1 > 0 looks horrible @ lower bitrates, 1 good, 2 great but add's too the conversion time. I always use at least 1.
flags2=+bpyramid+wpred+brdo+mixed_refs+dct8x8+fastpskip
threads=0

-deblockalpha -2 -deblockbeta -1 > These 2 settings are for deblocking eg sharpness. Their very dependent on your source media. I use these settings for 720p non CG/animea movie trailers. For animea you might want to try 0 /0 or +1 /+1. I don't work with a lot of animea but some of the CG media I've worked with has responded well to +1 /0 and +1 /+1. Please experiment with these settings on your own. everyone has their own taste but generally at least -1 /-1 works well for non cg/animea content.

Here's a quick 1 pass cmd line
-i /yourfile.mov -y -f mp4 -vcodec libx264 -crf 28 -threads 0 -flags +loop -cmp +chroma -deblockalpha -1 -deblockbeta -1 -refs 3 -bf 3 -coder 1 -me_method hex -me_range 18 -subq 7 -partitions +parti4x4+parti8x8+partp8x8+partb8x8 -g 320 -keyint_min 25 -level 41 -qmin 10 -qmax 51 -qcomp 0.7 -trellis 1 -sc_threshold 40 -i_qfactor 0.71 -flags2 +mixed_refs+dct8x8+wpred+bpyramid -padcolor 000000 -padtop 0 -padbottom 0 -padleft 0 -padright 0 -acodec libfaac -ab 80kb -ar 48000 -ac 2 outputfile.mp4

I'm not going to explain all the options and what they do. If your wondering what something does just Google it... Or as someone posted in a previous reply go here - http://sites.google.com/site/linuxencoding/x264-ffmpeg-mapping

For local conversions here's some of my fav apps:
sx264 gui -This is currently my fav, still in alpha but works extremely well. I'm also using the latest x264 core 71 r1210 with it.
http://forum.doom9.org/showthread.php?t=143399

MeGUI Great app but requires a lot of user input and setup. Its probably the most indepth encoder I've ever seen.
http://forum.doom9.org/showthread.php?t=96032

WinFF -windows based ffmpeg GUI. Its really good for tweaking your conversion settings before setting up your serverside ffmpeg app.
http://www.videohelp.com/tools/WinFF

I really like ffmpeg but whenever I can I use straight x264. Mencoder also rocks but since this is a ffmpeg thread I won't expand on it.

If you wanna see a pretty sweet encode I would check this out - http://www.flashvideofactory.com/test/DEMO720_Heima_H264_500K.html
That's at 500k lol. He's got it down from 3:53min/sec @ 139mb to 15.4mb. "FLV should just give up and die" I'm working on one now but thus far have only hit 17.4mb.
Here's my attempt http://static.bittnews.com/heima_720p.mp4

Ok time to order a pizza...

gmccomb

Posts: 746

Registered:
Apr 9, 2009

» » » Perfecting h264 conversion with ffmpeg

Posted: Aug 16, 2009

Reply to: » » Perfecting h264 conversion with ffmpeg, from edge
>> "FLV should just give up and die"

The reason it doesn't is that none of the applications you mention are "legitimate" for producing H.264 videos. H.264 is covered by several legal patents. (And no, I'm not interested in arguing if software patents are valid, any more than if software licenses are valid. There have been many, many more legal cases upholding software patents than there has been for software licences.)

The world of properly licensed H.264 software is pretty small.

That said, you may be aware that Google recently made a bid to purchase On2, and there's little reason to suspect the sale won't go through. Speculation is on whether Google will make the On2 codecs open source, allowing these and other programs to legitimately produce not only FLVs (which is On2's as well), but media as good as or better than H.264.

Why they would want to do this centers around YouTube and associated businesses, as well as a "Bing killer," and the fact that Chrome beta is reported to use FFmpeg libraries for H.264 decoding. (This is so they can support H.264 in HTML5.) Google has the money to buy any number of licenses from MPEG LA, which they may do, but I see them also pushing VP7 and VP8 codecs, especially as both of them can drastically reduce storage and bandwidth requirements for YouTube (and their Bing killer), while keeping quality very high.

We'll have to see how this plays out.

Edge
Vizmu Media ------------------- http://vizmu.com/

Posts: 577

Registered:
Nov 29, 2008

» » » » Perfecting h264 conversion with ffmpeg

Posted: Aug 16, 2009

Reply to: » » » Perfecting h264 conversion with ffmpeg, from gmccomb
When I said flv should give up and die I was referring to the only version freely available. eg h.263. You and I both know its It's horrible.

Vp6 is impressive I've used it and recommended it for a long time. The upcoming vp8 looks interesting as well, but thus far the only real info on it is coming from adobe and its mostly marketing bs. - http://flix.on2.com/samples/vp8x264_720p.zip

I'm hoping for the best with both Vp8 and the On2 buyout. The possibility of google open sourcing some of the Vp lineup is great news but only time will tell. Currently none of the On2 family can be used without licensing. It's too bad really, Vp6 is a very impressive codec especially considering it's age.

You said
The reason it doesn't is that none of the applications you mention are "legitimate" for producing H.264 videos.
Please explain, this is a rather broad statement. Are you saying using -f mp4 in the ffmpeg cmd line is illegal?
Are you basing your statement off the title of this thread? I didn't make the title, I'm just replying to it with the intent of giving people freely available higher quality encoding options for the media they want to put in flowplayer.

When flash 9 first came out I can understand sticking with flv for compatibility reasons. But currently flash player 9 saturation is around 98% -http://www.adobe.com/products/player_census/flashplayer/version_penetration.html
And a correctly encoded mp4 can have pretty low decoding requirements.

On the HTML5 note. I'm looking forward to it. Though I'm a little scared of what might actually be supported. Theora and Vorbis are not exactly cream of the crop options lol. I hope h.264 will find it's way in but it's to early to tell. Or google open sourcing vp6 and adding it to HTML5 would be amazing. Though I doubt it will ever happen.

gmccomb

Posts: 746

Registered:
Apr 9, 2009

» » » » » Perfecting h264 conversion with ffmpeg

Posted: Aug 16, 2009

Reply to: » » » » Perfecting h264 conversion with ffmpeg, from edge
>Please explain, this is a rather broad statement.
>Are you saying using -f mp4 in the ffmpeg cmd
>line is illegal?

I mean that any application that renders H.264 without a license to MPEG LA is almost certainly infringing on patents. If anyone has figured out a way to create an H.264 encoding that doesn't infringe on the patents behind H.264 (and MPEG4 for that matter), they're being quiet about it.

Google uses FFmpeg libraries in Chrome and they also licensed H.264 from the licensing authority. There was a big stink about this (Slashdot and others) a few months ago. Some people claimed that was against GPL, but it's not.

VP3 (FLV) is not all that bad depending on the application. Millions of people enjoy those videos on YouTube, not to mention the vast majority of user-submitted tubes (adult, mainstream, and otherwise), but of course it depends on the source and the expectations. There are still millions of Flash users with versions under 9r115, so having only H.264 media shuts them out. As "bad" as FLV encoding may be, it's really the only worldwide standard guaranteed to hit 97+ % of users. (You can't go by just v9 penetration; r115 came later, and the penetration for it is 5-10% less, according to some tracking sources.)

Edge
Vizmu Media ------------------- http://vizmu.com/

Posts: 577

Registered:
Nov 29, 2008

» » » » » » Perfecting h264 conversion with ffmpeg

Posted: Aug 16, 2009

Reply to: » » » » » Perfecting h264 conversion with ffmpeg, from gmccomb
Regarding the x264 patents discussion, I think we've both had this conversation before. It ends up being very long and very very boring. nuff said.

Imo Vp3 flv is horrible. If I wanted to use it on any of my sites I would just upload my videos to youtube. Vp6 I can understand using, at least it looks ok. But considering this is a ffmpeg/mp4 thread I'm going to assume that anyone reading it will be interested in mp4's not flv's. I'm not here to argue with you about codecs or how many millions of people visit youtube every day. Though something worth noting is youtube now has a "HD" option that streams mp4's.

Media Tech is evolving and even though I spend an absurd amount of time making sure the sites I work on are compatible with older browsers there's a line that has to be drawn. And considering I never have to work with corporate sites "thank god" I get to draw the line where I see fit wewt!
-My take on flash, It's a simple upgrade, if someone doesn't wanna spend 2 minutes to upgrade their ancient flash player its not my problem. Yep that's right I'm a rebel lol... Imo flowplayer is sexy as hell and deserves something better than vp3 flv inside it. Its like buying a ferrari and droping a yugo engine in it.

x264 is better quality and compression at the same or even lower bitrates than any flv available. Including vp6. And if their encoded correctly the decoding requirements -other than the flash 9 requirement can be very low.

I don't disagree that if your building a site that need's to work across every platform known to man flv is the way to go. Just that if you have the option why not use mp4.

gmccomb

Posts: 746

Registered:
Apr 9, 2009

» » » » » » » Perfecting h264 conversion with ffmpeg

Posted: Aug 16, 2009

Reply to: » » » » » » Perfecting h264 conversion with ffmpeg, from edge
>Though something worth noting is youtube now has
>a "HD" option that streams mp4's.

Correct. If you have the storage capability, and a cooperative player, you should provide both if you want the best of both worlds - the option for higher quality and maximum reach.

I'm just noting that the VAST majority of conversion programs you see that support H.264 do so by skirting some intellectual property rights, and taking the associated risks should MPEG LA decide to bring suit. That's why many of the converter programs you see for sale (almost all use FFmpeg as their engine) are from countries far outside the US - China, for one. Not many companies within the legal reach of the US is willing to take the risk.

Personally, in my view, no matter what Google does to open source On2 codecs, the days of H.264 are numbered anyway. Adobe is one of On2's (now Google's) biggest customers, and with YouTube Google can push any codec they want as the new standard.

Because Google has a vested interest ($$$$ saved) in pushing a new codec that maintains quality while reducing bandwidth/storage, there is every reason they'll look to ways to quicken the adoption of the codec. They may well do this by open sourcing it. Otherwise, frankly, there's hardly a reason to have *bought* On2.

I foresee by year's end we'll be wanting to use VP7/8 for the highest quality, because Google will somehow find a way to release/license these. And if my guess is right, we'll have a lot more quality apps to choose from, including other open source projects that openly (and legally) leverage the codecs.

Of course, none of this detracts from the original purpose of the thread - using FFmpeg to get better H.264 encodes!

Edge
Vizmu Media ------------------- http://vizmu.com/

Posts: 577

Registered:
Nov 29, 2008

» » » » » » » » Perfecting h264 conversion with ffmpeg

Posted: Aug 17, 2009

Reply to: » » » » » » » Perfecting h264 conversion with ffmpeg, from gmccomb
You seriously think Vp7 is better than the h264 codec encoded via x264?

And this wow
-I foresee by year's end we'll be wanting to use VP7/8 for the highest quality,
mmmm Vp7 is like 5 years old now... And I don't think its been updated in that time.

If you want to find a GOOD 1280x720 100mb'ish source we can both download, then tell me what bitrate or filesize you want to shoot for. I'll use x264 you use any FLV codec want, be it Vp6/7 vp3 take your pick. Then we'll both post our results.

And btw all the converters I use are 100% free and completely open source. Only 1 of the above programs I mentioned uses ffmpeg strictly. The other 2 access x264 directly.

gmccomb

Posts: 746

Registered:
Apr 9, 2009

» » » » » » » » » Perfecting h264 conversion with ffmpeg

Posted: Aug 17, 2009

Reply to: » » » » » » » » Perfecting h264 conversion with ffmpeg, from edge
What does the age of the codec have to do with it? You are aware H.264 is several years older?

The reason for H.264's demise has to do with licensing fees. I thought that was understood in my discussion over Google buying a competitor's product. Google has the weight to elect any codec it wants as a defacto standard for Web videos - YouTube is not an insignificant market leader - and at least one of the On2 codecs WILL be so elected. That's a given. Google isn't buying On2 because it has extra cash floating around.

I understand the H.264 converters you are using are "100% free." That doesn't mean they are free of patent encumbrance. Because of this, no mainstream software company develops with these tools unless they also purchase a license from MPEG LA. Virtually NONE do that.

What I am saying is that if Google starts pushing one or more On2 codecs for Web videos, people won't need to license from MPEG LA any more, and they'll have a choice. With Google preferring On2 codecs for YouTube and its search results, you can see what that means for H.264 as a leading format for Flash-based players. Bye bye.

(For that matter I assume you're aware Adobe must pay royalties to MPEG LA for its Flash player downloads. Must be a *killer* check Adobe has to sign every quarter. Seeing how On2 and Adobe have a long relationship, and Adobe will want to continue that relationship with Google, it's even possible that Adobe will strike up a better deal and Flash will eventually DROP support for H.264. Hey, stranger things have happened!)

The ONLY way it would stay relevant is if MPEG LA drastically reduces the licensing fees. Since they are a patent enforcement and royalty clearinghouse for numerous patent holders, that's anything but likely. Too much committee mentality involved.

H.264 will still be used in Quicktime and other desktop players, but that's beside the point.

As for the lineup, I see VP3 being the old standby, but phased out over time. VP6 or VP7 will be a middle-ground - much better than VP3 but mainly used when higher compression is sought after. For HD they'll rely on VP8. It is THIS codec I believe Google is paying $100+ million for. The others are just side dressing.

vesolovski

Posts: 1

Registered:
May 8, 2010

Best video oncoding I"ve seen so far

Posted: May 8, 2010

Reply to: » » Perfecting h264 conversion with ffmpeg, from edge
Can someone tell how this was achieved?
http://www.flashvideofactory.com/test/DEMO720_Heima_H264_500K.html
Was it only ffmpeg and libx264 with (some) appropriate params or something else?

I would like to encode my camera MTS movies with such a quality like above. Can anyone help me with it? Or at least near to this quality?

Edge
Vizmu Media ------------------- http://vizmu.com/

Posts: 577

Registered:
Nov 29, 2008

» Perfecting h264 conversion with ffmpeg

Posted: Aug 17, 2009

Reply to: Perfecting h264 conversion with ffmpeg, from LiamGooding
Age, The difference is the actual encoders "not guis" for Vp3-7 haven't been updated in a very very long time. While x264 has.

Please stop derailing this thread. If you feel the need to discuss Gui's, licensing fees, patents and other such thing Please start a new thread. I am no longer going to reply to anything other than information regarding the optimization of ffmpeg cmd line encoding.

gmccomb

Posts: 746

Registered:
Apr 9, 2009

» » Perfecting h264 conversion with ffmpeg

Posted: Aug 17, 2009

Reply to: » Perfecting h264 conversion with ffmpeg, from edge
Sorry, I thought it was a lively debate, and relevant given FFmpeg's position as an unlicensed encoder, and why the licensing terms of MPEG LA prevent better and easier to use encoding applications. If it weren't for H.264 licensing restrictions the average person wouldn't have to deal with these obtuse and arcane manual settings. (We geeks love 'em, though!)

FWIW, even FFmpeg's implementation of VP3 encoding has evolved and improved over time. It's constrained by the specs, just as H.264 is, but it's a false assumption these implementations haven't changed. We're not aware of the internal bug fixes or improvements in the VP3 decoder in Flash, for example. Doesn't mean they don't occur.

Anyway, I'll take this over to my blog, because I think it's important for people to know WHY they have to do all this stuff. You're right, though, this should have been in a new thread. My apologies.

zandzpider

Posts: 4

Registered:
May 4, 2009

Grainy end result

Posted: Jan 15, 2010

Reply to: Perfecting h264 conversion with ffmpeg, from LiamGooding
Helloooo there, i have been encoding for some while now and im kiinda annoyed over my files being Grainy / dotted......

I'm usually coding from h.264 720p files

Here's my line

ffmpeg -i "input.mp4" -y -f mp4 -s 848x480 -vcodec libx264 -vpre zz_hd -crf 20 -level 41 -acodec libfaac -ab 96k -ar 48000 -ac 2 -threads 0 -deblockalpha -2 -deblockbeta -1 output.mp4

my preset file:

coder=1
flags=+loop
cmp=+chroma
partitions=+parti8x8+parti4x4+partp8x8+partb8x8
me_method=hex
subq=7
me_range=22
g=320
keyint_min=25
sc_threshold=40
i_qfactor=0.71
b_strategy=1
qcomp=0.7
qmin=10
qmax=51
qdiff=4
bf=2
refs=3
directpred=3
trellis=1
flags2=+wpred+mixed_refs+dct8x8+fastpskip

Edge
Vizmu Media ------------------- http://vizmu.com/

Posts: 577

Registered:
Nov 29, 2008

» Grainy end result

Posted: Jan 15, 2010

Reply to: Grainy end result, from zandzpider
If the source media was grainy getting rid of that grain is hard.

You could try changing deblocking to 0 or 1

-deblockalpha 0 -deblockbeta 0
or
-deblockalpha 1 -deblockbeta 1

sgh

Posts: 1

Registered:
Mar 1, 2010

Bit Rate Compressiion Quality

Posted: Mar 1, 2010

Reply to: » Grainy end result, from edge
All the above is really good advise but I have a question on the quality of compression.... If the bit rate of a video is lets say half of another file... does this mean the resolution of a file with a higher bit rate is better?

We are finding that the quality of our videos is much less when the files we are using have a lower bit rate then others... which is strange because the videos were all shot on the same day, with the same camera etc....

Also, is it normal that the bit rate is higher when you are zoomed in on an individual? and the bit rate less when you have a full body shot?

Thanks,

Simeon

Your City Office Limited
Providers of Virtual Office services and Office Space services

JayAdams
[color="#FF0000"][size="6"][b]Living Large In Austin Texas..............[/b][/size][/color]

Posts: 1

Registered:
8 days ago

» » Grainy end result

Posted: 8 days ago

Reply to: » Grainy end result, from edge
I agree Simeon. Just what I was looking for.

cwang

Posts: 39

Registered:
Jun 30, 2009

» Perfecting h264 conversion with ffmpeg

Posted: Mar 17, 2010

Reply to: Perfecting h264 conversion with ffmpeg, from LiamGooding
Hi there,
I tried to use the formular

"ffmpeg -y -i input.mov -acodec libfaac -ar 44100 -ab 96k -vcodec libx264 -level 41 -crf 20 -bufsize 20000k -maxrate 25000k -g 250 -r 20 -s 1280x544 -coder 1 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +brdo+dct8x8+bpyramid -me umh -subq 7 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq 'blurCplx^(1-qComp)' -bf 16 -b_strategy 1 -bidir_refine 1 -refs 6 -deblockalpha 0 -deblockbeta 0 output.mp4"

to convert my mov file to mp4 file but the mp4 file couldn't be played on iPhone.

Is this the right formular to convert to H264 in mp4 container? Thanks a lot!

cancan0312

Posts: 2

Registered:
Mar 25, 2010

» » Perfecting h264 conversion with ffmpeg

Posted: Mar 25, 2010

Reply to: » Perfecting h264 conversion with ffmpeg, from cwang
Smart FLV to AVI H.264 Converter is specially designed to FLV to AVI h.264 with excellent output sound and image quality. Before converting FLV to AVI H.264, FLV to AVI h.264 Converter also can convert FLV from YouTube and Google Video encoded with H.263 and Divx, Xvid codec.
To hold FLV to AVI h.264 converter let you crop and trim video, customize profile, merge files into one at will. Why not convert FLV to AVI h.264 with your own method? Try it! ( http://www.convertflv.biz/convert-flv-to-avi-h264.html )

undercash
http://www.pokercast.tv/

Posts: 41

Registered:
Feb 26, 2009

» » » Perfecting h264 conversion with ffmpeg

Posted: May 19, 2010

Reply to: » » Perfecting h264 conversion with ffmpeg, from cancan0312
sometime ago , i have been writing a little blog, mostly for myself but maybe it could help others
http://www.pokercast.tv/blog/setting-up-ffmpeg

jeffreymarshall

Posts: 2

Registered:
3 weeks ago

Little Mermaid Costume and Child Mermaid Costume

Posted: 2 weeks ago

Reply to: » » » Perfecting h264 conversion with ffmpeg, from undercash
you are so lucky to have met Robert Swain. Also thnx for the tutorial!

co1986
[url=http://www.aimersoft.com/dvd-ripper.html]dvd ripper[/url] | [url=http://www.aimersoft.com/mac-dvd-to-ipad-converter.html]DVD to iPad ma

Posts: 2

Registered:
4 weeks ago

» Perfecting h264 conversion with ffmpeg

Posted: yesterday 10:21

Reply to: Perfecting h264 conversion with ffmpeg, from LiamGooding
Thank you .