[FFmpeg-user] hw_decode.c on osx?

su.00048 at cherry.org su.00048 at cherry.org
Sat Apr 18 07:14:37 EEST 2020

on 2020.04.17 09:02 -0400, ffmpeg-user at ffmpeg.org wrote:

> Hi,
> > i have ffmpeg building successfully on osx (10.14.6; xcode 11.3.1),
> > and am using the generated libraries in a personal video project i'm
> > working on.  now i'm ready to start thinking about implementing hardware
> > decoding ...  i tried adapting some of the code from hw_decode.c, but 
> > ran into runtime errors.  thinking that it was my code that was at
> > fault, i then compiled hw_decode by itself, but i get the same errors
> > even there.  is anyone aware of hw_decode.c not working on osx?
> The example's working fine for me. (I think... I don't know what kind of
> format videotoolbox decodes to but if I squint and tilt my head a little the
> hex dump looks like it might be raw pixel buffer bytes of some sort lol)

thanks ted for your reply.

videotoolbox decodes to CMSampleBuffer, which is CoreMedia's generic buffer
wrapper class.  a couple levels down, it's probably a CVPixelBuffer.  if it's
working for you, i'd be curious to know what hardware and what os version
you're running on, and what type of file you're feeding to hw_decode.

> Did you read the readme in the folder the example is in? I'm wondering when
> you say you compiled hw_decode by itself you literally mean just the compile
> step using cc.

originally, i just took some of the code from hw_decode.c and adapted it for
use within my app.  when i got the errors, my first thought was that i was
doing something wrong, so i wanted to isolate that by just running the
executable produced by compiling hw_decode.c as a standalone program from the
commandline.  i've built that a few different ways now (to be clear, these are
successful compilations producing an executable program), but they all exhibit
the same runtime errors (shown in my original message).  as far as build
methods, here's what i've tried so far:

1) build the hw_decode executable (a separate target in xcode), linking against
the ffmpeg libraries built locally in an earlier project step.  i know these
libraries are generally functional, because i'm linking against them in my main
application, and it works as expected (except for the hardware decoding).

2) build the executable linking against the precompiled libraries downloaded
from https://ffmpeg.zeranoe.com/builds/.

3) build the examples "in-tree" (method 2 from the README you suggested).
this again will link against the locally built libraries, similar to (1) above.

here are some (i am assuming pertinent) excerpts from the output of the
configure stage during these builds:

> External libraries:
> appkit                  coreimage               zlib
> avfoundation            iconv
> bzlib                   securetransport
> External libraries providing hardware acceleration:
> audiotoolbox            videotoolbox
> Libraries:
> avcodec                 avformat                swscale
> avdevice                avutil
> avfilter                swresample
> ...
> Enabled hwaccels:
> h263_videotoolbox       hevc_videotoolbox       mpeg2_videotoolbox
> h264_videotoolbox       mpeg1_videotoolbox      mpeg4_videotoolbox

am i incorrect in assuming that one should be able to build the ffmpeg libs on
osx with hardware decoding support for h264 and hevc?  the hwaccel intro wiki
page seems to suggest it should work ...


More information about the ffmpeg-user mailing list