VideoToolBox not working on Apple Silicon M1

HandBrake for Mac support
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
pdewost
Posts: 6
Joined: Mon Dec 07, 2020 1:58 pm

VideoToolBox not working on Apple Silicon M1

Post by pdewost »

HandBrake 1.4 beta on Apple Silicon M1 - VideoToolbox fails to load:
Using the M1 GPUs for speed testing fails
x264 encoding works

Select a video file to encode / transcode and select VideoToolBox H264 or H265 as the encoding method:

HandBrake will exit the task in any case
- H264 VTB
- H265 VTB
average bitrate or Constant Quality

Encoding with the CPU using x264 as the encoder works on the other hand at approx 25 fps

1.4.0-beta 1:

macOS Big Sur 11.0.1:

HandBrake Activity Log ***required*** (see How-to get an activity log)

Code: Select all

[11:12:38] Compile-time hardening features are enabled
[11:12:38] hb_init: starting libhb thread
[11:12:38] macgui: fr.handbrake.HandBrakeXPCService scanning specifically for title: 1
[11:12:38] CPU: 
[11:12:38]  - logical processor count: 8
[11:12:38] hb_scan: path=/Volumes/PhilSSD1To/GOPR0875-pdewost_3.00x_3840x2160_alq-8.mp4, title_index=1
udfread ERROR: ECMA 167 Volume Recognition failed
disc.c:323: failed opening UDF image /Volumes/PhilSSD1To/GOPR0875-pdewost_3.00x_3840x2160_alq-8.mp4
disc.c:424: error opening file BDMV/index.bdmv
disc.c:424: error opening file BDMV/BACKUP/index.bdmv
bluray.c:2585: nav_get_title_list(/Volumes/PhilSSD1To/GOPR0875-pdewost_3.00x_3840x2160_alq-8.mp4/) failed
[11:12:38] bd: not a bd - trying as a stream/file instead
libdvdnav: Using dvdnav version 6.0.1
libdvdread: Encrypted DVD support unavailable.
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.BUP failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: failed to read VIDEO_TS.IFO
[11:12:38] dvd: not a dvd - trying as a stream/file instead
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Volumes/PhilSSD1To/GOPR0875-pdewost_3.00x_3840x2160_alq-8.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.20.100
  Duration: 00:20:10.41, start: 0.016000, bitrate: 198749 kb/s
    Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 3840x2160, 198609 kb/s, 59.94 fps, 59.94 tbr, 60k tbn, 119.88 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
[11:12:38] scan: decoding previews for title 1
[11:12:38] scan: audio 0x1: aac, rate=48000Hz, bitrate=128506 Unknown (AAC LC) (2.0 ch) (128 kbps)
[11:12:39] scan: 10 previews, 3840x2160, 59.940 fps, autocrop = 0/0/0/0, aspect 16:9, PAR 1:1
[11:12:39] libhb: scan thread found 1 valid title(s)
[11:12:39] macgui: fr.handbrake.HandBrakeXPCService scan done
[11:12:39] Starting work at: Mon Dec  7 11:12:39 2020

