Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 12th May 2010, 22:54   #1  |  Link
shon3i
BluRay Maniac
 
shon3i's Avatar
 
Join Date: Dec 2005
Posts: 2,419
Encoding Video for Blu-Ray using H264/AVC

Here is part of specification that apply when encoding with H264/AVC codec, all parameters showed here are not guessing, it's based on original Blu-Ray specification, which are not available in public.

NOTE: This is discussion about settings that are for creating 100% compliant Blu-Ray structures, not for encoding from Blu-Ray sources to matroska/mp4 or other media, if you encode to those skip this nightmare

1. GENERAL CONSTRAINTS FOR MPEG-4 H264/AVC

1.1 ALLOWED RESOLUTIONS/FRAMERATES




1.2 ALLOWED LEVELS, PROFILES, REFERENCE FRAMES, VBV

1.2.1 Primary Video Rules



1.2.2 Secondary Video Rules

NOTE: In case of 1080 and 720 resolutions same rules apply as Primary video, while 576 and 480 resolutions have stricter parameters showed in table:




1.3 SIMPLE ASPECT RATIO




1.4 COLOR CHARACTERISTICS




1.5 OTHER REQUIRED PARAMETERS

8-bit (4:2:0) Colorspace is only allowed
Main and High profiles are allowed
Maximum 3 B-Frames is allowed
NAL-HRD Type 2 capable encoder is needed


2. ENCODE BLU-RAY VIDEO USING x264

2.1 MANDATORY PARAMETERS

Every encode for Blu-Ray must contain this parameters, without it will not meet Blu-Ray specification.

Quote:
--bluray-compat
Enforce x264 to create BD compliant stream, that will reduce x264 settings to BD compatible: bframe<=3, ref<=4 for 1080, ref<=6 for 720/576/480, bpyramid<=strict, weightp<=1, aud=1, nalhrd=vbr

Quote:
--level
Blu-Ray level, see the table for the appropriate level

Quote:
--keyint
Maximum number displayed pictures in GOP. If you set Maximum bitrate less or equal to 15mbps you can use 2 second long GOP otherwise, 1 second GOP must be used.

Quote:
--vbv-maxrate
Maximum allowed bitrate. Depend of destination media, for normal BD Media, maximum settings is allowed (40000), while for DVD Media (eg BD-5 or BD-9) there is no maximum per Blu-Ray specification, but is strongly recommended that use less or equal to 15000, since DVD reading is slower.

Quote:
--vbv-bufsize
Maximum allowed buffer, buffer size is in relation with maxrate. Since STD Buffer Delay for Blu-Ray allows maximum 1 second. This mean to divide buffer with maxrate and see if result is less or equal to 1, if not, buffer is need to be reduced to lower value that meet 1 second STD. For BD media, maximum settings is allowed (30000), but if not meet STD Buffer Delay, then need to be reduced to lower value. For DVD media there is no maximum in Blu-Ray specification, but is strongly recommended that use less or equal to 15000, and again need to meet STD delay of 1 second.

For example:

--vbv-bufsize 30000 --vbv-maxrate 40000 is allowed
--vbv-bufsize 30000 --vbv-maxrate 30000 is allowed
--vbv-bufsize 15000 --vbv-maxrate 30000 is allowed
--vbv-bufsize 30000 --vbv-maxrate 15000 is not allowed (delay is greater than 1 second)

Basicly vbv-bufsize should newer been greater than vbv-maxrate, that is whole point.

Quote:
--sar
Simple Aspect Ratio, must present in stream, see the table for the appropriate settings

Quote:
--slices
Only when encoding with --level 4.1, slices need to be set to 4 or greater, otherwise you can skip this setting or set it to 1.

Quote:
-o xxx.264
Output file must be in raw 264 elementary stream (extension .264) otherwise settings will not applied correctly. DO NOT USE MKV OR MP4.

2.2 OPTIONAL PARAMETERS

This parameters is optional and not need for every encode.

Quote:
--colorprim
--transfer
--colormatrix
Specify color primaries, transfer characteristics and color matrix. This is optional, and not need to be present, see the table for the appropriate settings.

Quote:
--pic-struct
Need only when fake interlaced is used, and it's default on with interlaced and pulldown. It's fine with progressive aslo, and some BD verification tools request to be present in stream.

Quote:
--open-gop
Use non-IDR pictures instead classic IDR picture, this will tend to resolve pulsing picture problem that is usually came with short GOP's.

Quote:
--fake-interlaced
Since 25p or 30p video is not allowed for Primary Video, encoding progressive video that meet Blu-Ray specification is only possible with this option. If use this option you aslo need to specify --pic-struct

Quote:
--qpfile
Need for chapters.

2.2 EXAMPLES

Progressive

1080p
720p
576p
480p

Interlaced

1080i
576i
480i

Last edited by shon3i; 21st April 2011 at 13:01.
shon3i is offline   Reply With Quote
Old 12th May 2010, 23:19   #2  |  Link
b66pak
Registered User
 
b66pak's Avatar
 
