@ChuckPa
Alright so ive done a bit more testing with just ffmpeg after I saw a post on another media server forum reporting similar issues. It appears it may not be a plex issue but an issue within ffmpeg and CUDA. I have now been able to replicate the issue with my local ffmpeg on two separate machines with different nvidia cards and different ffmpeg versions also different CUDA versions leveraging CUDA 11.7 and 12.
I can replicate the issue in ffmpeg directly by passing -hwaccel (auto|cuda|nvdec) and -hwaccel_output_format cuda. Passing other combinations results in the hw transcode happening without issue.
Example commands below
Truncated plex command
/usr/lib/plexmediaserver/Plex Transcoder -codec:0 hevc -hwaccel:0 nvdec -hwaccel_fallback_threshold:0 10 -threads:0 1 -hwaccel_output_format:0 cuda -hwaccel_device:0 cuda -analyzeduration 20000000 -probesize 20000000 -i /srv/ftp/movies/test/jellyfish-30-mbps-hd-hevc.mkv -filter_complex [0:0]hwupload[0];[0]scale_cuda=w=1920:h=1080:format=nv12[1] -map [1] -codec:0 h264_nvenc -b:0 20000k -preset:0 hq
Generates the errors that were discussed
Taking what I saw there I created an ffmpeg command that is very basic but results in generating the same errors
ffmpeg -hwaccel nvdec -hwaccel_output_format cuda -i /srv/ftp/movies/test/jellyfish-30-mbps-hd-hevc.mkv -c:v h264_nvenc test.mkv
Fails with the same errors as seen in pms logs. Below is truncated output that ffmpeg spat out (the Invalid DTS is something I didnt see in pms logs but the other messages are the same)
[matroska @ 0x5589ef3c7ec0] Invalid DTS: 27928 PTS: 27861 in output stream 0:0, replacing by guess
Error while decoding stream #0:0: Generic error in an external library
Last message repeated 1 times
[hevc @ 0x5589f0144940] No decoder surfaces left
[hevc @ 0x5589f0144940] decoder->cvdl->cuvidDecodePicture(decoder->decoder, &ctx->pic_params) failed -> CUDA_ERROR_INVALID_VALUE: invalid argument
[hevc @ 0x5589f0144940] hardware accelerator failed to decode picture
Error while decoding stream #0:0: Generic error in an external library
[hevc @ 0x5589f0207200] No decoder surfaces left
[hevc @ 0x5589f0207200] decoder->cvdl->cuvidDecodePicture(decoder->decoder, &ctx->pic_params) failed -> CUDA_ERROR_INVALID_VALUE: invalid argument
[hevc @ 0x5589f0207200] hardware accelerator failed to decode picture
Error while decoding stream #0:0: Generic error in an external library
[hevc @ 0x5589f02c9ac0] No decoder surfaces left
[hevc @ 0x5589f02c9ac0] decoder->cvdl->cuvidDecodePicture(decoder->decoder, &ctx->pic_params) failed -> CUDA_ERROR_INVALID_VALUE: invalid argument
[hevc @ 0x5589f02c9ac0] hardware accelerator failed to decode picture
[hevc @ 0x5589f038c380] Could not find ref with POC 891
[hevc @ 0x5589f038c380] No decoder surfaces left
[hevc @ 0x5589f038c380] decoder->cvdl->cuvidDecodePicture(decoder->decoder, &ctx->pic_params) failed -> CUDA_ERROR_INVALID_VALUE: invalid argument
[hevc @ 0x5589f038c380] hardware accelerator failed to decode picture
[hevc @ 0x5589f044ec40] Could not find ref with POC 889
[hevc @ 0x5589f044ec40] No decoder surfaces left
[hevc @ 0x5589f044ec40] decoder->cvdl->cuvidDecodePicture(decoder->decoder, &ctx->pic_params) failed -> CUDA_ERROR_INVALID_VALUE: invalid argument
[hevc @ 0x5589f044ec40] hardware accelerator failed to decode picture
Error while decoding stream #0:0: Generic error in an external library
Last message repeated 4 times
[matroska @ 0x5589ef3c7ec0] Invalid DTS: 28962 PTS: 28929 in output stream 0:0, replacing by guess
[matroska @ 0x5589ef3c7ec0] Invalid DTS: 29496 PTS: 29463 in output stream 0:0, replacing by guess
Modifying that command and replacing the explicit CUDA with auto or nvdec solves the problem or simply removing the explicit callout to hwaccel_output_format also resolves the issue
ffmpeg -hwaccel nvdec -hwaccel_output_format auto -i /srv/ftp/movies/test/jellyfish-30-mbps-hd-hevc.mkv -c:v h264_nvenc test.mkv
ffmpeg -hwaccel nvdec -hwaccel_output_format nvdec -i /srv/ftp/movies/test/jellyfish-30-mbps-hd-hevc.mkv -c:v h264_nvenc test.mkv
ffmpeg -hwaccel nvdec -i /srv/ftp/movies/test/jellyfish-30-mbps-hd-hevc.mkv -c:v h264_nvenc test.mkv
All these show the same type of performance on my hardware that plex runs on resulting in a 14x conversion
Can you guys make the -hwaccel_output_format a configurable value or simply let ffmpeg choose the solution by using auto or leave that out of the args you are passing to the transcoder?