[11:12:39] 1 job(s) to process
[11:12:39] Starting Task: Encoding Pass
[11:12:39] Skipping vfr filter
[11:12:39] Skipping crop/scale filter
[11:12:39] macgui: fr.handbrake.HandBrakeXPCService started encoding GOPR0875-pdewost_3.00x_3840x2160_alq-8 1abr16000.mp4
[11:12:39] macgui: fr.handbrake.HandBrakeXPCService with preset Fast 1080p30 (Modifié)
[11:12:39] work: only 1 chapter, disabling chapter markers
[11:12:39] job configuration:
[11:12:39]  * source
[11:12:39]    + /Volumes/PhilSSD1To/GOPR0875-pdewost_3.00x_3840x2160_alq-8.mp4
[11:12:39]    + title 1, chapter(s) 1 to 1
[11:12:39]    + container: mov,mp4,m4a,3gp,3g2,mj2
[11:12:39]    + data rate: 198749 kbps
[11:12:39]  * destination
[11:12:39]    + /Volumes/PhilSSD1To/GOPR0875-pdewost_3.00x_3840x2160_alq-8 1abr16000.mp4
[11:12:39]    + container: MPEG-4 (libavformat)
[11:12:39]      + align initial A/V stream timestamps
[11:12:39]  * video track
[11:12:39]    + decoder: h264
[11:12:39]      + bitrate 198609 kbps
[11:12:39]    + filter
[11:12:39]      + Decomb (mode=7)
[11:12:39]    + Output geometry
[11:12:39]      + storage dimensions: 3840 x 2160
[11:12:39]      + pixel aspect ratio: 1 : 1
[11:12:39]      + display dimensions: 3840 x 2160
[11:12:39]    + encoder: H.264 (libavcodec)
[11:12:39]      + preset:  default
[11:12:39]      + profile: main
[11:12:39]      + level:   4.0
[11:12:39]      + bitrate: 16000 kbps, pass: 0
[11:12:39]      + color profile: 1-1-1
[11:12:39]  * audio track 1
[11:12:39]    + decoder: Unknown (AAC LC) (2.0 ch) (128 kbps) (track 1, id 0x1)
[11:12:39]      + bitrate: 128 kbps, samplerate: 48000 Hz
[11:12:39]    + AAC Passthru
[11:12:39] sync: expecting 72552 video frames
[11:12:39] encavcodecInit: H.264 (VideoToolbox)
[11:12:39] encavcodec: encoding with stored aspect 1/1
[h264_videotoolbox @ 0x12102d400] Error: cannot prepare encoder: -12902
[11:12:39] encavcodecInit: avcodec_open failed
[11:12:39] Failure to initialise thread 'FFMPEG encoder (libavcodec)'
[11:12:39] decomb: deinterlaced 0 | blended 0 | unfiltered 0 | total 0
[11:12:39] aac-decoder done: 0 frames, 0 decoder errors
[11:12:39] h264-decoder done: 0 frames, 0 decoder errors
[11:12:39] sync: got 0 frames, 72552 expected
[11:12:39] Finished work at: Mon Dec  7 11:12:39 2020

[11:12:39] libhb: work result = 3
[11:12:40] macgui: fr.handbrake.HandBrakeXPCService work failed
[11:12:40] macgui: fr.handbrake.HandBrakeXPCService scanning specifically for title: 1
[11:12:40] CPU: 
[11:12:40]  - logical processor count: 8
[11:12:40] hb_scan: path=/Volumes/PhilSSD1To/GOPR0875-pdewost_3.00x_3840x2160_alq-8.mp4, title_index=1
udfread ERROR: ECMA 167 Volume Recognition failed
disc.c:323: failed opening UDF image /Volumes/PhilSSD1To/GOPR0875-pdewost_3.00x_3840x2160_alq-8.mp4
disc.c:424: error opening file BDMV/index.bdmv
disc.c:424: error opening file BDMV/BACKUP/index.bdmv
bluray.c:2585: nav_get_title_list(/Volumes/PhilSSD1To/GOPR0875-pdewost_3.00x_3840x2160_alq-8.mp4/) failed
[11:12:40] bd: not a bd - trying as a stream/file instead
libdvdnav: Using dvdnav version 6.0.1
libdvdread: Encrypted DVD support unavailable.
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.BUP failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: failed to read VIDEO_TS.IFO
[11:12:40] dvd: not a dvd - trying as a stream/file instead
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Volumes/PhilSSD1To/GOPR0875-pdewost_3.00x_3840x2160_alq-8.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.20.100
  Duration: 00:20:10.41, start: 0.016000, bitrate: 198749 kb/s
    Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 3840x2160, 198609 kb/s, 59.94 fps, 59.94 tbr, 60k tbn, 119.88 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
[11:12:40] scan: decoding previews for title 1
[11:12:40] scan: audio 0x1: aac, rate=48000Hz, bitrate=128506 Unknown (AAC LC) (2.0 ch) (128 kbps)
[11:12:40] scan: 10 previews, 3840x2160, 59.940 fps, autocrop = 0/0/0/0, aspect 16:9, PAR 1:1
[11:12:40] libhb: scan thread found 1 valid title(s)
[11:12:40] macgui: fr.handbrake.HandBrakeXPCService scan done
[11:12:40] Starting work at: Mon Dec  7 11:12:40 2020

