Encoding with X264 for Blu-ray compatibility

vbimport

#1

Kerry56 could you give me a hand one last time? I finally produced my video after hours of encoding and deinterlacing with QTGMC. Looking quite good. So now I have my video file and audio is in a separate WAV.

It seems like BD-Rebuilder won’t mux by itself as it doesn’t accept WAV as input (maybe I’m missing something though), so what is the best way to mux the file first? I only know of mkvmerger/mkvtoolnix and tsMuxer. How should I mux with either of those, which setting(s), etc?

As mentioned before, the video was produced using CLI x264.exe. The audio was extracted from the source, and then created using the avisynth soundout() plugin so that it could be trimmed at the same frames as the video. But maybe there is a better way to do this, not sure if it is compliant. Guess it can be easily reencoded though.

thanks!

here are my file informations:

General
Complete name : […]
Format : Matroska
Format version : Version 2
File size : 18.1 GiB
Duration : 1h 16mn
Overall bit rate : 34.0 Mbps
Writing application : x264 r2638 7599210
Writing library : Haali Matroska Writer b0

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4.1
Format settings, CABAC : Yes
Format settings, ReFrames : 4 frames
Codec ID : V_MPEG4/ISO/AVC
Duration : 1h 16mn
Bit rate : 34.0 Mbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 25.000 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.656
Stream size : 17.8 GiB (98%)
Writing library : x264 core 148 r2638 7599210
Encoding settings : cabac=1 / ref=4 / deblock=1:0:0 / analyse=0x3:0x113 / me=umh / subme=8 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=12 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=240 / keyint_min=24 / scenecut=40 / intra_refresh=0 / rc_lookahead=50 / rc=2pass / mbtree=1 / bitrate=34000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / ip_ratio=1.40 / aq=1:1.00
Language : English
Default : Yes
Forced : No

General
Complete name : […]
Format : Wave
File size : 1.23 GiB
Duration : 1h 16mn
Overall bit rate mode : Constant
Overall bit rate : 2 304 Kbps

Audio
Format : PCM
Format settings, Endianness : Little
Format settings, Sign : Signed
Codec ID : 1
Duration : 1h 16mn
Bit rate mode : Constant
Bit rate : 2 304 Kbps
Channel(s) : 2 channels
Sampling rate : 48.0 KHz
Bit depth : 24 bits
Stream size : 1.23 GiB (100%)


#2

TsMuxer
Add the files and output to folder
Input to BD_RB

MKVToolNix
Mux the files
Import into BD_RB

No special settings in either for now

Please test along the way (synch,etc)


#3

^ Do what gonca advised. I can see some problems in your settings for the video. It isn’t Blu-ray compliant right now. When using 1080p and 25fps, you’d need to use a fake interlaced flag. And there are some other settings in there that aren’t quite right.

This site shows Blu-ray compliant X264 settings for various resolutions.


#4

@Kerry56
The size of his file is only 18.1 GB
He might have to use a custom size (to maintain his present bitrate) and force BR_RB to encode it to make it compliant.


#5

thank you guys. maybe I should just reencode to x264 using those presets from the webpage you mentioned Kerry…

1080p25

x264 --bitrate XXXXX --preset veryslow --tune film --bluray-compat --vbv-maxrate 40000 --vbv-bufsize 30000 --level 4.1 --keyint 25 --open-gop --slices 4 --fake-interlaced --colorprim “bt709” --transfer “bt709” --colormatrix “bt709” --sar 1:1 --pass 1 -o out.264 input.file

x264 --bitrate XXXXX --preset veryslow --tune film --bluray-compat --vbv-maxrate 40000 --vbv-bufsize 30000 --level 4.1 --keyint 25 --open-gop --slices 4 --fake-interlaced --colorprim “bt709” --transfer “bt709” --colormatrix “bt709” --sar 1:1 --pass 2 -o out.264 input.file


#6

Its always best to encode once, instead of having to correct settings in a second encode. If you encode to Blu-ray specs, you can use tsMuxeR to go straight to a Blu-ray format, provided you don’t need any type of menu.

I’m going to move all of these comments into a new thread and take them out of the guide. I’ll leave a redirect.


#7

What did you use to do the original encode?
Does it have a BD compatibility setting?


#8

Sorry for the derail and thanks for moving to a new thread.

