jellyfin / jellyfin-ffmpeg

FFmpeg for Jellyfin
https://jellyfin.org
Other
436 stars 118 forks source link

Movies with specific resolutions (Intel QSV,1910x816) transcoding failed #300

Open shaino opened 8 months ago

shaino commented 8 months ago

Describe The Bug A native 22 mbps H264 movie transcoding higher than 10 mbps fails.

Steps To Reproduce Normal transcoding below 10 mbps. Transcoding failed for 10 mbps and above.

Expected Behavior none

System (please complete the following information):

all

MediaInfo H264 22mbps

FFmpeg Logs [matroska,webm @ 0x55c368c342c0] sub2video: using 1910x816 canvas libva info: VA-API version 1.19.0 libva info: Trying to open /usr/lib/jellyfin-ffmpeg/lib/dri/iHD_drv_video.so libva info: Found init function __vaDriverInit_1_19 libva info: va_openDriver() returns 0 [AVHWFramesContext @ 0x55c36974d040] Error synchronizing the operation [hwupload @ 0x55c368ce3580] Failed to upload frame: -1313558101. Error while add the frame to buffer source(Unknown error occurred). Error while filtering: Unknown error occurred Failed to inject frame into filter network: Unknown error occurred Error while processing the decoded data for stream #0:0 Conversion failed!

Additional Context none

nyanmisaka commented 8 months ago

@shaino I've only heard of this on intel graphics with ancient kernels, like kernel 4.x. I doubt Intel is still taking the time to test the compatibility of their code with these kernels. If I'm right, it's time to update to at least 5.10 LTS.

shaino commented 8 months ago

The testing hardware is the NAS of Synology and QNAP. CPU is intel 8259u and 3865u,server version is 10.8.11 ,and ffmpeg v6.0.8(The same goes for the old version). Currently, only one H264 encoded file with issues has been found in over 3000 movies. Of course, most of my movies are H265 HDR, and H264 is rare Even other H264 movies have not found any issues. Is this movie just because it is a 1910 video width issue? Because the bit rate is below 10mbps, only "- canvas_size 1280x546" and "- canvas_size 1910x816" are different in terms of parameters.

nyanmisaka commented 8 months ago

These NAS use custom kernels, and their i915 driver is not necessarily guaranteed to follow upstream backport fixes.

Please install Ubuntu 22.04 LTS on intel 8259u to test whether the problem can be reproduced. If it can be reproduced, I will be happy to help you file an issue to Intel.

shaino commented 8 months ago

Perhaps we need to build an Ubuntu platform for testing, but I still doubt whether video resolution is the key point. I tested it on the bash console and only needed to modify the ffmpeg parameter "- canvas_size 1910x816" to an even number greater than 1914 to work. For example, "1914x816", "1916x816", "1920x816". It is difficult to obtain updates for Intel drivers on NAS. Assuming that outdated Intel drivers have this bug, wouldn't it be better for Jellyfin to force non compliant video widths such as 1910 to be modified to compliant widths when transcoding.

shaino commented 8 months ago

I transcoded the H264 to an H265 video and the same issue occurred. It seems to indicate that it is not related to the original video encoding, but rather to the resolution.

shaino commented 8 months ago

10th generation Intel CPU, newly installed Ubuntu 22.04.3 LTS system, and Jellyfin 10.8.12 server version. The problem remains. @nyanmisaka

shaino commented 8 months ago

Is there a limit on video width for ffmpeg or Intel drivers, which happens to be a problem with 1910 video width.

shaino commented 8 months ago

In addition, after upgrading to the 10.8.12 server version, the 8259u encountered an opencl tone mapping failure, while the vpp tone mapping did not have any issues. No issues were found with other CPUs. In 2022, you fixed the issue of 8259u as a special case where the buffer parameters were too small.

nyanmisaka commented 8 months ago

Then it must be an issue of intel's QSV code.

Starting from intel compute-runtime 23.17.26241.22, the support for kernel 4.x have been broken or dropped. I learned last month from other people who were using Synology NAS. So I haven't upgraded it in my docker image. But one day I have to do it for newer GPUs. You can file an issue in their repo and wait for their response.

shaino commented 8 months ago

The issue of 10.8.12 should be different from the issue of the Synology you referenced. The issue of the Synology you referenced has started transcoding. And this issue cannot start ffmpeg work. Simply downgrade to 10.8.11 to work, or change OpenCL tone mapping to vpp tone mapping in 10.8.12. The attached log is as follows. It's not that I didn't attach the complete log, but that the log ends here.

------ ffmpeg log ...... ffmpeg version 6.0-Jellyfin Copyright (c) 2000-2023 the FFmpeg developers built with gcc 10 (Debian 10.2.1-6) configuration: --prefix=/usr/lib/jellyfin-ffmpeg --target-os=linux --extra-version=Jellyfin --disable-doc --disable-ffplay --disable-ptx-compression --disable-static --disable-libxcb --disable-sdl2 --disable-xlib --enable-lto --enable-gpl --enable-version3 --enable-shared --enable-gmp --enable-gnutls --enable-chromaprint --enable-libdrm --enable-libass --enable-libfreetype --enable-libfribidi --enable-libfontconfig --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libopenmpt --enable-libdav1d --enable-libwebp --enable-libvpx --enable-libx264 --enable-libx265 --enable-libzvbi --enable-libzimg --enable-libfdk-aac --arch=amd64 --enable-libsvtav1 --enable-libshaderc --enable-libplacebo --enable-vulkan --enable-opencl --enable-vaapi --enable-amf --enable-libvpl --enable-ffnvcodec --enable-cuda --enable-cuda-llvm --enable-cuvid --enable-nvdec --enable-nvenc libavutil 58. 2.100 / 58. 2.100 libavcodec 60. 3.100 / 60. 3.100 libavformat 60. 3.100 / 60. 3.100 libavdevice 60. 1.100 / 60. 1.100 libavfilter 9. 3.100 / 9. 3.100 libswscale 7. 1.100 / 7. 1.100 libswresample 4. 10.100 / 4. 10.100 libpostproc 57. 1.100 / 57. 1.100 libva info: VA-API version 1.20.0 libva info: Trying to open /usr/lib/jellyfin-ffmpeg/lib/dri/iHD_drv_video.so libva info: Found init function __vaDriverInit_1_20 libva info: va_openDriver() returns 0