Opened 8 months ago

Closed 6 months ago

#10876 closed defect (fixed)

scale_vulkan filter does not accept an output format different than yuv420p

Reported by: bermond Owned by:
Priority: normal Component: avfilter
Version: git-master Keywords: vulkan
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

The scale_vulkan filter does not accept an output pixel format different than yuv420p in the format option.

For example, when trying to use nv12 in the format option, it fails with an error message of Unsupported input format for conversion:

$ ffmpeg \
  -init_hw_device vulkan=hw:0 -filter_hw_device hw \
  -f lavfi -i 'color=color=White:size=1280x720' \
  -vf 'hwupload,scale_vulkan=w=640:h=480:format=nv12,hwdownload,format=nv12,format=yuv420p' \
  -c:v libx264 -preset:v ultrafast -movflags '+faststart' -t 40 -y test-out.mp4
ffmpeg version N-113734-gcffadfe99a Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 13.2.1 (GCC) 20230801
  configuration: --prefix=/usr --extra-cflags=-I/opt/cuda/include --extra-ldflags=-L/opt/cuda/lib64 --enable-lto --disable-rpath --enable-gpl --enable-version3 --enable-nonfree --enable-shared --disable-static --disable-stripping --disable-htmlpages --enable-gray --enable-alsa --enable-avisynth --enable-bzlib --enable-chromaprint --enable-frei0r --enable-gcrypt --enable-gmp --enable-gnutls --enable-iconv --enable-ladspa --enable-lcms2 --enable-libaom --enable-libaribb24 --enable-libaribcaption --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcelt --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libdavs2 --enable-libdc1394 --enable-libfdk-aac --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-libglslang --enable-libgme --enable-libgsm --enable-libiec61883 --enable-libilbc --enable-libjack --enable-libjxl --enable-libklvanc --enable-libkvazaar --enable-liblensfun --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopencv --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-libopenvino --enable-libopus --enable-libplacebo --enable-libpulse --enable-libqrencode --enable-librabbitmq --enable-librav1e --enable-librist --enable-librsvg --enable-librubberband --enable-librtmp --disable-libshaderc --enable-libshine --enable-libsmbclient --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libsvthevc --enable-libsvtvp9 --disable-libtensorflow --enable-libtesseract --enable-libtheora --disable-libtls --enable-libtwolame --enable-libuavs3d --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxevd --enable-libxeve --enable-libxavs --enable-libxavs2 --enable-libxcb --enable-libxcb-shm --enable-libxcb-xfixes --enable-libxcb-shape --enable-libxvid --enable-libxml2 --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-lzma --enable-decklink --disable-mbedtls --enable-libmysofa --enable-openal --enable-opencl --enable-opengl --disable-openssl --disable-pocketsphinx --enable-sndio --enable-sdl2 --enable-vapoursynth --enable-vulkan --enable-xlib --enable-zlib --enable-amf --enable-cuda-nvcc --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-libdrm --enable-libvpl --enable-libnpp --enable-nvdec --enable-nvenc --enable-omx --enable-rkmpp --enable-v4l2-m2m --enable-vaapi --enable-vdpau
  libavutil      58. 39.100 / 58. 39.100
  libavcodec     60. 39.101 / 60. 39.101
  libavformat    60. 21.101 / 60. 21.101
  libavdevice    60.  4.100 / 60.  4.100
  libavfilter     9. 17.100 /  9. 17.100
  libswscale      7.  6.100 /  7.  6.100
  libswresample   4. 13.100 /  4. 13.100
  libpostproc    57.  4.100 / 57.  4.100
Input #0, lavfi, from 'color=color=White:size=1280x720':
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: wrapped_avframe, yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 25 tbn
Stream mapping:
  Stream #0:0 -> #0:0 (wrapped_avframe (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[Parsed_scale_vulkan_1 @ 0x7b54f0005600] Unsupported input format for conversion
[Parsed_scale_vulkan_1 @ 0x7b54f0005600] Failed to configure output pad on Parsed_scale_vulkan_1
[vf#0:0 @ 0x5ee8fea51b00] Error reinitializing filters!
[vf#0:0 @ 0x5ee8fea51b00] Task finished with error code: -22 (Invalid argument)
[vf#0:0 @ 0x5ee8fea51b00] Terminating thread with return code -22 (Invalid argument)
[vost#0:0/libx264 @ 0x5ee8feac8c80] Could not open encoder before EOF
[vost#0:0/libx264 @ 0x5ee8feac8c80] Task finished with error code: -22 (Invalid argument)
[vost#0:0/libx264 @ 0x5ee8feac8c80] Terminating thread with return code -22 (Invalid argument)
[out#0/mp4 @ 0x5ee9006763c0] Nothing was written into output file, because at least one of its streams received no packets.
frame=    0 fps=0.0 q=0.0 Lsize=       0KiB time=N/A bitrate=N/A speed=N/A    
Conversion failed!

As the error complains about the input pixel format, I tried to insert a format=nv12 filter before hwupload, but this still does not work:

-vf 'format=nv12,hwupload,scale_vulkan=w=640:h=480:format=nv12,hwdownload,format=nv12,format=yuv420p'

It works when using yuv420p pixel format, either by explicitly setting it or by omitting the format option, as bellow:

-vf 'hwupload,scale_vulkan=w=640:h=480:format=yuv420p,hwdownload,format=yuv420p'

-vf 'hwupload,scale_vulkan=w=640:h=480,hwdownload,format=yuv420p'

It also works when using rgba as the input pixel format, but still no nv12 is accepted in the format option, and produces a green tint output (wrong colors, maybe related to #10875):

-vf 'format=bgra,hwupload,scale_vulkan=w=640:h=480:format=yuv420p,hwdownload,format=yuv420p'

All other hardware accelerated scale filters (scale_cuda, scale_npp, scale_qsv and scale_vaapi) does not behave like this, as they accept, for example, nv12 in the format option using the example above.

By looking at the vf_scale_vulkan.c source code (https://git.ffmpeg.org/gitweb/ffmpeg.git/blob/cffadfe99a1c41866701bab6c7410c17737a1db1:/libavfilter/vf_scale_vulkan.c#l335), it looks like that it should support nv12, yuv420p and yuv444p output formats.

System Information:

  • OS: Arch Linux
  • Vulkan device: NVIDIA RTX 3060
  • GPU driver: NVIDIA proprietary driver version 545.29.06

Change History (2)

comment:1 by bermond, 6 months ago

This seems to be fixed by commit eb7d019b326b0c34e07f2369f31e8ba266fa666b.

comment:2 by bermond, 6 months ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.