Encoding a second time using the proper specs is not a problem, thanks heaps for linking those. I’ll leave it running tonight.

here is how I encoded the first time, just FYI (which, now that I read the x264 bluray page makes no sense indeed):

x264.exe --pass 1 --level 4.1 --stats 1080.stats --bitrate 34000 --preset slow --keyint 240 --min-keyint 24 -o NUL "input.avs"
x264.exe --pass 2 --level 4.1 --stats 1080.stats --bitrate 34000 --preset slow --keyint 240 --min-keyint 24 -o “output.mkv” "input.avs"
my avs script:

SetMemoryMax(2048)
SetMTMode(5, 8)

LWLibavVideoSource (“source.mxf”, stacked = false, format = “yuv422p”)
converttoyv12()
trim(2252,116878)
SetMTMode(2)
QTGMC( Preset=“Slow”, FPSDivisor=2, EdiThreads=1 )

Distributor()

SetMTMode(5)

TextSub(“subs.srt”)
and the source itself:

Format : MXF
Commercial name : XDCAM HD422
Format version : 1.2
Format profile : OP-1a
Format settings : Closed / Complete
File size : 32.7 GiB
Duration : 1h 17mn
Overall bit rate : 60.0 Mbps
Encoded date : 2015-09-30 18:21:52.332
Writing application : Apple Inc. AppleMXFExportFCP 12

Video
ID : 2
Format : MPEG Video
Commercial name : XDCAM HD422
Format version : Version 2
Format profile : 4:2:2@High
Format settings, BVOP : Yes
Format settings, Matrix : Custom
Format settings, GOP : M=3, N=12
Format settings, picture structure : Frame
Format settings, wrapping mode : Frame
Codec ID : 0D01030102046001-0401020201040300
Duration : 1h 17mn
Bit rate : 50.0 Mbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate : 25.000 fps
Standard : Component
Color space : YUV
Chroma subsampling : 4:2:2
Bit depth : 8 bits
Scan type : Interlaced
Scan order : Top Field First
Compression mode : Lossy
Bits/(Pixel*Frame) : 0.965
Stream size : 27.2 GiB (83%)
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709


#9

If your goal is a BD disc why encode to MKV?
If using command line consider using --bluray-compat switch
(please confirm the correct syntax)

keyint 240
Won’t be BD compatible
As Kerry56 said encode once then remux or reauthor to whatever


#10

yes, will encode properly tonight. :slight_smile:

what about audio? should I encode it to something particular (using eac3to or other tool - if yes to which format/settings?) or is this good enough?

General
Complete name : audio.wav
Format : Wave
File size : 1.23 GiB
Duration : 1h 16mn
Overall bit rate mode : Constant
Overall bit rate : 2 304 Kbps

Audio
Format : PCM
Format settings, Endianness : Little
Format settings, Sign : Signed
Codec ID : 1
Duration : 1h 16mn
Bit rate mode : Constant
Bit rate : 2 304 Kbps
Channel(s) : 2 channels
Sampling rate : 48.0 KHz
Bit depth : 24 bits
Stream size : 1.23 GiB (100%)


#11

Its fairly big, but PCM audio should be acceptable in Blu-ray. Technically there is a difference between LPCM (found in DVD’s and Blu-ray) and PCM, but I’m not sure MediaInfo can pick up on that difference, and players don’t seem to mind.

And you can always re-encode it to regular AC3. That would work in Blu-ray up to 640kbps. Top bitrate for DVD’s would be 448kbps.


#12

alright, encoded the movie properly using the right x264 settings and converted audio to ac3 640.

when muxing in tsMuxer, what should the options for “sei/vui” and “sps/pps” be? I know this gave me stuttering problems in the past with certain sources when muxing regular mkv videos and playing them in mpc-hc.

the movie has no chapters and does not need any (it needs to play from start to end in a theater, so no menu or anything needed), so I set “no chapters” instead of inserting them every 5 minutes - not sure wether this is a good thing or not either.


#13

I’m afraid I haven’t got answers for these questions. I’ve never had issues with tsMuxeR’s output, so I haven’t futzed with those settings. On the other hand, I haven’t made anything for Blu-ray with 25fps either. What you’re doing is a little unusual.

I would advise letting tsMuxeR do its thing, then test the output. It doesn’t take that long to mux to Blu-ray.

Chapters aren’t necessary, but I’ve always put them in. If nothing else, it helps preview sections when checking for errors.


