[FFmpeg-user] Get Hardware Buffer from FFmpeg 4.0 + VideoToolBox

Bo Zhou bo.schwarzstein at gmail.com
Sat Aug 18 05:50:45 EEST 2018

Hi !

I'm using the FFmpeg 4.0.2 and successfully executed the example hw_decode
on Mac. And I could see the trace log

[h264 @ 0x7f97d9800000] Format videotoolbox_vld chosen by get_format().
[h264 @ 0x7f97d9800000] Format videotoolbox_vld requires hwaccel
[h264 @ 0x7f97d9800000] Reinit context to 1280x720, pix_fmt:

Which should mean that it's using videotoolbox_vld .

In the hw_decode.c file, we could find the following piece of code.

        if (frame->format == hw_pix_fmt) {
            /* retrieve data from GPU to CPU */
            if ((ret = av_hwframe_transfer_data(sw_frame, frame, 0)) < 0) {
                fprintf(stderr, "Error transferring the data to system
                goto fail;
            tmp_frame = sw_frame;
        } else
            tmp_frame = frame;

So I'd like to know is that possible to get the GPU buffer directly ? I
could see the frame->data[3] and frame->buf[0] has a pointer, but how
should I use them ? I just want to map the hardware buffer into OpenGL

Thank you very much.

More information about the ffmpeg-user mailing list