Join Date: Aug 2008
Location: The Land Of Dracula (Romania - EU)
Posts: 934
thanks a lot...
_
__________________
if you ask a question and somebody give you the correct answer don't forget to leave a "thank you" note...
Visit The Land Of Dracula (Romania - EU)!
b66pak is offline   Reply With Quote
Old 12th May 2010, 23:46   #3  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,901
Please advise when it is complete so we can make it a stickie. Thank you.
Guest is offline   Reply With Quote
Old 13th May 2010, 00:31   #4  |  Link
AnonCrow
Registered User
 
Join Date: Aug 2009
Location: 61.45° , 23.86°
Posts: 120
Little nitpick : since you're using images and you're hosting them yourself, might want to optimize them for smaller size - pics 1 and 2 went from 50 KiB and 62 KiB to 13 and 16 KiB, respectively , just by decreasing bit-depth and using maximum PNG compression. This without even resorting to PNGOUT or Pngcrush.
AnonCrow is offline   Reply With Quote
Old 13th May 2010, 02:24   #5  |  Link
ajp_anton
Registered User
 
ajp_anton's Avatar
 
Join Date: Aug 2006
Location: Stockholm/Helsinki
Posts: 805
What does "Max bitrate BD, DVD and with or without 2 sec GOP" mean?

And to do 25fps progressive, you have to either double the framerate to 50fps, or encode it as 25fps interlaced?

Last edited by ajp_anton; 13th May 2010 at 02:27.
ajp_anton is offline   Reply With Quote
Old 13th May 2010, 03:11   #6  |  Link
creamyhorror
Registered User
 
Join Date: Mar 2008
Posts: 118
Thanks for doing this. I think a specific x264 section with recommended commandlines and workflow notes would be essential.
creamyhorror is offline   Reply With Quote
Old 13th May 2010, 07:30   #7  |  Link
shon3i
BluRay Maniac
 
shon3i's Avatar
 
Join Date: Dec 2005
Posts: 2,419
@AnonCrow, thanks for tip. i probably will upload later here as attach, but i will optimize as much as possible.

Quote:
Originally Posted by ajp_anton
What does "Max bitrate BD, DVD and with or without 2 sec GOP" mean?
It mean, if you target is BD media and if you set VBV maxrate <=15000 then you can use --keyint from Max Frames in 2 sec. GOP. Or if you target media is DVD (BD5/BD9) you aslo may not use higher maxrate/buffer than 15000, coz DVD spin speed is lower, that is some error free maximum for DVD. Still if you set maxrate to 15000 you can choose what you want to use 1 second or 2 second GOP, for BD or DVD.

Quote:
Originally Posted by ajp_anton
And to do 25fps progressive, you have to either double the framerate to 50fps, or encode it as 25fps interlaced?
You need encode it as interlaced, or convert to 720p50.

Quote:
Originally Posted by creamyhorror
Thanks for doing this. I think a specific x264 section with recommended commandlines and workflow notes would be essential.
To be continued with explanation, examples, and few more tables.
shon3i is offline   Reply With Quote
Old 13th May 2010, 08:00   #8  |  Link
Snowknight26
Registered User
 
Join Date: Aug 2007
Posts: 1,429
Quote:
Originally Posted by shon3i View Post
You need encode it as interlaced, or convert to 720p50.
Doesn't actually have to be interlaced, can just be flagged as interlaced yet contain progressive frames.
Snowknight26 is offline   Reply With Quote
Old 13th May 2010, 08:23   #9  |  Link
kieranrk
Registered User
 
Join Date: Jun 2009
Location: London, United Kingdom
Posts: 707
Quote:
Originally Posted by Snowknight26 View Post
Doesn't actually have to be interlaced, can just be flagged as interlaced yet contain progressive frames.
If you had an encoder that can do adaptive PAFF/MBAFF then yes.

Or you could force it manually since the spec says frame_mbs_only shall be 0.

Last edited by kieranrk; 13th May 2010 at 13:12.
kieranrk is offline   Reply With Quote
Old 13th May 2010, 10:03   #10  |  Link
bob0r
Pain and suffering
 
bob0r's Avatar
 
Join Date: Jul 2002
Posts: 1,337
May i advice, that instead of an image, maybe make a .html page or something silimar.
So in case of link down, or user absense, people can easy update or repost when needed.
bob0r is offline   Reply With Quote
Old 13th May 2010, 10:06   #11  |  Link
kypec
User of free A/V tools
 
kypec's Avatar
 
Join Date: Jul 2006
Location: SK
Posts: 826
Quote:
Originally Posted by bob0r View Post
May i advice, that instead of an image, maybe make a .html page or something silimar.
So in case of link down, or user absense, people can easy update or repost when needed.
+++ Images are nice but hardly maintainable nor usable (copy/paste) and so on.
kypec is offline   Reply With Quote
Old 13th May 2010, 11:26   #12  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: Poland
Posts: 2,843
I'm preaty sure that 25p is allowed for secondary video stream.


Andrew
kolak is offline   Reply With Quote
Old 13th May 2010, 11:31   #13  |  Link
mp3dom
Registered User
 
