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 20th August 2024, 05:16   #1  |  Link
PSimpso
Registered User
 
Join Date: Jul 2024
Posts: 4
x264 not working on the Mac

I’ve been digging into x264 for the first time. I installed x264 on my Mac and started trying out commands but was getting error messages. Eventually I installed it on a PC and the same exact commands worked with no errors. I had tried it on both Intel and Apple silicon Macs.

For example, here’s a command that works on a PC…
x264.exe --bitrate 25000 --preset ultrafast --tune film --vbv-maxrate 40000 --vbv-bufsize 30000 -o output.264 input

…but the exact same command on the Mac I get the following errors:
avs [error]: failed to load avisynth
raw [error]: raw input requires a resolution.
x264 [error]: could not open input file `input' via any method!


Am I doing something wrong? Shouldn't a basic command like that work on a Mac as well?
PSimpso is offline   Reply With Quote
Old 20th August 2024, 08:22   #2  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,872
Which x264 are you using? Seems yours is compiled and dependant on avisynth. You also have to specify a resolution with --input-res
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is offline   Reply With Quote
Old 20th August 2024, 16:32   #3  |  Link
PSimpso
Registered User
 
Join Date: Jul 2024
Posts: 4
Here's the version info on my Mac (I installed through Homebrew):

x264 0.164.3108 31e19f9
built on Oct 4 2023, clang: 14.0.3 (clang-1403.0.22.14.1)
x264 configuration: --chroma-format=all
libx264 configuration: --chroma-format=all
x264 license: GPL version 2 or later


And good to know about the --input-res command. Any idea why my encodes are working without it on the PC?

Last edited by PSimpso; 20th August 2024 at 17:45.
PSimpso is offline   Reply With Quote
Old 22nd August 2024, 01:22   #4  |  Link
qyot27
...?
 
qyot27's Avatar
 
Join Date: Nov 2005
Location: Florida
Posts: 1,445
x264 builds on Windows usually have FFMS2 and/or LAVF enabled, while Homebrew explicitly disables FFMS2 input.

AviSynth input support is enabled by default in x264 because they ship a copy of the AviSynth+ headers in the x264 source tree. That input module will only function if AviSynth(+) is installed, though. Otherwise, it would try to fall back to another input module that would work. So on Windows you'd probably never see it fall all the way down to trying RAW input. But because Homebrew doesn't enable either of the two general-purpose input modules, and you don't have AviSynth+ installed, you are seeing it fall back to attempting to open the file as raw video and failing because A) you have to specify resolution and framerate for raw and B) even if you did, it wouldn't be correct because the file probably isn't uncompressed, uncontainerized raw video.

There are a few ways forward here:
  • Install AviSynth+, build FFMS2 or LSMASHSource filters yourself, then give the AviSynth script opening your input file to x264.
  • Install AviSynth+, build FFMS2 or LSMASHSource filters yourself, build avs2yuv, and then use avs2yuv to pipe into x264.
  • Open the input file in FFmpeg and pipe out to x264.
  • Install FFmpeg and FFMS2 from Homebrew, build x264 yourself, making sure that it's enabling FFMS2 and/or LAVF support.
  • Don't use x264's CLI, use FFmpeg the entire way through and select libx264 as the encoder.
qyot27 is offline   Reply With Quote
Old 22nd August 2024, 17:43   #5  |  Link
PSimpso
Registered User
 
Join Date: Jul 2024
Posts: 4
Thank you for the very detailed response! This is definitely more complex than I realized it would be. I'll have to dig into these and see how deep I'm willing/able to go here as I'm more of an occasional user of x264.

If I use your last solution - using FFmpeg the entire way through - am I limited in the commands I can use? I'm creating Blu-ray compatible files using "--bluray-compat" and some other commands and I was told somewhere that FFmpeg doesn't support all of the necessary commands.
PSimpso is offline   Reply With Quote
Old 22nd August 2024, 21:17   #6  |  Link
qyot27
...?
 
qyot27's Avatar
 
Join Date: Nov 2005
Location: Florida
Posts: 1,445
The -x264-params option in FFmpeg is intended to pass any option that they don't have ready suboptions for, but there might still be options that only exist in the x264 CLI and not the library. That doesn't mean that the library can't do it, there just isn't a one-stop option to enable it. I've never needed to try doing Blu-ray compatible encodes, so I don't really know what changes under the hood when that option gets set.

But let's see:
Code:
x264 --bitrate XXXXX --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 --pass 2 -o out.264 input.file
bitrate is controlled through a general FFmpeg option: b:v for video bitrate, b:a (or ab) for audio bitrate. Same for however two-pass options are supposed to work.

preset, tune, bluray-compat, and level all have direct options for the libx264 encoder in FFmpeg (see the readout of the libx264 help below).

vbv-maxrate, vbv-bufsize, keyint, open-gop, and slices might require using x264-params to set them. Or maybe x264opts, although I'm not 100% clear on what the difference is.

FFmpeg itself should properly handle detecting and setting primaries, transfer characteristics, matrix, and SAR. There would be general FFmpeg options for adjusting those, or you could install AviSynth+, build one of the source filters, and then tweak those properties inside the script so that you can ensure that FFmpeg reads/sets them correctly. The evermeet.cx FFmpeg binaries are built with AviSynth support enabled, although those are Intel-only (the build command is provided, though, so you could try to redo it on ARM yourself; I doubt Rosetta is capable of mixing ARM-native libraries with Intel-native applications in the same process).

ffmpeg -h encoder=libx264:
Code:
libx264 AVOptions:
  -preset            <string>     E..V....... Set the encoding preset (cf. x264 --fullhelp) (default "medium")
  -tune              <string>     E..V....... Tune the encoding params (cf. x264 --fullhelp)
  -profile           <string>     E..V....... Set profile restrictions (cf. x264 --fullhelp)
  -fastfirstpass     <boolean>    E..V....... Use fast settings when encoding first pass (default true)
  -level             <string>     E..V....... Specify level (as defined by Annex A)
  -passlogfile       <string>     E..V....... Filename for 2 pass stats
  -wpredp            <string>     E..V....... Weighted prediction for P-frames
  -a53cc             <boolean>    E..V....... Use A53 Closed Captions (if available) (default true)
  -x264opts          <string>     E..V....... x264 options
  -crf               <float>      E..V....... Select the quality for constant quality mode (from -1 to FLT_MAX) (default -1)
  -crf_max           <float>      E..V....... In CRF mode, prevents VBV from lowering quality beyond this point. (from -1 to FLT_MAX) (default -1)
  -qp                <int>        E..V....... Constant quantization parameter rate control method (from -1 to INT_MAX) (default -1)
  -aq-mode           <int>        E..V....... AQ method (from -1 to INT_MAX) (default -1)
     none            0            E..V.......
     variance        1            E..V....... Variance AQ (complexity mask)
     autovariance    2            E..V....... Auto-variance AQ
     autovariance-biased 3            E..V....... Auto-variance AQ with bias to dark scenes
  -aq-strength       <float>      E..V....... AQ strength. Reduces blocking and blurring in flat and textured areas. (from -1 to FLT_MAX) (default -1)
  -psy               <boolean>    E..V....... Use psychovisual optimizations. (default auto)
  -psy-rd            <string>     E..V....... Strength of psychovisual optimization, in <psy-rd>:<psy-trellis> format.
  -rc-lookahead      <int>        E..V....... Number of frames to look ahead for frametype and ratecontrol (from -1 to INT_MAX) (default -1)
  -weightb           <boolean>    E..V....... Weighted prediction for B-frames. (default auto)
  -weightp           <int>        E..V....... Weighted prediction analysis method. (from -1 to INT_MAX) (default -1)
     none            0            E..V.......
     simple          1            E..V.......
     smart           2            E..V.......
  -ssim              <boolean>    E..V....... Calculate and print SSIM stats. (default auto)
  -intra-refresh     <boolean>    E..V....... Use Periodic Intra Refresh instead of IDR frames. (default auto)
  -bluray-compat     <boolean>    E..V....... Bluray compatibility workarounds. (default auto)
  -b-bias            <int>        E..V....... Influences how often B-frames are used (from INT_MIN to INT_MAX) (default INT_MIN)
  -b-pyramid         <int>        E..V....... Keep some B-frames as references. (from -1 to INT_MAX) (default -1)
     none            0            E..V.......
     strict          1            E..V....... Strictly hierarchical pyramid
     normal          2            E..V....... Non-strict (not Blu-ray compatible)
  -mixed-refs        <boolean>    E..V....... One reference per partition, as opposed to one reference per macroblock (default auto)
  -8x8dct            <boolean>    E..V....... High profile 8x8 transform. (default auto)
  -fast-pskip        <boolean>    E..V....... (default auto)
  -aud               <boolean>    E..V....... Use access unit delimiters. (default auto)
  -mbtree            <boolean>    E..V....... Use macroblock tree ratecontrol. (default auto)
  -deblock           <string>     E..V....... Loop filter parameters, in <alpha:beta> form.
  -cplxblur          <float>      E..V....... Reduce fluctuations in QP (before curve compression) (from -1 to FLT_MAX) (default -1)
  -partitions        <string>     E..V....... A comma-separated list of partitions to consider. Possible values: p8x8, p4x4, b8x8, i8x8, i4x4, none, all
  -direct-pred       <int>        E..V....... Direct MV prediction mode (from -1 to INT_MAX) (default -1)
     none            0            E..V.......
     spatial         1            E..V.......
     temporal        2            E..V.......
     auto            3            E..V.......
  -slice-max-size    <int>        E..V....... Limit the size of each slice in bytes (from -1 to INT_MAX) (default -1)
  -stats             <string>     E..V....... Filename for 2 pass stats
  -nal-hrd           <int>        E..V....... Signal HRD information (requires vbv-bufsize; cbr not allowed in .mp4) (from -1 to INT_MAX) (default -1)
     none            0            E..V.......
     vbr             1            E..V.......
     cbr             2            E..V.......
  -avcintra-class    <int>        E..V....... AVC-Intra class 50/100/200/300/480 (from -1 to 480) (default -1)
  -me_method         <int>        E..V....... Set motion estimation method (from -1 to 4) (default -1)
     dia             0            E..V.......
     hex             1            E..V.......
     umh             2            E..V.......
     esa             3            E..V.......
     tesa            4            E..V.......
  -motion-est        <int>        E..V....... Set motion estimation method (from -1 to 4) (default -1)
     dia             0            E..V.......
     hex             1            E..V.......
     umh             2            E..V.......
     esa             3            E..V.......
     tesa            4            E..V.......
  -forced-idr        <boolean>    E..V....... If forcing keyframes, force them as IDR frames. (default false)
  -coder             <int>        E..V....... Coder type (from -1 to 1) (default default)
     default         -1           E..V.......
     cavlc           0            E..V.......
     cabac           1            E..V.......
     vlc             0            E..V.......
     ac              1            E..V.......
  -b_strategy        <int>        E..V....... Strategy to choose between I/P/B-frames (from -1 to 2) (default -1)
  -chromaoffset      <int>        E..V....... QP difference between chroma and luma (from INT_MIN to INT_MAX) (default 0)
  -sc_threshold      <int>        E..V....... Scene change threshold (from INT_MIN to INT_MAX) (default -1)
  -noise_reduction   <int>        E..V....... Noise reduction (from INT_MIN to INT_MAX) (default -1)
  -udu_sei           <boolean>    E..V....... Use user data unregistered SEI if available (default false)
  -x264-params       <dictionary> E..V....... Override the x264 configuration using a :-separated list of key=value parameters
  -mb_info           <boolean>    E..V....... Set mb_info data through AVSideData, only useful when used from the API (default false)
qyot27 is offline   Reply With Quote
Old 3rd September 2024, 23:21   #7  |  Link
PSimpso
Registered User
 
Join Date: Jul 2024
Posts: 4
Thanks for the in-depth response! I'll certainly come back to this when I'm ready to take a deeper dive into x264, Avisynth and FFmpeg.
PSimpso is offline   Reply With Quote
Reply

Tags
apple, mac

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 22:47.


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