3

I'm working on an application (c++/Linux) that uses the ffmpeg 3.4 libraries to do video encoding. Since version 3.3 hardware acceleration is enabled by default if the platform supports it. The graphics card in my dev system has hardware acceleration support, but the tool also has to run on older systems that do not. How can i configure ffmpeg to disable hardware acceleration for video encoding? There is a ton of info about enabling, but i just cant find how to disable it.

ps. There already is a similar question: How to turn off ffmpeg hardware acceleration but its a year old and unfortunately still unanswered.

MadMarky
  • 265
  • 2
  • 10
  • 1
    If you specify a particular encoder it should be "either software or hardware" based on the name I believe... – rogerdpack Feb 13 '18 at 17:04

1 Answers1

2

I can't find any reference so I think the support for hardware acceleration is enabled by default (there's a configure option to disable it, --disable-hwaccels). You still need to code to make it happen. The wiki covers command-line usage as far as I can see.

Decoding (internal):

  • for the internal HW decoders you would have to follow the example in doc/examples/hw_decode.c

Decoding / Encoding (external):

  • you must specifically choose a hardware accelerated encoder/decoder using the avcodec_find_decoder_by_name / avcodec_find_encoder_by_name functions
  • the naming convention for these encoders is generally codec_api (eg: h264_nvenc) and they have specific options based on the SDK they use.
  • there's no software fallback so you must check device capabilities beforehand.
aergistal
  • 29,947
  • 5
  • 70
  • 92
  • `avcodec_find_encoder` returns a registered encoder for a given CodecID (eg. `AV_CODEC_ID_H264`), which in this case is `h264_nvenc` since the code is built on a system with a pretty recent nvidia graphics card. I now did a workaround using `avcodec_find_encoder_by_name` to first look for some specific registered software encoders (eg. libx264) before eventually reverting to `avcodec_find_encoder' if nothing was found. Thanks for your answer. – MadMarky Feb 13 '18 at 14:58
  • @MadMarky so it chooses `h264_nvenc` even if `libx264` is enabled? – aergistal Feb 13 '18 at 15:18
  • apparently since version 3.3 ffmpeg always chooses hardware acceleration over sofware encoders. – MadMarky Feb 13 '18 at 15:29
  • @MadMarky a new API for iterating over codecs has been added recently but [seems disputed](http://ffmpeg.org/pipermail/ffmpeg-devel/2018-February/225046.html). So currently the git version is different from 3.4. You're better off with `avcodec_find_encoder_by_name`. – aergistal Feb 13 '18 at 16:10