[Libav-user] Example hw_decode.c runs with error on MacOS

Richard Hu richardyusen at gmail.com
Wed Apr 10 13:37:09 EEST 2024


I'm trying to figure out how hardware video decoding works on MacOS, but I
could not get the example program (doc/examples/hw_decode.c) to work. When
I run it with any video file, it complains "Failed to get HW surface
format". The full output is uploaded here: https://pastebin.com/Tz1VkYgq

It seems like that the `hw_pix_fmt` found by `avcodec_get_hw_config` is set
to AV_PIX_FMT_VIDEOTOOLBOX, but AV_PIX_FMT_YUVJ420P is the only thing
available in the provided `pix_fmts` in `get_hw_format`, so the function
fails to get the desired HW surface format.

Curiously, when I replace the body of the `get_hw_format` function with a
simple `return AV_PIX_FMT_YUVJ420P`, the program appears to run without
errors (but produces an output mp4 file that cannot be opened for some
reason). I'm also not sure if the program actually used HW acceleration in
this case, since it ran for 13 seconds with a 5 second video as input.

My MacOS version is 14.3 (23D56). I'm using FFMpeg 6.1.1 (the output of
`ffmpeg -report` can be viewed here: https://pastebin.com/MgVgE5CL ).

What's causing this problem? Any help would be appreciated!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20240410/fcab9b36/attachment.htm>

More information about the Libav-user mailing list