#14

1080p @ 25fps is not allowed I believe
What format is the file in prior to using TsMuxer?


#15

It’s 1080i, I encoded using --fake-interlaced as advised here:

here’s the produced .264 file:

General
Complete name : C:\out\output.264
Format : AVC
Format/Info : Advanced Video Codec
File size : 20.2 GiB
Overall bit rate mode : Variable
Writing library : x264 core 148 r2638 7599210
Encoding settings : cabac=1 / ref=4 / deblock=1:-1:-1 / analyse=0x3:0x133 / me=umh / subme=10 / psy=1 / psy_rd=1.00:0.15 / mixed_ref=1 / me_range=24 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-3 / threads=12 / lookahead_threads=1 / sliced_threads=0 / slices=4 / nr=0 / decimate=1 / interlaced=fake / bluray_compat=1 / constrained_intra=0 / bframes=3 / b_pyramid=1 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=1 / weightp=1 / keyint=25 / keyint_min=1 / scenecut=40 / intra_refresh=0 / rc_lookahead=25 / rc=2pass / mbtree=1 / bitrate=38000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / vbv_maxrate=40000 / vbv_bufsize=30000 / nal_hrd=vbr / filler=0 / ip_ratio=1.40 / aq=1:1.00

Video
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4.1
Format settings, CABAC : Yes
Format settings, ReFrames : 3 frames
Bit rate mode : Variable
Bit rate : 38.0 Mbps
Maximum bit rate : 40.0 Mbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate : 25.000 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.733
Writing library : x264 core 148 r2638 7599210
Encoding settings : cabac=1 / ref=4 / deblock=1:-1:-1 / analyse=0x3:0x133 / me=umh / subme=10 / psy=1 / psy_rd=1.00:0.15 / mixed_ref=1 / me_range=24 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-3 / threads=12 / lookahead_threads=1 / sliced_threads=0 / slices=4 / nr=0 / decimate=1 / interlaced=fake / bluray_compat=1 / constrained_intra=0 / bframes=3 / b_pyramid=1 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=1 / weightp=1 / keyint=25 / keyint_min=1 / scenecut=40 / intra_refresh=0 / rc_lookahead=25 / rc=2pass / mbtree=1 / bitrate=38000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / vbv_maxrate=40000 / vbv_bufsize=30000 / nal_hrd=vbr / filler=0 / ip_ratio=1.40 / aq=1:1.00
Color range : Limited
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709
tsmuxer detects it as 1080i:

Network Optix tsMuxeR. Version 2.6.12. www.networkoptix.com
Decoding H264 stream (track 1): Profile: High@4.1 Resolution: 1920:1080i Frame rate: 25
H.264 muxing fps is not set. Get fps from stream. Value: 25
B-pyramid level 1 detected. Shift DTS to 2 frames
H264 bitstream changed: insert pict timing and buffering period SEI units
Decoding AC3 stream (track 2): Bitrate: 640Kbps Sample Rate: 48KHz Channels: 2
Processed 114627 video frames
Flushing write buffer
Creating Blu-ray stream info and seek index
Creating Blu-ray playlist
Mux successful complete
Muxing time: 2 min 38 sec

should I burn this directly, or should I now input this into BD-RE?


#16

[QUOTE=gonca;2773162]1080p @ 25fps is not allowed I believe
What format is the file in prior to using TsMuxer?[/QUOTE]

This is the only place I’ve seen that talks about 25fps and 1080p:

Using the fake interlaced flag.

His source file specs are in a previous post.


#17

If you have a player that plays BD-RE consistently well, I’d certainly burn it to one of them, rather than waste a BD-R disc just for testing.

Does it play well on the computer with MPC-HC or another software player?


#18

sorry, I meant BD-REbuilder, not a BD-RE disc :wink: I’ll burn to BD-R in any case… and yes the m2ts play fine in mpc-hc and windvd


#19

[QUOTE=Kerry56;2773166]This is the only place I’ve seen that talks about 25fps and 1080p:

Using the fake interlaced flag.

His source file specs are in a previous post.[/QUOTE]
Sorry, missed that
I thought that since he was going to do a new encode he would do it to 1080p


#20

I believe that WinDVD is a licensed player
Try playing the BD folder as opposed to just the m2ts file
If it plays the BD folder properly it should be ready for a test burn