Fanedit Forums
Captain Khajiit's Quick Guide to Encoding a BD via the Command-line - Printable Version

+- Fanedit Forums (https://forums.fanedit.org)
+-- Forum: Technical Information (https://forums.fanedit.org/forumdisplay.php?fid=5)
+--- Forum: File Conversion (https://forums.fanedit.org/forumdisplay.php?fid=23)
+--- Thread: Captain Khajiit's Quick Guide to Encoding a BD via the Command-line (/showthread.php?tid=15699)



Captain Khajiit's Quick Guide to Encoding a BD via the Command-line - Captain Khajiit - 09-20-2017

This is a very short guide devoted to answering a single question:

How do I encode a BD via the command-line?

Assuming 1920x1080p@23.976fps input, I do it like this.

Windows
Code:
"x264.exe" --pass 1 --bitrate XXXXX --bluray-compat --level 4.1 --preset slower --tune film --keyint 24 --sar 1:1 --slices 4 --vbv-bufsize 30000 --vbv-maxrate 40000 --b-pyramid none --weightp 0 --colorprim bt709 --transfer bt709 --colormatrix bt709 --merange 24 --output NUL "whatever.avs"
"x264.exe" --pass 2 --bitrate XXXXX --bluray-compat --level 4.1 --preset slower --tune film --keyint 24 --sar 1:1 --slices 4 --vbv-bufsize 30000 --vbv-maxrate 40000 --b-pyramid none --weightp 0 --colorprim bt709 --transfer bt709 --colormatrix bt709 --merange 24 --output "whatever.264" "whatever.avs"

Feed your rendered video to x264 via AviSynth.  (My decoding guide has instructions for writing a basic script.)

Linux
Code:
x264 --pass 1 --bitrate XXXXX --bluray-compat --level 4.1 --preset slower --tune film --keyint 24 --sar 1:1 --slices 4 --vbv-bufsize 30000 --vbv-maxrate 40000 --b-pyramid none --weightp 0 --colorprim bt709 --transfer bt709 --colormatrix bt709 --merange 24 --output /dev/null --fps 24000/1001 input.mkv
x264 --pass 2 --bitrate XXXXX --bluray-compat --level 4.1 --preset slower --tune film --keyint 24 --sar 1:1 --slices 4 --vbv-bufsize 30000 --vbv-maxrate 40000 --b-pyramid none --weightp 0 --colorprim bt709 --transfer bt709 --colormatrix bt709 --merange 24 --output output.264 --fps 24000/1001 input.mkv

The main difference is that on Linux you'll probably be feeding x264 via ffms support: your distro should have such a version in its repos.  To check, open a terminal and run:
Code:
x264 --fullhelp | head

This is the line that you need to look for:
Code:
or libav* formats if compiled with lavf support (yes) or ffms support (yes)

Ensure that it says (yes) next to "ffms support".

Bitrate

Use a bitrate calculator to determine the average bitrate, and change --bitrate XXXXX accordingly: e.g., --bitrate 25000.

Closing GOPs and setting b-pyramid to none and weightp to 0 are measures that promote compatibility with older chip-sets (and can help with fussy authoring programs) but are not strictly required by the BD spec, which looks like shon3i's excellent post here. If you are encoding anything other than 1920x1080p@23.976fps, I suggest that you follow the command-lines given on this site but adjust them to include the three compatibility measures given above (i.e. by adding --b-pyramid none and --weightp 0 and removing --open-gop in order to close the GOPs).

Tools

x264
AviSynth (I always recommend the latest non-MT version.)
Bitrate Calculator
tsMuxeR

I always use a 32-bit workflow because the 32-bit versions of tools are usually more up to date, but you can use a 64-bit workflow if you like.  N.B.  You must use like with like i.e. you cannot use the 32-bit version of AviSynth with the 64-bit of x264 (and vice versa).  If in doubt, keep everything 32-bit and you will not go wrong.

N.B. I do not intend to turn this into a thread about using or troubleshooting the various GUIs that are available (e.g. MeGUI).  Please start separate threads in you want to discuss those.

Muxing

Nightly builds of tsMuxer for Linux, macOS, and Windows are currently available at VideoHelp.com.



N.B. Questions about colorspace conversions and levels issues are beyond the scope of this guide.


RE: Captain Khajiit's Quick Guide to Encoding a BD via the Command-line - Captain Khajiit - 09-20-2017

FAQ

reserved


RE: Captain Khajiit's Quick Guide to Encoding a BD via the Command-line - ThrowgnCpr - 09-20-2017

Fastastic, thanks for making this thread


RE: Captain Khajiit's Quick Guide to Encoding a BD via the Command-line - RollWave - 03-18-2018

For blu-ray authoring in DVDarchitect, I would like to recommend changing:

"--vbv-maxrate 40000"

to

"--vbv-maxrate 38000"

When using your settings, or GeminiGod's settings in the other thread, DVDarchitect would always want to recompress my video tracks. No combination of open/closed gop, bpyramid, weightp, or a number of other iterations with other settings I tried made any difference. BUT lowering this maxrate by a marginal amount made it work.


My very poor guess as to why this may be the case is that if the video alone is using the maxbitrate, then once DVDarchitect adds in the audio, the new video/audio combination may exceed the bluray spec limit. So this lowers the max by an amount that allows the audio to be added in, and still remain below the 40k limit.

Whether this is intended, a bug, a coincidence, or I'm just completely wrong, I cannot say.

But it works. DVDarchitect does not require recompressing the video track with this lower vbv-maxrate.


RE: Captain Khajiit's Quick Guide to Encoding a BD via the Command-line - Captain Khajiit - 01-11-2020

I've updated the guide to make it accessible to Linux users.