0

I've compiled the most recent snapshot of ffmpeg with vaapi enabled

$ ffmpeg -hwaccesls
ffmpeg version N-98129-g0b182ff Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) 20160609
  configuration: --disable-debug --disable-doc --disable-ffplay --enable-shared --enable-avresample --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-gpl --enable-libass --enable-fontconfig --enable-libfreetype --enable-libvidstab --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxvid --enable-libx264 --enable-nonfree --enable-openssl --enable-libfdk_aac --enable-postproc --enable-small --enable-version3 --enable-libzmq --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-libopenjpeg --enable-libkvazaar --enable-libaom --extra-libs=-lpthread --enable-libsrt --enable-vaapi --extra-cflags=-I/opt/ffmpeg/include --extra-ldflags=-L/opt/ffmpeg/lib
  libavutil      56. 54.100 / 56. 54.100
  libavcodec     58. 92.100 / 58. 92.100
  libavformat    58. 46.101 / 58. 46.101
  libavdevice    58. 11.100 / 58. 11.100
  libavfilter     7. 86.100 /  7. 86.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
Hardware acceleration methods:
vaapi

I know that vaapi is working because I can use it for hardware decoding and encoding of h264 videos. I can see some vaapi filters as well

$ ffmpeg -filters | grep vaapi
 ... deinterlace_vaapi V->V       (null)
 ... denoise_vaapi     V->V       (null)
 ... procamp_vaapi     V->V       (null)
 ... scale_vaapi       V->V       (null)
 ... sharpness_vaapi   V->V       (null)

However, I notice that this list is missing the filter that I'm specifically looking for, namely , transpose_vaapi. If you look in the libavfilter source code you'll see the following

This shows the transpose_vaapi filter defined in the allfilters.c file https://github.com/FFmpeg/FFmpeg/blob/master/libavfilter/allfilters.c#L414

This shows the transpose_vaapi filter source code https://github.com/FFmpeg/FFmpeg/blob/master/libavfilter/vf_transpose_vaapi.c

If the filter is defined in source code, it's defined in allfilters.c, and I've compiled ffmpeg from this source with vaapi enabled, why can I not use this filter with ffmpeg?

$ ffmpeg -y -hide_banner -nostats -loglevel error \
    -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi \
    -i ./test_video.mp4 \
    -vf 'format=nv12,transpose_vaapi=2' \
    -c:v h264_vaapi \
    /tmp/rotated_video.mp4
[AVFilterGraph @ 0xf14000] No such filter: 'transpose_vaapi'
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument

EDIT -

Looking through the source code for vf_transpose_vaapi.c I see the following logic

    if (!pipeline_caps.rotation_flags) {
        av_log(avctx, AV_LOG_ERROR, "VAAPI driver doesn't support transpose\n");
        return AVERROR(EINVAL);
    }

that's inside of the transpose_vaapi_build_filter_params function which is part of the filter initialization process. I guess it's possible that, if that call failed, the filter would fail to be built and it would not be registered as a valid filter? This seems like something that would happen at runtime when I attempt to run the filter rather than something that would happen at compile time when setting which filters are defined.

John Allard
  • 3,564
  • 5
  • 23
  • 42

1 Answers1

1

The filter also depends on a build time check for VAProcFilterParameterBufferHDRToneMapping, as seen in ./configure

tonemap_vaapi_filter_deps="vaapi VAProcFilterParameterBufferHDRToneMapping"
Gyan
  • 85,394
  • 9
  • 169
  • 201
  • Can you help me determine how that dependency is checked? The only place I see that string is in `config` and in the source file itself, how does configure go about checking that the `VAProcFilterParameterBufferHDRToneMapping` value is valid before trying to include the `tonemap_vaapi_filter` as an available filter? – John Allard Jun 13 '20 at 07:46
  • 1
    It compiles `#include "va/va.h" #include "va/va_vpp.h" int main(void) { VAProcFilterParameterBufferHDRToneMapping v; return 0; }` and checks if object was generated successfully. – Gyan Jun 13 '20 at 07:57
  • Thank you so much! I really appreciate your help, that explains enough for me to figure out what I need to change going forward. – John Allard Jun 13 '20 at 20:29