Log in

View Full Version : BluRay Encoding from libx264 in ffmpeg


Electron.Rotoscope
26th May 2013, 01:17
Does anyone know how to set x264 flags in ffmpeg that aren't covered here?
https://sites.google.com/site/linuxencoding/x264-ffmpeg-mapping

What I'm hoping to do is follow the command line from https://sites.google.com/site/x264bluray/ and encode a large sourcefile into a .264 and .ac3 in one pass, but I can't set all the flags I need. Is there a way to set x264 flags like --bluray-compat directly? Or is there a list somewhere of everything that it sets so I can just do them all manually?

Secondary question: it's my understanding that a 2 pass encode is functionally the same as a crf encode quality-wise, but is crf safe to use for bluray encoding? I ask because I can't find any examples of anyone doing it, but no-one seems to say explicitly that it doesn't work.

Electron.Rotoscope
26th May 2013, 02:25
Tertiary Question:

If I use the following command line input to pipe out just the video
C:\cli\ffmpeg\bin\ffmpeg.exe -i infile -pix_fmt yuv420p -f yuv4mpegpipe - | C:\cli\x264\x264.exe --input-res 1920x1080 --fps 24000/1001 --crf 18 ^
--preset veryslow --tune film --bluray-compat --vbv-maxrate 40000 --vbv-bufsize 30000 --level 4.1 --keyint 24 --open-gop --slices 4 --colorprim "bt709" --transfer "bt709" --colormatrix "bt709" --sar 1:1 ^
-o "Z:\temp\infile-forbluray.264" -

it mostly works! But it tells me
[yuv4mpegpipe @ 000000000264f040] Encoder did not produce proper pts, making some up.
and then reports the encoded bitrate as being around 596600 kbits for the whole encode. Is that normal?

fvisagie
27th May 2013, 13:00
These may be of some help:
* http://ffmpeg.org/trac/ffmpeg/wiki/x264EncodingGuide (covers CRF vs. 2-pass etc.), and
* http://www.ffmpeg.org/ffmpeg-codecs.html#Option-Mapping

Cheers,
Francois

Electron.Rotoscope
27th May 2013, 19:59
Thanks, unfortunately neither seem to help with this question.

This (http://doom10.org/index.php?PHPSESSID=okj08qe73ictdtv532augv8nu7&topic=267.msg2071#msg2071) from your first link is why I was thinking that CRF and 2-Pass are functionally the same in most cases, I'm just worried about --vbv-bufsize type stuff that people don't usually care about outside of a BluRay.

And unfortunately while I appreciate another option mapping link, you may notice that it also doesn't cover --bluray-compat, so it unfortunately isn't really enough.

Thanks for looking though!

fvisagie
28th May 2013, 07:37
This (http://doom10.org/index.php?PHPSESSID=okj08qe73ictdtv532augv8nu7&topic=267.msg2071#msg2071) from your first link is why I was thinking that CRF and 2-Pass are functionally the same in most cases, I'm just worried about --vbv-bufsize type stuff that people don't usually care about outside of a BluRay.

BluRay is one of those cases where the differences do matter as you suggest. Specifically wrt. CRF, from the first link:
The downside is that you can't tell it to ... not go over a specific size or bitrate.
Hence the rule-of-thumb to use 2-pass encoding for size and bitrate-constrained targets like DVD and BluRay.

And unfortunately while I appreciate another option mapping link, you may notice that it also doesn't cover --bluray-compat, so it unfortunately isn't really enough.

Thanks for looking though!

A little down the Private Options (http://www.ffmpeg.org/ffmpeg-codecs.html#Private-Options) I'd play with

‘-b-pyramid integer’

Keep some B-frames as references.

Possible values:

‘none’
‘strict’

Strictly hierarchical pyramid.
‘normal’

Non-strict (not Blu-ray compatible).

fvisagie
28th May 2013, 11:52
Actually, this is the one to use in this case (from the ffmpeg mailing list):

> The question is: "Is there a way to set x264 flags like
> --bluray-compat directly?"
>

Yes! use "-x264opts bluray-compat=1

multiple options should be separated with a colon ":" but no spaces.

>


A little more information about -x264opts from Private Options (http://www.ffmpeg.org/ffmpeg-all.html#Private-Options):

‘x264opts options’

Allow to set any x264 option, see x264 --fullhelp for a list.

options is a list of key=value couples separated by ":". In filter and psy-rd options that use ":" as a separator themselves, use "," instead. They accept it as well since long ago but this is kept undocumented for some reason.

For example to specify libx264 encoding options with ffmpeg:
ffmpeg -i foo.mpg -vcodec libx264 -x264opts keyint=123:min-keyint=20 -an out.mkv

For more information about libx264 and the supported options see: http://www.videolan.org/developers/x264.html


Cheers,
Francois

Electron.Rotoscope
2nd June 2013, 19:15
Actually, this is the one to use in this case (from the ffmpeg mailing list):



A little more information about -x264opts from Private Options (http://www.ffmpeg.org/ffmpeg-all.html#Private-Options):

‘x264opts options’

Allow to set any x264 option, see x264 --fullhelp for a list.

options is a list of key=value couples separated by ":". In filter and psy-rd options that use ":" as a separator themselves, use "," instead. They accept it as well since long ago but this is kept undocumented for some reason.

For example to specify libx264 encoding options with ffmpeg:
ffmpeg -i foo.mpg -vcodec libx264 -x264opts keyint=123:min-keyint=20 -an out.mkv

For more information about libx264 and the supported options see: http://www.videolan.org/developers/x264.html


Cheers,
Francois

Amazing, that's exactly what I need! Thanks so much!

Electron.Rotoscope
2nd June 2013, 19:25
BluRay is one of those cases where the differences do matter as you suggest. Specifically wrt. CRF, from the first link:

Hence the rule-of-thumb to use 2-pass encoding for size and bitrate-constrained targets like DVD and BluRay.

Oh damn so CRF just ignores all the vbv flags? damn damn damn

Dark Shikari
2nd June 2013, 19:26
CRF works just fine with VBV.