[11:12:40] 1 job(s) to process
[11:12:40] macgui: fr.handbrake.HandBrakeXPCService started encoding GOPR0875-pdewost_3.00x_3840x2160_alq-8 1cq22.00.mp4
[11:12:40] macgui: fr.handbrake.HandBrakeXPCService with preset Fast 1080p30 (Modifié)
[11:12:40] Starting Task: Encoding Pass
[11:12:40] Skipping vfr filter
[11:12:40] Skipping crop/scale filter
[11:12:40] work: only 1 chapter, disabling chapter markers
[11:12:40] job configuration:
[11:12:40]  * source
[11:12:40]    + /Volumes/PhilSSD1To/GOPR0875-pdewost_3.00x_3840x2160_alq-8.mp4
[11:12:40]    + title 1, chapter(s) 1 to 1
[11:12:40]    + container: mov,mp4,m4a,3gp,3g2,mj2
[11:12:40]    + data rate: 198749 kbps
[11:12:40]  * destination
[11:12:40]    + /Volumes/PhilSSD1To/GOPR0875-pdewost_3.00x_3840x2160_alq-8 1cq22.00.mp4
[11:12:40]    + container: MPEG-4 (libavformat)
[11:12:40]      + align initial A/V stream timestamps
[11:12:40]  * video track
[11:12:40]    + decoder: h264
[11:12:40]      + bitrate 198609 kbps
[11:12:40]    + filter
[11:12:40]      + Decomb (mode=7)
[11:12:40]    + Output geometry
[11:12:40]      + storage dimensions: 3840 x 2160
[11:12:40]      + pixel aspect ratio: 1 : 1
[11:12:40]      + display dimensions: 3840 x 2160
[11:12:40]    + encoder: H.264 (libavcodec)
[11:12:40]      + preset:  default
[11:12:40]      + profile: main
[11:12:40]      + level:   4.0
[11:12:40]      + quality: 22.00 (CQ)
[11:12:40]      + color profile: 1-1-1
[11:12:40]  * audio track 1
[11:12:40]    + decoder: Unknown (AAC LC) (2.0 ch) (128 kbps) (track 1, id 0x1)
[11:12:40]      + bitrate: 128 kbps, samplerate: 48000 Hz
[11:12:40]    + AAC Passthru
[11:12:40] sync: expecting 72552 video frames
[11:12:40] encavcodecInit: H.264 (VideoToolbox)
[11:12:40] encavcodec: encoding at constant quality 22
[11:12:40] encavcodec: encoding with stored aspect 1/1
[h264_videotoolbox @ 0x12086de00] Error: cannot prepare encoder: -12902
[11:12:40] encavcodecInit: avcodec_open failed
[11:12:40] Failure to initialise thread 'FFMPEG encoder (libavcodec)'
[11:12:40] Failure to initialise thread 'FFMPEG encoder (libavcodec)'
[11:12:40] decomb: deinterlaced 0 | blended 0 | unfiltered 0 | total 0
[11:12:40] aac-decoder done: 0 frames, 0 decoder errors
[11:12:40] h264-decoder done: 0 frames, 0 decoder errors
[11:12:40] sync: got 0 frames, 72552 expected
[11:12:41] Finished work at: Mon Dec  7 11:12:41 2020

[11:12:41] libhb: work result = 3
[11:12:41] macgui: Queue Done, there are no more pending encodes
[11:12:41] macgui: fr.handbrake.HandBrakeXPCService work failed
Deleted User 11865

Re: VideoToolBox not working on Apple Silicon M1

Post by Deleted User 11865 »

You can't encode 2160p at level 4.0, which would explain why the encoder fails to initialize somewhere.
pdewost
Posts: 6
Joined: Mon Dec 07, 2020 1:58 pm

Re: VideoToolBox not working on Apple Silicon M1

Post by pdewost »

Thx @Rodeo : what level shall I use then ?

And BTW, x264 accepts level 4 on 4K, while x265 refuses. Maybe you want to add warnings in the GUI when a user attempts to encode with the wrong level, and while we are at it, provide a minimal set of explanations about levels.

Regards

Code: Select all

x265 [info]: HEVC encoder version 3.2.1+1-b5c86a64bbbe
x265 [info]: build info [Mac OS X][clang 12.0.0][32 bit] 8bit+10bit+12bit
x265 [info]: using cpu capabilities: NEON
x265 [error]: picture dimensions are out of range for specified level
[18:10:10] encx265: x265_encoder_open failed.
pdewost
Posts: 6
Joined: Mon Dec 07, 2020 1:58 pm

