[Libav-user] Fwd: 971108 - ffmpeg doesn't use GPU

JP May jpm at smhk.com
Wed Jan 30 17:30:58 EET 2019


hamidi, there are definitely some problems getting it to use the hardware decoder. For us we have such a problem on iOS builds.

We have to use code something like this to be sure it finds a hardware decoder ...

#include <libavcodec/videotoolbox.h>
static enum AVPixelFormat find_pixel_format(struct AVCodecContext *s, const enum AVPixelFormat *fmt) {
    while (*fmt != AV_PIX_FMT_NONE) {
        if (*fmt == AV_PIX_FMT_VIDEOTOOLBOX) {
            if (s->hwaccel_context == NULL) {
                int result = av_videotoolbox_default_init(s);
                if (result < 0) {
                	printf("       the 'SPS/PPS problem' has happened.\n");
                	printf("       you are NOT getting hardware decoding on this stream.\n");
                    return s->pix_fmt;
                }
                else {
                	printf("       the test was OK....\n");
                }
            }
            return *fmt;
        }
        ++fmt;
    }
    return s->pix_fmt;
}


the problem seems to relate to finding the SPS/PPS information on a variety of sources
see,

https://stackoverflow.com/q/25787347/294884 <https://stackoverflow.com/q/25787347/294884>

a couple yrs ago there was a patch on the 264 problem (which I think was not incorporated..)

https://ffmpeg.org/pipermail/ffmpeg-devel/2016-June/194842.html <https://ffmpeg.org/pipermail/ffmpeg-devel/2016-June/194842.html>

we really have not been able to solve the issue in the 265 case.

If this info is relevant to your case, I hope it helps …



> On Jan 30, 2019, at 7:58 AM, hamidi <hamidi at gmail.com> wrote:
> 
> I got the latest version binaries of ffmpeg from here <https://ffmpeg.zeranoe.com/builds/>. When I examine CPU and GPU usages when I play a video by its ffplay, I see that GPU is used during play. Not much using of CPU also indicates it. But when I get the latest version sources from the original site, I can't use GPU. ….





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20190130/88829377/attachment.html>


More information about the Libav-user mailing list