6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

自分のApple製ハードウェアが対応してるエンコーダーの種類を調べる

Posted at

VideoToolboxを弄り回しており、流れてくる入力ストリームをVTCompressionSessionFrameEncoderにぶち込み、H.264を得たい。

一応その流れはできたが、とんでもない勢いでVTEncoderXPCServiceがブン回りはじめる。

これ、HWエンコーダー使われてるのかな・・・それ以前に積んでるよね?よね?

というのを調べるべく、VideoToolboxのAPIを叩いて確認することになった。

VTCopyVideoEncoderList(::)APIだ。

よし調べたろ! という段階でつまづいた。

VideoToolboxは低レベルAPI系なので、ObjCでいうArrayRefなどのRef系を多様する。Swiftでどうやってやんねんそれ・・・というわけでその問題を解消するべく、自分のMacが対応しているエンコーダーの一覧を出すものを書いてみた。

Playgroundでも動くので試してみていただきたい。

import Cocoa
import VideoToolbox

let list = UnsafeMutablePointer<CFArray?>.allocate(capacity: 1)
VTCopyVideoEncoderList(nil, list)
print(list.pointee)

うちのでは以下のような結果になった。

お、Apple HEVC (HW)はいってるやん!!(当たり前)。いつか利用したい。

もしHEVC(SW)しかない人はそろそろ買い直しも検討にいれてみてはどうか。

参考URL: (あっぷるちゃんねる)https://applech2.com/archives/20170626-hevc-hw-sw-acceleration-mac.html

MacBook Pro (15-inch, 2017)では以下のような結果になる

Optional(<__NSArrayM 0x7fa8c7426650>(
    {
        CodecName = "24-bit RGB";
        CodecType = 24;
        DisplayName = "24-bit RGB";
        EncoderID = "com.apple.videotoolbox.videoencoder.24rgb";
        EncoderName = "Apple 24-bit RGB";
    },
    {
        CodecName = "32-bit ARGB";
        CodecType = 32;
        DisplayName = "32-bit ARGB";
        EncoderID = "com.apple.videotoolbox.videoencoder.32argb";
        EncoderName = "Apple 32-bit ARGB";
    },
    {
        CodecName = "Apple ProRes 422";
        CodecType = 1634755438;
        DisplayName = "Apple ProRes 422";
        EncoderID = "com.apple.videotoolbox.videoencoder.prores422";
        EncoderName = "Apple ProRes 422";
    },
    {
        CodecName = "Apple ProRes 422 HQ";
        CodecType = 1634755432;
        DisplayName = "Apple ProRes 422 HQ";
        EncoderID = "com.apple.videotoolbox.videoencoder.prores422hq";
        EncoderName = "Apple ProRes 422 HQ";
    },
    {
        CodecName = "Apple ProRes 422 LT";
        CodecType = 1634755443;
        DisplayName = "Apple ProRes 422 LT";
        EncoderID = "com.apple.videotoolbox.videoencoder.prores422lt";
        EncoderName = "Apple ProRes 422 LT";
    },
    {
        CodecName = "Apple ProRes 422 Proxy";
        CodecType = 1634755439;
        DisplayName = "Apple ProRes 422 Proxy";
        EncoderID = "com.apple.videotoolbox.videoencoder.prores422proxy";
        EncoderName = "Apple ProRes 422 Proxy";
    },
    {
        CodecName = "Apple ProRes 4444";
        CodecType = 1634743400;
        DisplayName = "Apple ProRes 4444";
        EncoderID = "com.apple.videotoolbox.videoencoder.prores4444";
        EncoderName = "Apple ProRes 4444";
    },
    {
        CodecName = "H.263";
        CodecType = 1748121139;
        DisplayName = "H.263";
        EncoderID = "com.apple.videotoolbox.videoencoder.h263";
        EncoderName = "Apple H.263";
    },
    {
        CodecName = "H.264";
        CodecType = 1635148593;
        DisplayName = "Apple H.264 (HW)";
        EncoderID = "com.apple.videotoolbox.videoencoder.h264.gva";
        EncoderName = "Apple H.264 (HW)";
    },
    {
        CodecName = "H.264";
        CodecType = 1635148593;
        DisplayName = "Apple H.264 (SW)";
        EncoderID = "com.apple.videotoolbox.videoencoder.h264";
        EncoderName = "Apple H.264 (SW)";
    },
    {
        CodecName = HEVC;
        CodecType = 1752589105;
        DisplayName = "Apple HEVC (HW)";
        EncoderID = "com.apple.videotoolbox.videoencoder.hevc.gva";
        EncoderName = "Apple HEVC (HW)";
    },
    {
        CodecName = HEVC;
        CodecType = 1752589105;
        DisplayName = "Apple HEVC (SW)";
        EncoderID = "com.apple.videotoolbox.videoencoder.hevc.vcp";
        EncoderName = "Apple HEVC (SW)";
    },
    {
        CodecName = JPEG;
        CodecType = 1785750887;
        DisplayName = JPEG;
        EncoderID = "com.apple.videotoolbox.videoencoder.jpeg";
        EncoderName = "Apple JPEG";
    }
))

6
5
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?