VideoHelp Forum
+ Reply to Thread
Results 1 to 25 of 25
Thread
  1. I'm scratching my head trying to work out how to encode Prores files on a Mac using the X264 encoder. Can anyone help me out - can I use ffmpeg, or is it bettter to run via Terminal? Is there some sort of beginner's guide out there?

    I'm aiming to produce Blu-ray compliant encodes for import into authoring sofware for commercially pressed discs.

    Thanks.
    Last edited by TenementLady; 10th Feb 2021 at 11:53.
    Quote Quote  
  2. I'm a Super Moderator johns0's Avatar
    Join Date
    Jun 2002
    Location
    canada
    Search Comp PM
    Thread moved to the mac forum where you can get more help.
    I think,therefore i am a hamster.
    Quote Quote  
  3. Explorer Case's Avatar
    Join Date
    Feb 2004
    Location
    Middle Earth
    Search Comp PM
    Originally Posted by TenementLady
    I'm aiming to produce Blu-ray compliant encodes
    ffmpeg and many softwares based on ffmpeg, and other conversion tools, will have a blu-ray preset, to make it easier for users to create compliant files. My conversion tool of choice is ff·Works, which is a GUI for ffmpeg.

    Originally Posted by TenementLady
    for import into authoring software for commercially pressed discs.
    That unspecified authoring software may have its own file requirements, which may or may not be configured in X264 or ffmpeg or other conversion software. For commercially pressed discs, consult with the next firm in the production chain.
    Quote Quote  
  4. Thanks

    I do the disc authoring myself too, so I need to be able to make sure the encodes are Blu-ray compliant. I need to know which settings to use based on the various types of film footage etc I'll be encoding.
    Quote Quote  
  5. Explorer Case's Avatar
    Join Date
    Feb 2004
    Location
    Middle Earth
    Search Comp PM
    Originally Posted by TenementLady
    I do the disc authoring myself too, so I need to be able to make sure the encodes are Blu-ray compliant.
    Some authoring software can be finicky, so it may cost some trial-and-error that is specific to that authoring software. Good authoring software will reject non-compliant files on import, so test a short clip first to speed up this part of the process.

    Originally Posted by TenementLady
    I need to know which settings to use based on the various types of film footage etc I'll be encoding.
    Use a blu-ray preset in GUI software, as mentioned above; that covers all the sub-settings that the software thinks is required. The frame rate will be your choice, and the audio codec will be your choice, as there are multiple good choices there, but the other settings should probably not vary too much. Don’t use CRF, but two-pass instead.

    For command line, see some examples on the web.
    Authoring a professional Blu-ray Disc with x264 - x264bluray.com
    Google ffmpeg encode for blu-ray
    Quote Quote  
  6. Can anyone help with ff-works and how to set this up for blu-ray compliant x264 streams? I'm screatching my head here, I have no idea where to start.
    Quote Quote  
  7. I've honestly never touched ff-works, but if you don't mind spending some time in Terminal, I can give you the command I use that should produce Blu–Ray compliant files *.264 files for 1080p30 source material.

    Code:
    ./ffmpeg -i INPUT.mov -c:v h264 -preset veryslow -b:v 20000k -maxrate 40000k -bufsize 30000k -level 4.1 -pix_fmt yuv420p -x264-params bluray-compat=1:open-gop=1:slices=4:keyint=30:fake-interlaced=1:colorprim=bt709:transfer=bt709:colormatrix=bt709:pass=1 OUTPUT.264
    For the second pass, the only change is this:

    Code:
    ./ffmpeg -i INPUT.mov -c:v h264 -preset veryslow -b:v 20000k -maxrate 40000k -bufsize 30000k -level 4.1 -pix_fmt yuv420p -x264-params bluray-compat=1:open-gop=1:slices=4:keyint=30:fake-interlaced=1:colorprim=bt709:transfer=bt709:colormatrix=bt709:pass=2 OUTPUT.264
    When the second pass prompts you to overwrite the file from the first pass, select yes, ("Y" in the y/N prompt) and hit return. When done, you should have a Blu–Ray compliant video file with no audio. (More on that in a bit.)

    All right, so what did we actually just do? First, a bit more information about my source file: My source file is a ProRes4444 video file in an *.mov container. Technically it also has uncompressed 48kHz two channel stereo audio in it, but we don't care about that as we're only focused on the video right now. (The audio could honestly even be 44.1kHz stereo as I won't be using the audio from the ProRes file anyway. Theoretically I could have saved the *.mov file from my editing software with no audio whatsoever.) Keeping everything I've just mentioned in mind, the following information applies only to the video portion of your file.

    Code:
    ./ffmpeg
    I put a copy of FFMpeg in the same folder as my source files; I recommend this for the sake of simplicity, but you'll need the ./ at the beginning of your ffmpeg commands if you do this.

    Code:
    -i INPUT.mov
    This tells FFMpeg to use INPUT.mov as the input file, although you can name your file whatever you want.

    Pro Tip: Drag the file into the Terminal window if it has a long name, this will save you from having to remember to type a \ every time there's a space. If you like clean code, you can then erase the path before the start of your filename too to keep things neat.

    Code:
    -c:v h264
    This is telling FFmpeg to use the H.264 video codec, although you could probably substitute this for libx264; personally I don't notice a difference, and it's faster to type h264, so that's what I use.

    Code:
    -preset veryslow
    This tells FFmpeg to use the veryslow preset of the h264 encoder. Theoretically, this should result in the highest quality file at the smallest size possible based on your other settings. Note that I did not add a -tune option to my command, but if you're working with material that was literally shot on film or that is 2D animation, you may wish to add one after the -preset veryslow portion of the command.

    Code:
    -b:v 20000k
    Okay, now we're at the part where things really start to matter. This is setting the video bitrate to 20Mbps, which is the standard for Blu–Ray.

    Code:
    -maxrate 40000k
    This tells the encoder to have a maximum bitrate of 40Mbps,but never more than that.

    Code:
    -bufsize 30000k
    This is our buffer size; it's what FFMpeg should target in scenes with lots of motion where it has to go above 20Mbps.

    Code:
    -level 4.1
    This tells FFmpeg to create an h264 file with a profile level of 4.1, which is required for most Blu–Ray formats.

    Code:
    -pix_fmt yuv420p
    This tells FFMpeg to create a video that uses the 4:2:0 8–bit color space required by Blu–Ray. Note that most ProRes files utilize 10–bit color that does NOT play well with standard Blu–Ray discs, so this command is a must. If you're not sure what color space your source file is in, include this all the time.

    Code:
    -x264-params bluray-compat=1:open-gop=1:slices=4:keyint=30:fake-interlaced=1:colorprim=bt709:transfer=bt709:colormatrix=bt709:pass=1
    This really long command actually handles several settings with each setting being separated by colons, so I'll break it down a bit more below.

    Code:
    -x264-params bluray-compat=1:
    This tells FFMpeg to include the following parameters in the output file. The first is Blu–Ray compatibility, hence the bluray-compat=1 portion of the command.

    Code:
    open-gop=1:
    Blu–Ray requires an open GOP structure, so that's what we're giving it.

    Code:
    slices=4:
    Blu–Ray also requires four slices for our 1080p30 source material, so that's set here as well.

    Code:
    keyint=30:
    Also required by Blu–Ray, this tells FFMpeg to have an i–frame (often described as a keyframe) every 30 frames; your ProRes file is all I–frames, but your Blu–Ray file needs to keep one of those every 30 frames; the rest can be P–frames and B–frames.

    Code:
    fake-interlaced=1:
    This really only applies to 1080p30 and 1080p25 footage. Blu–Ray does not support storing 29.97fps footage at 1080p. To get around that, this command tells FFMpeg to store the footage in a way that Blu–Ray will interpret it as 1080i60, which is an acceptable Blu–Ray format. Now I want to make something abundantly clear here: we are not interlacing the footage! (I can't emphasize that enough.) All we're doing is telling FFMpeg to store the footage in a way that Blu–Ray can understand. I believe the name for this format is Progressive–segmented–Frame, or PsF. Either way, it's not actually interlaced. Your profile says you're in London, if you're working with 1080p25 and not 1080p24, you'll probably need to include this.

    Code:
    colorprim=bt709:
    This is color metadata that Blu–Ray expects from the video file, in this case the color primaries. BT.709 is the standard for HDTV, and is what Blu–Ray is expecting.

    Code:
    transfer=bt709:
    More color metadata, in this case the color transfer properties.

    Code:
    colormatrix=bt709:
    Even more color metadata, in this case the color matrix.

    Code:
    pass=1
    And finally, a command indicating that this is a 2–pass encode and that this is the first pass. For the second pass all you'll do is change this to
    Code:
    pass=2
    ; that's the only change you'll need to make for pass 2.

    Code:
    OUTPUT.264
    And finally, this tells FFMpeg to create a file named OUTPUT.264, although you can change OUTPUT to anything. Note that this is a *.264 file, and not an *.mp4; Blu–Ray likes raw stream data, so that's what we're giving it, hence the *.264 extension. (This can be dumped into an MP4 or MOV later as well though if you wish.)

    All right, now we have the video, but we still need audio. Typically I would export a *.wav file separately from your editing software just to speed this step up a little, but if you want to split it out of your video file that's always an option too. What's important is that the audio be uncompressed linear PCM at 48kHz. Note that you could use AC–3 or a similar format too, but LPCM is probably the most standard these days, so that's what I use. I'm not sure what your editing software is, but this next step is kind of required if you're using Adobe Premiere Pro. Download and install Audacity; it's small, free, and available under the VideoHelp "Tools" section of the site. Take your *.wav file, open it in Audacity, and save it again. At this point you should be prompted for metadata info. Delete all of the metadata fields that you can remove completely and empty out the others as best you can. Once you've named and saved your new *.wav file, you should be good to go.

    The reason for the *.wav file with the metadata removed boils down to tsMuxer (the software we'll use to create an *.m2ts file like the ones on a Blu–Ray Disc for testing purposes,) not being able to handle a *.wav file directly from Adobe Premiere Pro/Media Encoder, seemingly as a result of the metadata that Adobe adds. If you leave this in your audio will sound fine until the last second or so of your video, upon which you'll be greeted with a LOUD buzzing sound that'll drive you insane and maybe break some speakers. This isn't something anyone would want in a file you were giving away for free, let alone in a pressed Blu–Ray, so it's important to make sure that this nuisance is eliminated before you author any discs.

    Testing your files:
    Okay, we have a *.264 file and a *.wav file. If you don't already have tsMuxer, go ahead and download that from the "Tools" section of VideoHelp as well. Drag the *.264 and *.wav file into tsMuxer, select "*.mt2s Stream" for your output, and make sure "BDMV Compatible" is check off. (I believe it's under the General tab, it should be checked by default.) Click on the button that says something like "Start Muxing." You should now have a Blu–Ray compliant *.m2ts file that you can test in VLC or similar software before you go ahead and author a full disc with whatever you normally use. (Out of curiosity, what are you using to author Blu–Ray discs on the Mac? The options are pretty limited, so I'm definitely interested in knowing what's out there.) It's also how I discovered the need for the step above involving Audacity.

    Finally, if you're working with 1080p23.976/1080p24 footage, the following variant of the command above can be used:

    Code:
    ./ffmpeg -i INPUT.mov -c:v h264 -preset veryslow -b:v 20000k -maxrate 40000k -bufsize 30000k -level 4.1 -pix_fmt yuv420p -x264-params bluray-compat=1:open-gop=1:slices=4:keyint=24:colorprim=bt709:transfer=bt709:colormatrix=bt709:pass=1 OUTPUT.264
    For 1080p25 use the following:

    Code:
    ./ffmpeg -i INPUT.mov -c:v h264 -preset veryslow -b:v 20000k -maxrate 40000k -bufsize 30000k -level 4.1 -pix_fmt yuv420p -x264-params bluray-compat=1:open-gop=1:slices=4:keyint=25:fake-interlaced=1:colorprim=bt709:transfer=bt709:colormatrix=bt709:pass=1 OUTPUT.264
    In both cases, change the "1" to a "2" for the pass number on the second output. Let me know if this was of any assistance. I know it's not ff-works, but I'm hoping that it's still helpful for achieving the end result that you wanted.
    Specs: Mac Mini (Early 2006): 1.66 GHz Intel Core Duo CPU, 320GB HDD, 2GB DDR2 RAM, Intel GMA 950 integrated graphics card, Matshita UJ-846 Superdrive, Mac OS X 10.5.7 and various peripherals. System runs Final Cut Express 3.5 for editing.
    Quote Quote  
  8. Handbrake and AviDemux are both available for the Mac.
    Quote Quote  
  9. Jagabo, Handbrake and Avidemux don't create Blu–Ray compliant streams. Remember, TenementLady is trying to author Blu–Ray discs; those need *.264 video streams for the authoring software, not *.mp4 files.
    Specs: Mac Mini (Early 2006): 1.66 GHz Intel Core Duo CPU, 320GB HDD, 2GB DDR2 RAM, Intel GMA 950 integrated graphics card, Matshita UJ-846 Superdrive, Mac OS X 10.5.7 and various peripherals. System runs Final Cut Express 3.5 for editing.
    Quote Quote  
  10. x264 has blu-ray compatibility options -- though I can't vouch for how well they work. One can easily demux h.264 elementary streams from mp4 files.
    Quote Quote  
  11. Originally Posted by jagabo View Post
    x264 has blu-ray compatibility options -- though I can't vouch for how well they work. One can easily demux h.264 elementary streams from mp4 files.
    x264's Blu–Ray compatibility options work; they're used by Criterion (via FFMpeg) on a regular basis and have been used on other major commercial Blu–Ray releases as well. (e.g. Friends Season One, per x264's own website.) However, those compatibility options need to be enabled when the stream is initially created or you'll have nothing but problems with it; at best you'll wind up with "friendly" authoring software that decides to re–encode your files for you, creating quality loss in the process, which is something a person authoring discs for the purpose of pressing is going to actively want to avoid. This is why FFMpeg or one of its variants, with or without a front–end like ff–works is a must; not Handbrake or AVIDemux. While both Handbrake and AVIDemux use portions of x264, they do not author Blu–Ray compliant files, or even Blu–Ray compliant streams. At best you would wind up with elementary streams that would need to be re–encoded, which is unacceptable in a professional production environment, and completely avoidable using the method I've outlined above.
    Specs: Mac Mini (Early 2006): 1.66 GHz Intel Core Duo CPU, 320GB HDD, 2GB DDR2 RAM, Intel GMA 950 integrated graphics card, Matshita UJ-846 Superdrive, Mac OS X 10.5.7 and various peripherals. System runs Final Cut Express 3.5 for editing.
    Quote Quote  
  12. Thanks so much. I've copied ffmpeg to the same project folder as my video file on an external Drobo drive, but I'm having problems specifying the paths in Terminal.

    External Drobo Drive/Current Project/ProjectA/ffmpeg
    External Drobo Drive/Current Project/ProjectA/Project.mov

    Terminal says: ./ffmpeg: No such file or directory

    Edit - OK, I left the first dot off the path to ffmpeg and it now seems to be encoding. Will report back. Thanks
    Quote Quote  
  13. I agree that using ffmpeg is a better option because you have better control. But I'm pretty sure AviDemux lets you specify all the Blu-ray compatibility options via it's GUI. And Handbrake lets you manually add any x264 options you want in the "Extra Options" box. Like I said, I'm not sure how well they work in practice -- for example, maybe some of the Handbrake GUI options will conflict with, or override, the manual options.

    In any case, the user seems to finally have ffmpeg working.
    Last edited by jagabo; 24th Mar 2021 at 09:54.
    Quote Quote  
  14. Hi jagabo, I've had a play around with AviDemux, and on first glance it appears pretty good. However, I'm unsure how to export encoded files with the correct file type extension. Can you help?

    For example, Apple's Compressor exports Blu-ray encoded files with a .264 extension.

    Also with AviDemux, I'm not quite sure what controls it has for the varying types of film grain.
    Quote Quote  
  15. I've now done my first test encode, and I'm seeing this error, any suggestions?

    ProRes422HQMovie.mov: corrupt decoded frame in stream 2. 251x
    ProRes422HQMovie.mov: corrupt decoded frame in stream 2. 252x


    the rest:

    frame=131327 fps=6.1 q=-1.0 Lsize=13383358kB time=01:31:11.87 bitrate=20036.4kbits/s speed=0.254x
    video:13383358kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
    [libx264 @ 0x7fb1ef019a00] frame I:4564 Avg QP:23.37 size:205910
    [libx264 @ 0x7fb1ef019a00] frame P:42267 Avg QP:26.36 size:112620
    [libx264 @ 0x7fb1ef019a00] frame B:84496 Avg QP:26.68 size: 94735
    [libx264 @ 0x7fb1ef019a00] consecutive B-frames: 5.4% 1.5% 75.3% 17.9%
    [libx264 @ 0x7fb1ef019a00] mb I I16..4: 0.6% 96.3% 3.1%
    [libx264 @ 0x7fb1ef019a00] mb P I16..4: 0.1% 17.6% 0.1% P16..4: 40.5% 30.8% 10.2% 0.1% 0.0% skip: 0.5%
    [libx264 @ 0x7fb1ef019a00] mb B I16..4: 0.0% 6.6% 0.0% B16..8: 53.4% 15.6% 4.4% direct:12.4% skip: 7.6% L0:48.7% L1:44.9% BI: 6.4%
    [libx264 @ 0x7fb1ef019a00] final ratefactor: 22.37
    [libx264 @ 0x7fb1ef019a00] 8x8 transform intra:98.3% inter:85.4%
    [libx264 @ 0x7fb1ef019a00] direct mvs spatial:100.0% temporal:0.0%
    [libx264 @ 0x7fb1ef019a00] coded y,uvDC,uvAC intra: 97.9% 61.5% 18.9% inter: 75.2% 37.6% 0.1%
    [libx264 @ 0x7fb1ef019a00] i16 v,h,dc,p: 27% 17% 24% 32%
    [libx264 @ 0x7fb1ef019a00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 7% 5% 8% 11% 16% 13% 15% 11% 13%
    [libx264 @ 0x7fb1ef019a00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 9% 5% 2% 10% 15% 15% 15% 13% 15%
    [libx264 @ 0x7fb1ef019a00] i8c dc,h,v,p: 42% 29% 17% 11%
    [libx264 @ 0x7fb1ef019a00] Weighted P-Frames: Y:12.5% UV:3.2%
    [libx264 @ 0x7fb1ef019a00] ref P L0: 63.7% 36.3% 0.0%
    [libx264 @ 0x7fb1ef019a00] ref B L0: 80.8% 19.2%
    [libx264 @ 0x7fb1ef019a00] ref B L1: 97.0% 3.0%
    [libx264 @ 0x7fb1ef019a00] kb/s:20036.06
    Quote Quote  
  16. It appears the program had problems reading the source video.
    Quote Quote  
  17. Can anyone help with how to get the correct Blu-ray compliant extension exported from AviDemux?
    Quote Quote  
  18. AviDemux cannot export as an h.264 elementary stream. You should export as MOV or MP4 then demux the video to an elementary stream. I don't know what's available on the Mac but with ffmpeg it's:

    Code:
    ffmpeg -i input.mov -c copy output.264
    Depending on the size of the source it will only take a few seconds to a few minutes.
    Quote Quote  
  19. I've been encoding for Blu-ray with ffmpeg/x264, but all the encodes state they are encoded with: x264 core 161 r3048 b86ae3c

    I've just checked my installed version (via Homebrew) and it says I have x264 is x264 r3060 installed.

    Does anybody know why ffmpeg is referencing an older version of x264 to perform the encodes? Is it a Mac issue?

    Thanks.
    Quote Quote  
  20. ffmpeg uses its built in version of x264, not a system installed version.
    Quote Quote  
  21. Thanks, I always thought ffmpeg referenced an installed version of x264.

    So I guess I need to wait for an ffmpeg update.
    Quote Quote  
  22. Does anyone know if it's possible to use GPU acceleration on a Mac (AMD Radeon Pro 580 8 GB) as part of the ffmpeg command string? I've tried several attemps and not been able to get anything to work so far.
    Quote Quote  
  23. I usually use ffmpeg builds from https://evermeet.cx/ffmpeg/ on Mac OS and at least those lack any gpu acceleration for encoding.
    Not sure whether vce support is even available on mac os. (I think there are no vce capable drivers for mac os,..)
    Iirc there it was possible to compile ffmpeg with videotoolbox support, but no clue whether videotoolbox even exists on newer MacOSs.
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  24. It looks like you can use -c:v h264_videotoolbox or -c:v hevc_videotoolbox.

    https://stackoverflow.com/questions/52591553/how-to-use-ffmpeg-with-gpu-support-on-macos
    Quote Quote  
  25. mr. Eric-jan's Avatar
    Join Date
    Apr 2018
    Location
    Netherlands
    Search Comp PM
    Shutter Encoder has a good GUI which uses ffmpeg

    Extremely easy to setup
    Last edited by Eric-jan; 13th Nov 2022 at 08:34.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!