Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jasonmvp

macrumors 6502
Original poster
Jun 15, 2015
421
345
Northern VA
Hey folks -

This question is centered around the Apple Videotoolbox (VT) hardware encoders that MacOS provides an API to. Specifically around the h.264 hardware encoders as found on the various consumer-level CPUs and discrete AMD GPUs. Per my signature, my Mac Pro 7,1 has the single AMD Radeon Pro Vega II GPU in it. While running the latest (v 27.0.1) version of OBS Studio, I found that the VT h.264 Hardware Encoder is listed twice. In previous versions, it was only listed once.

In discussions with the OBS devs, they explained that between v. 26 and v. 27, they started indexing the encoders based on what the OS tells it. And on the Mac Pro specifically, the OS is showing two h.264 hardware encoders, not one. As proof, one of the devs whipped me up a simple C program that just indexes and pukes out the encoders available from the VT. The code is:

C:
#include <stdio.h>
#include <stdlib.h>

#include <CoreFoundation/CoreFoundation.h>
#include <VideoToolbox/VideoToolbox.h>
#include <VideoToolbox/VTVideoEncoderList.h>
#include <CoreMedia/CoreMedia.h>


int main() {
    CFArrayRef encoder_list;
    VTCopyVideoEncoderList(NULL, &encoder_list);
    CFIndex size = CFArrayGetCount(encoder_list);

    for (CFIndex i = 0; i < size; i++) {
        CFDictionaryRef encoder_dict = CFArrayGetValueAtIndex(encoder_list, i);

#define VT_PRINT(key, name) \
        CFStringRef name##_ref = CFDictionaryGetValue(encoder_dict, key); \
        CFIndex name##_len = CFStringGetLength(name##_ref);               \
        char *name = malloc(name##_len + 1);                              \
        memset(name, 0, name##_len + 1); \
        CFStringGetFileSystemRepresentation(name##_ref, name, name##_len);

        VT_PRINT(kVTVideoEncoderList_EncoderName, name);
        printf("Name: %s\n", name);
        VT_PRINT(kVTVideoEncoderList_DisplayName, dn);
        printf("Display Name: %s\n", dn);
        VT_PRINT(kVTVideoEncoderList_EncoderID, id);
        printf("Id: %s\n", id);

        printf("=========================\n");
    }

    CFRelease(encoder_list);

    exit(0);
}

When I run it on my Mac Pro, among the output is this:

Code:
Name: Apple H.264 (HW)
Display Name: Apple H.264 (HW)
Id: com.apple.videotoolbox.videoencoder.h264.gva.100000abc
=========================
Name: Apple H.264 (HW)
Display Name: Apple H.264 (HW)
Id: com.apple.videotoolbox.videoencoder.h264.gva

Two encoders, one with a strange name. Let's run it on my 2018-era Macbook Pro that has the consumer-level CPU with the iGPU as well as the discrete Radeon GPU in it:

Code:
Name: Apple H.264 (HW)
Display Name: Apple H.264 (HW)
Id: com.apple.videotoolbox.videoencoder.h264.gva

One encoder. And sure enough when I run OBS studio on either of these machines, I see two encoders on the Mac Pro, and one on the laptop.

My question is: why? What is it about the Pro that's causing VT to puke out two h.264 hardware encoders vs one? Any ideas?

Thanks.
 

casperes1996

macrumors 604
Jan 26, 2014
7,511
5,680
Horsens, Denmark
I don't know, but maybe this is a clue. My 2020 iMac with a Radeon Pro 5700XT and (of course) a T2 and Intel QuickSync also shows two h.264 (HW) but they're both just .gva, not .gva.100000abc
 

jasonmvp

macrumors 6502
Original poster
Jun 15, 2015
421
345
Northern VA
I don't know, but maybe this is a clue. My 2020 iMac with a Radeon Pro 5700XT and (of course) a T2 and Intel QuickSync also shows two h.264 (HW) but they're both just .gva, not .gva.100000abc
Thanks for responding with the data, and that is interesting. And further confusing.

Dammit, Apple! Label these resources better.
 

casperes1996

macrumors 604
Jan 26, 2014
7,511
5,680
Horsens, Denmark
… I wonder if that @ even works like that... I've seen others do it on MR but never actually done it myself

@h9826790
The other message was a copy so the name came as a link. Wonder if that might've made it not work before but this will. Considering how much time I spend on here I don't know how to forum, haha
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.