Re: VideoToolBox not working on Apple Silicon M1

Post by pdewost »

OK, found it on Wikipedia, shall be Level 5.1

Now, noticed also that in 1.4 beta there is a Constant Quality slider available even for VTB encoder (which was not the case in previous HandBrake releases and is supposedly not a feature of VTB — unless it is Apple Silicon Specific ?)

Is there a correspondence between RF and QC ? For instance, what QC shall I pick to match the RF 22 quality level ?

Should I want to go the average bitrate road instead, is there somewhere a table matching target bitrates, picture dimensions, fps, and quality levels ?

Thx
rollin_eng
Veteran User
Posts: 4840
Joined: Wed May 04, 2011 11:06 pm

Re: VideoToolBox not working on Apple Silicon M1

Post by rollin_eng »

As the M1 is so new I would expect things to be in flux until people test and tweak settings.

If you go ABR there are no rules about settings, it’s really up to you.
mduell
Veteran User
Posts: 8187
Joined: Sat Apr 21, 2007 8:54 pm

Re: VideoToolBox not working on Apple Silicon M1

Post by mduell »

H.264 requires level 5.1 for 4K30 and 5.2 for 4K60.
H.265 requires level 5 for 4K30 and 5.1 for 4K60.
Deleted User 11865

Re: VideoToolBox not working on Apple Silicon M1

Post by Deleted User 11865 »

Or you can set it to Auto.

x264 does indeed allow a non-compliant bitstream to be output, though it does warn about it in the log.
pdewost
Posts: 6
Joined: Mon Dec 07, 2020 1:58 pm

Re: VideoToolBox not working on Apple Silicon M1

Post by pdewost »

mduell wrote: Mon Dec 07, 2020 6:29 pm H.264 requires level 5.1 for 4K30 and 5.2 for 4K60.
H.265 requires level 5 for 4K30 and 5.1 for 4K60.
Thank you so much !
pdewost
Posts: 6
Joined: Mon Dec 07, 2020 1:58 pm

Re: VideoToolBox not working on Apple Silicon M1

Post by pdewost »

Rodeo wrote: Mon Dec 07, 2020 9:57 pm Or you can set it to Auto.

x264 does indeed allow a non-compliant bitstream to be output, though it does warn about it in the log.
Understood. Thank you !
pdewost
Posts: 6
Joined: Mon Dec 07, 2020 1:58 pm

Re: VideoToolBox not working on Apple Silicon M1

Post by pdewost »

rollin_eng wrote: Mon Dec 07, 2020 5:53 pm As the M1 is so new I would expect things to be in flux until people test and tweak settings.

If you go ABR there are no rules about settings, it’s really up to you.
Not sure what you refer to here : did your comment specifically relate to the new constant quality "QC" slider that is now available on VTB encoding ?
If so, I'd be happy to get other user's feedback about what QC value matches the "RF=22" level I use for x264 and x265 encoders.

Kind regards

@pdewost
devilmonkey98
New User
Posts: 2
Joined: Tue Feb 09, 2021 10:25 am

Re: VideoToolBox not working on Apple Silicon M1

Post by devilmonkey98 »

pdewost wrote: Tue Dec 08, 2020 11:19 am
rollin_eng wrote: Mon Dec 07, 2020 5:53 pm As the M1 is so new I would expect things to be in flux until people test and tweak settings.

If you go ABR there are no rules about settings, it’s really up to you.
Not sure what you refer to here : did your comment specifically relate to the new constant quality "QC" slider that is now available on VTB encoding ?
If so, I'd be happy to get other user's feedback about what QC value matches the "RF=22" level I use for x264 and x265 encoders.

Kind regards

@pdewost
I would also appreciate an equivalent RF - CQ value from users if this is possible? Thanks!
mduell
Veteran User
Posts: 8187
Joined: Sat Apr 21, 2007 8:54 pm

Re: VideoToolBox not working on Apple Silicon M1

Post by mduell »

There's no matching, they're different metrics for setting quality; specifically x264's CRF incorporates a psychovisual model to vary the QP target depending on the content. Even when they're the same _on average_ they may differ in behavior for low/high motion or low/high detail scenes.
Post Reply