Join Date: Jul 2003
Location: Italy
Posts: 1,135
Infact it's mentioned in the tab
I would like to add that even if it's allowed to have a fullHD secondary video, it's better to prefer SD secondary video because not all the standalone players are able to handle 2 fullhd stream at once.
mp3dom is offline   Reply With Quote
Old 13th May 2010, 12:06   #14  |  Link
shh
Registered User
 
Join Date: Dec 2001
Posts: 96
Quote:
Originally Posted by Snowknight26 View Post
Doesn't actually have to be interlaced, can just be flagged as interlaced yet contain progressive frames.
Quote:
Originally Posted by kieranrk View Post
If you had an encoder that can do "full" PAFF/MBAFF then yes.
Is x264 able to do this already? (= flagging the stream interlaced, but just coding progressive frames)
I've got many progressive PAL-sources (most satellite-streams are p anyway), and wouldn't like to encode that "interlaced".
__________________
shh

Last edited by shh; 13th May 2010 at 12:13.
shh is offline   Reply With Quote
Old 13th May 2010, 13:07   #15  |  Link
kieranrk
Registered User
 
Join Date: Jun 2009
Location: London, United Kingdom
Posts: 707
Quote:
Originally Posted by shh View Post
Is x264 able to do this already? (= flagging the stream interlaced, but just coding progressive frames)
I've got many progressive PAL-sources (most satellite-streams are p anyway), and wouldn't like to encode that "interlaced".
You could modify x264 to write frame_mbs_only flag as zero. You'd have to write pic_struct too but the spec isn't clear whether it wants you to signal the frame as two fields or as one frame.
kieranrk is offline   Reply With Quote
Old 13th May 2010, 13:31   #16  |  Link
ajp_anton
Registered User
 
ajp_anton's Avatar
 
Join Date: Aug 2006
Location: Stockholm/Helsinki
Posts: 805
Quote:
Originally Posted by shon3i View Post
It mean, if you target is BD media and if you set VBV maxrate <=15000 then you can use --keyint from Max Frames in 2 sec. GOP. Or if you target media is DVD (BD5/BD9) you aslo may not use higher maxrate/buffer than 15000, coz DVD spin speed is lower, that is some error free maximum for DVD. Still if you set maxrate to 15000 you can choose what you want to use 1 second or 2 second GOP, for BD or DVD.
But the "with or without 2 sec GOP" means it is 15000 *always*, whether or not you use 2 sec GOP, and this is false, because if you use 1 sec GOP with BD, it's 40000 and not 15000.
Sure 15000 can be used, but it's not max, which is what this tries to tell you.

IMO it should say something like

Max bitrate
2 sec GOP BD
DVD
ajp_anton is offline   Reply With Quote
Old 13th May 2010, 14:55   #17  |  Link
rack04
Registered User
 
Join Date: Mar 2006
Posts: 1,538
Thanks for taking the time to put this together. Here are my comments:

1.) "RESOLITIONS" should be spelled "RESOLUTIONS"
2.) Add a section that includes mandatory items like --aud, --bframes 3, --nal-hrd vbr, etc. I know you mention bframes 3 in the title section of Section 2 but that could easily be overlooked by people who concentrate on big pretty pictures.
rack04 is offline   Reply With Quote
Old 13th May 2010, 15:00   #18  |  Link
Sharc
Registered User
 
Join Date: May 2006
Posts: 3,997
Thanks a lot shon3i for your initiative

Quote:
Originally Posted by creamyhorror View Post
Thanks for doing this. I think a specific x264 section with recommended commandlines and workflow notes would be essential.
+++ Would indeed be very helpful.
Could it eventually be included in x264 as 'device presets' or similar?
Sharc is offline   Reply With Quote
Old 13th May 2010, 15:24   #19  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,340
Nice work sho3ni!

Quote:
Originally Posted by ajp_anton View Post
And to do 25fps progressive, you have to either double the framerate to 50fps, or encode it as 25fps interlaced?
And another option would be to do the slowdown to 24p or 23.976p if you can tolerate the audio shift
poisondeathray is offline   Reply With Quote
Old 13th May 2010, 15:52   #20  |  Link
shon3i
BluRay Maniac
 
shon3i's Avatar
 
Join Date: Dec 2005
Posts: 2,419
Quote:
Originally Posted by ajp_anton View Post
But the "with or without 2 sec GOP" means it is 15000 *always*, whether or not you use 2 sec GOP, and this is false, because if you use 1 sec GOP with BD, it's 40000 and not 15000.
Sure 15000 can be used, but it's not max, which is what this tries to tell you.

IMO it should say something like

Max bitrate
2 sec GOP BD
DVD
Not exactly because situation looks like this:

1. 15000 is max for DVD
2. 15000 is max i you want use 2 sec GOP besides you use DVD or BD
3. you can still use 1 sec gop.

so if you don't use 2 sec GOP that mean you will use 1 second instead. I will somehow fix this.

@all, be patient

Last edited by shon3i; 13th May 2010 at 15:56.
shon3i is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:11.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.