Jump to content

NVDEC H.265 decoding not working (but CUVID does)


ctaranto

Recommended Posts

ctaranto

I posted another topic similar to this (https://emby.media/community/index.php?/topic/101366-hw-transcoding-was-working-and-now-its-not/#comment-1063318) but that workaround no longer works well.  The CUVID decoder results in a green screen for many movies.

Environment:

2022-04-06 07:47:00.579 Info Main: Application path: /usr/lib/emby-server/EmbyServer.dll
2022-04-06 07:47:00.850 Info Main: Emby
    Command line: /usr/lib/emby-server/EmbyServer.dll -programdata /var/lib/emby -ffdetect /usr/bin/ffdetect-emby -ffmpeg /usr/bin/ffmpeg-emby -ffprobe /usr/bin/ffprobe-emby -restartexitcode 3
    Operating system: Linux version 5.4.184-1-MANJARO (builduser@fv-az47-976) (gcc version 11.2.0 (GCC)) #1 SMP PREEMPT Fri Mar 11 13:59:07 UTC 2022
    Framework: .NET Core 3.1.20
    OS/Process: x64/x64
    Runtime: usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.20/System.Private.CoreLib.dll
    Processor count: 8
    Data path: /var/lib/emby
    Application path: /usr/lib/emby-server
2022-04-06 07:47:00.850 Info Main: Logs path: /var/lib/emby/logs
2022-04-06 07:47:00.850 Info Main: Cache path: /var/lib/emby/cache
2022-04-06 07:47:00.850 Info Main: Internal metadata path: /var/lib/emby/metadata
2022-04-06 07:47:00.850 Info Main: Transcoding temporary files path: /var/lib/emby/transcoding-temp
2022-04-06 07:47:00.892 Info App: Application version: 4.6.7.0

Manjaro (latest) Linux server with an nvidia GTX 1660 Super card with fully updated nvidia drivers.  Attached is the embyserver, hardware_detection, and ffmpeg-transcode of a movie where hardware decoding doesn't kick in even then NVDEC is selected in the H.265 (HEVC) decoding section of the Transcoding menu.

When I select CUVID and put it above NVENC, hardware decoding kicks in, but for many movies, this results in a green screen.  Reading other threads, CUVID is the "old" cuda decoding, and NVDEC is the newer decoding.

I would like to understand why the newer decoding isn't working for me.

Is there a test I could run at the command line to ensure nvdec is available?

embyserver.txt ffmpeg-transcode-8fa45245-4e61-486e-b34f-637673ebb748_1.txt hardware_detection-63784828026.txt

Link to comment
Share on other sites

Hi, the reason why we offer both is for this very reason that on since systems one will work better and on others it could be the opposite. If that weren't the case and one of them consistently worked with all hardware then we wouldn't even provide the choice.

Link to comment
Share on other sites

ctaranto

Thanks, Luke.

Is there anything in the logs that indicates why NVDEC isn't working?  Library compatibility?  Missing libraries?  

After reading various forums, it seems like _cuvid is not the preferred hardware acceleration (https://forums.developer.nvidia.com/t/ffmpeg-unknown-decoder-h265-cuvid-for-geforce-rtx-2060/128265).  I changed from -c:v:0 hevc_cuvid to -c:v:0 hevc_nvdec, but ffmpeg throws an error that hevc_nvdec isn't a valid decoder.  But the forum I linked to mentions that the preferred way to turn on nvdec acceleration is to use -hwaccel nvdec (instead of the -c:v:0 hevc parameter).  That turned on decoding hardware acceleration, presumably using nvdec.

I did this test on the commend line (extracting the call emby makes from the log).

How would I change emby's parameter list to use -hwaccel nvdec instead of "-c:v:0 hevc_cuvid"

 

Edited by ctaranto
Link to comment
Share on other sites

Happy2Play
5 hours ago, ctaranto said:

Is there anything in the logs that indicates why NVENC isn't working?

What do you mean?  Unless this is a typo and mean NVDEC, since the encoder is working.

Dev will have to confirm, but is this not just a display name issue as HWA decoder is being used? @Luke@softworkz

NVDEC NVIDIA GeForce GTX 1660 SUPER - H.265 (HEVC)

Spoiler

"4: NVDEC NVIDIA GeForce GTX 1660 SUPER - H.265 (HEVC)": {
            "MaxMacroBlocks": 262144,
            "IsEnabledByDefault": true,
            "DefaultPriority": 30,
            "NvidiaCodecInfo": {
                "Name": "NVDEC NVIDIA GeForce GTX 1660 SUPER - H.265 (HEVC)",
                "Description": "Adapter #0: 'NVIDIA GeForce GTX 1660 SUPER' ComputeCapability: 7.5",
                "DeviceInfo": {
                    "ComputeCapability": {
                        "Major": 7,
                        "Minor": 5,
                        "Build": -1,
                        "Revision": -1,
                        "MajorRevision": -1,
                        "MinorRevision": -1
                    },
                    "HardwareContextFramework": "NvEncDec",
                    "Capabilities": {
                        "SupportsHwUpload": true,
                        "SupportsHwDownload": true,
                        "SupportsStandaloneDeviceInit": true,
                        "Supports10BitProcessing": true,
                        "SupportsNativeToneMapping": false
                    },
                    "Adapter": 0,
                    "Name": "NVIDIA GeForce GTX 1660 SUPER",
                    "Desription": "Adapter #0: 'NVIDIA GeForce GTX 1660 SUPER' ComputeCapability: 7.5",
                    "DeviceId": 0,
                    "VendorId": 0
                },
                "SecondaryCodecTag": "cudaId0",
                "CommandGenerator": {},
                "MaxMacroBlocks": 262144
            },
            "SecondaryFramework": "NvEncDec",
            "FrameworkCodec": "hevc",
            "SecondaryFrameworkCodec": "cudaId0",
            "IsHardwareCodec": true,
            "VideoMediaType": "hevc",
            "ProfilesWithLevel": [{
                    "Profile": "HevcProfileMain",
                    "Level": "HevcLevel61"
                }, {
                    "Profile": "HevcProfileMain10",
                    "Level": "HevcLevel61"
                }, {
                    "Profile": "HevcProfileMainRext",
                    "Level": "HevcLevel61"
                }
            ],
            "SupportedProfiles": ["HevcProfileMain", "HevcProfileMain10", "HevcProfileMainRext"],
            "SupportedLevels": ["HevcLevel1", "HevcLevel2", "HevcLevel21", "HevcLevel3", "HevcLevel31", "HevcLevel4", "HevcLevel41", "HevcLevel5", "HevcLevel51", "HevcLevel52", "HevcLevel6", "HevcLevel61"],
            "Direction": "Decoder",
            "SupportedColorFormats": ["nv12", "p010", "p016", "cuda", "yuv420p", "yuv420p10", "yuv420p16", "yuv444p", "yuv444p10", "yuv444p16"],
            "CodecDeviceInfo": {
                "ComputeCapability": {
                    "Major": 7,
                    "Minor": 5,
                    "Build": -1,
                    "Revision": -1,
                    "MajorRevision": -1,
                    "MinorRevision": -1
                },
                "HardwareContextFramework": "NvEncDec",
                "Capabilities": {
                    "SupportsHwUpload": true,
                    "SupportsHwDownload": true,
                    "SupportsStandaloneDeviceInit": true,
                    "Supports10BitProcessing": true,
                    "SupportsNativeToneMapping": false
                },
                "Adapter": 0,
                "Name": "NVIDIA GeForce GTX 1660 SUPER",
                "Desription": "Adapter #0: 'NVIDIA GeForce GTX 1660 SUPER' ComputeCapability: 7.5",
                "DeviceId": 0,
                "VendorId": 0
            },
            "CodecKind": "Video",
            "MediaTypeName": "H.265 (HEVC)",
            "MinWidth": 144,
            "MaxWidth": 8192,
            "MinHeight": 144,
            "MaxHeight": 8192,
            "WidthAlignment": 2,
            "HeightAlignment": 2,
            "SupportedColorFormatStrings": ["NV12", "P010", "P016", "CUDA", "YUV420P", "YUV420P10", "YUV420P16", "YUV444P", "YUV444P10", "YUV444P16"],
            "ProfileAndLevelInformation": [{
                    "Profile": {
                        "ShortName": "HevcProfileMain",
                        "Description": "Main Profile",
                        "Details": "The Main profile allows for a bit depth of 8-bits per sample with 4:2:0 chroma sampling, which is the most common type of video used with consumer devices.",
                        "Id": "HevcProfiles.HevcProfileMain"
                    },
                    "Level": {
                        "ShortName": "HevcLevel61",
                        "Description": "Level 6.1",
                        "Ordinal": 61,
                        "MaxBitRate": "117 Mbit/s",
                        "MaxBitRateDisplay": "117 Mbit/s",
                        "Id": "HevcLevels.HevcLevel61",
                        "ResolutionRates": ["3840x2160@256", "7680x4320@64", "8192x4320@60", "8192x8192@30"],
                        "ResolutionRateStrings": ["3840x2160@256", "7680x4320@64", "8192x4320@60", "8192x8192@30"],
                        "ResolutionRatesDisplay": "3840x2160@256, 7680x4320@64, 8192x4320@60, 8192x8192@30"
                    }
                }, {
                    "Profile": {
                        "ShortName": "HevcProfileMain10",
                        "Description": "Main 10 Profile",
                        "Details": "The Main 10 profile allows for a bit depth of 8-bits to 10-bits per sample with 4:2:0 chroma sampling. allows for improved video quality since it can support video with a higher bit depth than what is supported by the Main profile.[140] Additionally, in the Main 10 profile 8-bit video can be coded with a higher bit depth of 10-bits, which allows improved coding efficiency compared to the Main profile.",
                        "Id": "HevcProfiles.HevcProfileMain10"
                    },
                    "Level": {
                        "ShortName": "HevcLevel61",
                        "Description": "Level 6.1",
                        "Ordinal": 61,
                        "MaxBitRate": "117 Mbit/s",
                        "MaxBitRateDisplay": "117 Mbit/s",
                        "Id": "HevcLevels.HevcLevel61",
                        "ResolutionRates": ["3840x2160@256", "7680x4320@64", "8192x4320@60", "8192x8192@30"],
                        "ResolutionRateStrings": ["3840x2160@256", "7680x4320@64", "8192x4320@60", "8192x8192@30"],
                        "ResolutionRatesDisplay": "3840x2160@256, 7680x4320@64, 8192x4320@60, 8192x8192@30"
                    }
                }, {
                    "Profile": {
                        "ShortName": "HevcProfileMainRext",
                        "Description": "Range Extension (REXT)",
                        "Details": "Version 2 of HEVC adds 21 range extensions profiles, which are grouped together as REXT for now.",
                        "Id": "HevcProfiles.HevcProfileMainRext"
                    },
                    "Level": {
                        "ShortName": "HevcLevel61",
                        "Description": "Level 6.1",
                        "Ordinal": 61,
                        "MaxBitRate": "117 Mbit/s",
                        "MaxBitRateDisplay": "117 Mbit/s",
                        "Id": "HevcLevels.HevcLevel61",
                        "ResolutionRates": ["3840x2160@256", "7680x4320@64", "8192x4320@60", "8192x8192@30"],
                        "ResolutionRateStrings": ["3840x2160@256", "7680x4320@64", "8192x4320@60", "8192x8192@30"],
                        "ResolutionRatesDisplay": "3840x2160@256, 7680x4320@64, 8192x4320@60, 8192x8192@30"
                    }
                }
            ],
            "Id": "V-D-hevc-nv-cudaId0",
            "Name": "NVDEC NVIDIA GeForce GTX 1660 SUPER - H.265 (HEVC)",
            "Description": "Adapter #0: 'NVIDIA GeForce GTX 1660 SUPER' ComputeCapability: 7.5"
        },

 

CUVID NVIDIA GeForce GTX 1660 SUPER - H.265 (HEVC)

Spoiler

       "6: CUVID NVIDIA GeForce GTX 1660 SUPER - H.265 (HEVC)": {
            "MaxMacroBlocks": 262144,
            "IsEnabledByDefault": false,
            "DefaultPriority": 0,
            "NvidiaCodecInfo": {
                "Name": "CUVID NVIDIA GeForce GTX 1660 SUPER - H.265 (HEVC)",
                "Description": "Adapter #0: 'NVIDIA GeForce GTX 1660 SUPER' ComputeCapability: 7.5",
                "DeviceInfo": {
                    "ComputeCapability": {
                        "Major": 7,
                        "Minor": 5,
                        "Build": -1,
                        "Revision": -1,
                        "MajorRevision": -1,
                        "MinorRevision": -1
                    },
                    "HardwareContextFramework": "NvEncDec",
                    "Capabilities": {
                        "SupportsHwUpload": true,
                        "SupportsHwDownload": true,
                        "SupportsStandaloneDeviceInit": true,
                        "Supports10BitProcessing": true,
                        "SupportsNativeToneMapping": false
                    },
                    "Adapter": 0,
                    "Name": "NVIDIA GeForce GTX 1660 SUPER",
                    "Desription": "Adapter #0: 'NVIDIA GeForce GTX 1660 SUPER' ComputeCapability: 7.5",
                    "DeviceId": 0,
                    "VendorId": 0
                },
                "SecondaryCodecTag": "cudaId0",
                "CommandGenerator": {},
                "MaxMacroBlocks": 262144
            },
            "SecondaryFramework": "NvEncDec",
            "FrameworkCodec": "hevc_cuvid",
            "SecondaryFrameworkCodec": "cudaId0",
            "IsHardwareCodec": true,
            "VideoMediaType": "hevc",
            "ProfilesWithLevel": [{
                    "Profile": "HevcProfileMain",
                    "Level": "HevcLevel61"
                }, {
                    "Profile": "HevcProfileMain10",
                    "Level": "HevcLevel61"
                }, {
                    "Profile": "HevcProfileMainRext",
                    "Level": "HevcLevel61"
                }
            ],
            "SupportedProfiles": ["HevcProfileMain", "HevcProfileMain10", "HevcProfileMainRext"],
            "SupportedLevels": ["HevcLevel1", "HevcLevel2", "HevcLevel21", "HevcLevel3", "HevcLevel31", "HevcLevel4", "HevcLevel41", "HevcLevel5", "HevcLevel51", "HevcLevel52", "HevcLevel6", "HevcLevel61"],
            "Direction": "Decoder",
            "SupportedColorFormats": ["nv12", "p010", "p016", "cuda", "yuv420p", "yuv420p10", "yuv420p16", "yuv444p", "yuv444p10", "yuv444p16"],
            "CodecDeviceInfo": {
                "ComputeCapability": {
                    "Major": 7,
                    "Minor": 5,
                    "Build": -1,
                    "Revision": -1,
                    "MajorRevision": -1,
                    "MinorRevision": -1
                },
                "HardwareContextFramework": "NvEncDec",
                "Capabilities": {
                    "SupportsHwUpload": true,
                    "SupportsHwDownload": true,
                    "SupportsStandaloneDeviceInit": true,
                    "Supports10BitProcessing": true,
                    "SupportsNativeToneMapping": false
                },
                "Adapter": 0,
                "Name": "NVIDIA GeForce GTX 1660 SUPER",
                "Desription": "Adapter #0: 'NVIDIA GeForce GTX 1660 SUPER' ComputeCapability: 7.5",
                "DeviceId": 0,
                "VendorId": 0
            },
            "CodecKind": "Video",
            "MediaTypeName": "H.265 (HEVC)",
            "MinWidth": 144,
            "MaxWidth": 8192,
            "MinHeight": 144,
            "MaxHeight": 8192,
            "WidthAlignment": 2,
            "HeightAlignment": 2,
            "SupportedColorFormatStrings": ["NV12", "P010", "P016", "CUDA", "YUV420P", "YUV420P10", "YUV420P16", "YUV444P", "YUV444P10", "YUV444P16"],
            "ProfileAndLevelInformation": [{
                    "Profile": {
                        "ShortName": "HevcProfileMain",
                        "Description": "Main Profile",
                        "Details": "The Main profile allows for a bit depth of 8-bits per sample with 4:2:0 chroma sampling, which is the most common type of video used with consumer devices.",
                        "Id": "HevcProfiles.HevcProfileMain"
                    },
                    "Level": {
                        "ShortName": "HevcLevel61",
                        "Description": "Level 6.1",
                        "Ordinal": 61,
                        "MaxBitRate": "117 Mbit/s",
                        "MaxBitRateDisplay": "117 Mbit/s",
                        "Id": "HevcLevels.HevcLevel61",
                        "ResolutionRates": ["3840x2160@256", "7680x4320@64", "8192x4320@60", "8192x8192@30"],
                        "ResolutionRateStrings": ["3840x2160@256", "7680x4320@64", "8192x4320@60", "8192x8192@30"],
                        "ResolutionRatesDisplay": "3840x2160@256, 7680x4320@64, 8192x4320@60, 8192x8192@30"
                    }
                }, {
                    "Profile": {
                        "ShortName": "HevcProfileMain10",
                        "Description": "Main 10 Profile",
                        "Details": "The Main 10 profile allows for a bit depth of 8-bits to 10-bits per sample with 4:2:0 chroma sampling. allows for improved video quality since it can support video with a higher bit depth than what is supported by the Main profile.[140] Additionally, in the Main 10 profile 8-bit video can be coded with a higher bit depth of 10-bits, which allows improved coding efficiency compared to the Main profile.",
                        "Id": "HevcProfiles.HevcProfileMain10"
                    },
                    "Level": {
                        "ShortName": "HevcLevel61",
                        "Description": "Level 6.1",
                        "Ordinal": 61,
                        "MaxBitRate": "117 Mbit/s",
                        "MaxBitRateDisplay": "117 Mbit/s",
                        "Id": "HevcLevels.HevcLevel61",
                        "ResolutionRates": ["3840x2160@256", "7680x4320@64", "8192x4320@60", "8192x8192@30"],
                        "ResolutionRateStrings": ["3840x2160@256", "7680x4320@64", "8192x4320@60", "8192x8192@30"],
                        "ResolutionRatesDisplay": "3840x2160@256, 7680x4320@64, 8192x4320@60, 8192x8192@30"
                    }
                }, {
                    "Profile": {
                        "ShortName": "HevcProfileMainRext",
                        "Description": "Range Extension (REXT)",
                        "Details": "Version 2 of HEVC adds 21 range extensions profiles, which are grouped together as REXT for now.",
                        "Id": "HevcProfiles.HevcProfileMainRext"
                    },
                    "Level": {
                        "ShortName": "HevcLevel61",
                        "Description": "Level 6.1",
                        "Ordinal": 61,
                        "MaxBitRate": "117 Mbit/s",
                        "MaxBitRateDisplay": "117 Mbit/s",
                        "Id": "HevcLevels.HevcLevel61",
                        "ResolutionRates": ["3840x2160@256", "7680x4320@64", "8192x4320@60", "8192x8192@30"],
                        "ResolutionRateStrings": ["3840x2160@256", "7680x4320@64", "8192x4320@60", "8192x8192@30"],
                        "ResolutionRatesDisplay": "3840x2160@256, 7680x4320@64, 8192x4320@60, 8192x8192@30"
                    }
                }
            ],
            "Id": "V-D-hevc_cuvid-nv-cudaId0",
            "Name": "CUVID NVIDIA GeForce GTX 1660 SUPER - H.265 (HEVC)",
            "Description": "Adapter #0: 'NVIDIA GeForce GTX 1660 SUPER' ComputeCapability: 7.5"
        },

 

Link to comment
Share on other sites

ctaranto

Thanks, H2P.  Yes, I meant NVDEC.  I edited the post to avoid further confusion.

I think it's more than a display name issue.  When CUVID is selected, I see "-c:v:0 hevc_cuvid" in the ffmpeg command line.  When NVDEC is selected, I see "-c:v:0 hevc".

It may be the problem I'm having is that instead of -c:v:0 hevc, it should be "-hwaccel nvdec".

 

 

Link to comment
Share on other sites

Happy2Play

Pretty sure this is the reason HWA NVDEC is not happening.

Info    Scaling                                  >> False                False                Ffmpeg does not include 'scale_cuda' ... 
Info    ToneMapping (when possible)              >> False                False                Ffmpeg does not include 'scale_cuda' ...

But know there is a lot of changes for this in beta 4.7.

Link to comment
Share on other sites

@ctaranto

The difference between CUVID and NVDEC in ffmpeg is that in case of CUVID, the whole video stream is sent to and processed by the Nvidia Media API and in case of NVDEC, the parsing is done by ffmpeg and only the video frame data is sent to the Nvidia API.

The API has formerly been called NVCUVID, now NVDEC, but that CUDA decoding that you read about has gone away long time ago while the name stayed for much longer. The decoding is the same (done by the fixed-function hardware "chips" in either case. Those chips are called NVDEC as well)
The whole story is really confusing, because  there's the ffmpeg naming, the Nvidia API naming and the Nvidia hardware feature naming - three different things...

The green artifacts with HEVC_cuvid are a know issue, that's why HEVC_nvdec is the default.

From the log I can't see any error, so I'm no sure what it could be.

Could you please retry with NVDEC and then grab the first transcoded segment from transcoding_temp? (a subfolder is created there)
You can send it to me via PM.

Thanks,
sw

Link to comment
Share on other sites

@ctaranto - Thanks for the test segment. It appears to be fine as far as I can see. Do you have any playback problems when choosing NVDEC?

On 4/6/2022 at 2:24 PM, ctaranto said:

I would like to understand why the newer decoding isn't working for me.

In what way doesn't it work for you?

I think I got it now, what you're asking about:

The Emby installation package which you are using includes an ffmpeg version which doesn't include all of the features like the version we have in most other Linux packages. As such, it doesn't include the scale_cuda filter:

image.png.22fc7474be8b7fe6db0ed02f662d479c.png

Due to the fact that the input source is 4k and the scaling needs to be done in software, the processing pipeline builder might have decided not to use hw decoding at all, considering the tradeoff between copying video data (encoded + raw) to and back from the hardware just for decoding (as the same copying will be required for encoding again).

In case of CUVID, the decision process is a bit different for various reasons, but in either case, the primary concern is not the decoding, but the lack of the scale_cuda and tonemap_cuda filters in the ffmpeg which is included in that installation package.

I'm not an expert in that area, but maybe you can try to use one of our official Linux installation packages (e.g. for Debian) instead.

Edited by softworkz
Link to comment
Share on other sites

ctaranto

Thanks for the details, sw.

I think that's part of the problem - Emby doesn't think my video card can do all the fun things it's supposed to do.

There's no way I could use a Debian distribution on an Arch-based distribution.

As an experiment, I replaced the Emby ffmpeg with the latest distribution of ffmpeg available (using symlinks).  While it did use the latest ffmpeg, It did not make a difference.

I think another part of the reason is that when NVDEC is selected, "-hwaccel nvdec" should be part of the ffmpeg command.  Instead, Emby sends "-c:v:0 hevc" which does nothing useful with regards to hardware decoding.

Can Emby make a change so when NVDEC is selected, "-hwaccel nvdec" is sent on the command line?  Or provide a way to override the default of "-c:v:0 hevc"?

 

Link to comment
Share on other sites

ctaranto

I went back and tried this again.  This time, I copied (not symlink) the manjaro-installed ffmpeg executable (in /usr/bin) to a new one (/usr/bin/ffmpeg-emby).  I backed up the original ffmpeg-emby first.

[ctaranto@thor-pc bin]$ ls -al ffmpeg*
-rwxr-xr-x 1 root root   280584 Mar  6 10:40 ffmpeg
-rwxr-xr-x 1 root root   280584 Apr 18 17:25 ffmpeg-emby
-rwxr-xr-x 1 root root 21702520 Apr  6 17:12 ffmpeg-emby.back
[ctaranto@thor-pc bin]$
 

It appears that emby is sending the -hwaccel parameters:

/usr/bin/ffmpeg-emby -y -copyts -start_at_zero -f matroska,webm -c:v:0 hevc -hwaccel:v:0 cuda -hwaccel_device:v:0 0 -hwaccel_output_format:v:0 cuda -i "/storage/red3/movies/Murder on the Orient Express.mkv" -filter_complex "[0:0]scale_cuda@f1=w=1920:h=1080:format=nv12,setsar@f2=sar=sar[f2_out0]" -map [f2_out0] -map 0:1 -sn -c:v:0 h264_nvenc -b:v:0 19616000 -g:v:0 72 -maxrate:v:0 19616000 -bufsize:v:0 39232000 -sc_threshold:v:0 0 -keyint_min:v:0 72 -r:v:0 23.976024627685547 -profile:v:0 high -c:a:0 libmp3lame -ab:a:0 192000 -ac:a:0 2 -metadata:s:a:0 language=eng -filter:a:0 "volume=2" -disposition:a:0 default -max_delay 5000000 -avoid_negative_ts disabled -f segment -map_metadata -1 -map_chapters -1 -segment_format mpegts -segment_list "/var/lib/emby/transcoding-temp/E4EFD2.m3u8" -segment_list_type m3u8 -segment_time 3 -segment_start_number 0 -individual_header_trailer 0 -write_header_trailer 0 "/var/lib/emby/transcoding-temp/E4EFD2_%d.ts"

 

Also appears that hardware acceleration is being used.  I'll confirm that there aren't any green screens next...

Thanks for the help, sw!

 

Update:  Appears no green screens with testing on movies that previously would green screen using CUVID!

For me, using the latest and greatest ffmpeg from my Linux distribution instead of the emby-supplied ffmpeg has enabled NVDEC support.

 

Edited by ctaranto
Link to comment
Share on other sites

You need to be aware, though, that this ffmpeg version lacks many of the customizations we have and you will sooner or later run into other issues.

Also, it doesn't have CUDA tone mapping and the scale_cuda doesn't support format conversions.

Recently, another user reported how he extracted the ffmpeg from our Debian package for use on Arch Linux. This might be a better solution for you.

 

Link to comment
Share on other sites

ctaranto

Ah.  That's what you meant by using the Debian package.  Thanks!  I'll give that a shot.

Update: That died a quick death.  The ffmpeg-emby that is installed by Arch is statically linked (21MB).  The ffmpeg installed by the Arch itself is 275KB (dynamically linked).  The ffmpeg inside of the Debian X64 package is also dynamically linked (275KB).  Unfortunately, that package expects the dependent libraries to be in the "Debian" locations, not the Arch locations.  I'm sure even if it could find the libraries, they would be out of sync (Arch is always at the latest; Debian is release-based).

./ffmpeg-emby: symbol lookup error: ./ffmpeg-emby: undefined symbol: avfilter_alloc, version LIBAVFILTER_7
 

Do any other Linux distributions supply a statically linked ffmpeg (or a link to the post how to better extract the Debian ffmpeg)?

UPDATE:  See the post below for a link how to get ffmpeg from the Debian package working on Arch

Edited by ctaranto
Link to comment
Share on other sites

18 minutes ago, ctaranto said:

Ah.  That's what you meant by using the Debian package.  Thanks!  I'll give that a shot.

Update: That died a quick death.  The ffmpeg-emby that is installed by Arch is statically linked (21MB).  The ffmpeg installed by the Arch itself is 275KB (dynamically linked).  The ffmpeg inside of the Debian X64 package is also dynamically linked (275KB).  Unfortunately, that package expects the dependent libraries to be in the "Debian" locations, not the Arch locations.  I'm sure even if it could find the libraries, they would be out of sync (Arch is always at the latest; Debian is release-based).

./ffmpeg-emby: symbol lookup error: ./ffmpeg-emby: undefined symbol: avfilter_alloc, version LIBAVFILTER_7

The ffmpeg in the Debian package is self-contained, i.e. it includes everything, the ffmpeg libs, all dependent libs, even the Intel drivers with libva, etc in the lib folder of the installation.
Essentially, it shouldn't use anything from the OS folders, but all from the lib folder of the package instead.

Link to comment
Share on other sites

ctaranto

Thanks again.  I just discovered (through reading another thread) the Emby Diagnostic plugin.  This will hopefully let me put the Debian ffmpeg (and all libraries) into it's own folder segmented away from the OS libraries, and point emby to that ffmpeg executable. 

Link to comment
Share on other sites

Also look at the emby server startup script. You might need to make some adjustments there to env variables being set.
(the purpose of the emby-ffmpeg, emby-ffprobe stubs is only to allow running those for testing from the command line but with the same environment in which the server runs them)

Link to comment
Share on other sites

ctaranto

Thanks again, sw.  I found the post you were referring to

Following that, I was able to get the debian ffmpeg working with my Arch (Manjaro) emby server.  Hardware decoding works and tone-mapping options appeared in the advanced transcoding menu!

 

Edited by ctaranto
  • Like 1
Link to comment
Share on other sites

ctaranto

Appears to be working perfectly!

>>>>>>  Processing Plan
Info    Name                                        CanDoInHardware      WillDoInHardware     Reason                                  
Info    NVDEC NVIDIA GeForce GTX 1660 SUPER -... >> True                 True                 Hardware Codec                           
Info    VideoInput                               >> True                 True                 Matching hardware context                
Info    Scaling                                  >> True                 True                                                          
Info    ToneMapping (when possible)              >> True                 True                                                          
Info    VideoOutput                              >> True                 True                 Hardware encoder                         
Info    NVENC NVIDIA GeForce GTX 1660 SUPER -... >> True                 True                 Hardware Codec                           

>>>>>>  Projected Processing Formats
Info    Previous                HW-Context   Format       SW-Format           Size   Next
Info    hevc                 >> CUDA         cuda         yuv420p10      3840x2160 >> scale_cuda
Info    scale_cuda           >> CUDA         cuda         yuv420p10      1920x1080 >> setsar
Info    setsar               >> CUDA         cuda         yuv420p10      1920x1080 >> setparams
Info    setparams            >> CUDA         cuda         yuv420p10      1920x1080 >> tonemap_cuda
Info    tonemap_cuda         >> CUDA         cuda         nv12           1920x1080 >> 


Everything comes back as True/True.  Jumping around a movie is quick.  Very little CPU load.

Thanks everyone (especially sw)!

 

  • Like 1
Link to comment
Share on other sites

Thanks for the feedback, you're welcome. 

PS: We're thinking about ways to make this easier for Arch/Manjaro users in the future.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...
On 4/19/2022 at 5:02 PM, softworkz said:

 

PS: We're thinking about ways to make this easier for Arch/Manjaro users in the future.

And this is in our 4.7 stable package. Thanks.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...
ctaranto

I recently updated to 4.7.5 and tried the included stable packages of ffmpeg.  Unfortunately, this didn't allow for hardware decoding on Manjaro on my system (fully updated as of today).

I then reverted back (using Diagnostic Options / FFmpeg Options) to override ffmpeg, ffprobe, and ffdetect to continue to use the Ubuntu versions.  I seems that 4.7.5 isn't honoring those overrides anymore.  Here's an excerpt from the transcoding log.  Note how the ffmpeg being used is /usr/bin (the default) and not /opt/emby-server/bin like I have set in the Diagnostic Options.

Also, when I don't override ffmpeg, I do not see any Tone Mapping options.  When I override it, I do see those options. 

I then edited /etc/conf.d/emby-server to point to the Ubuntu binaries.  This did make the transcode log change to show it using those binaries, but it now shows that "superscale_cuda" isn't supported (which it used to be before 4.7).

 

Update:  After sleeping on it, I figured I would update the Ubuntu ffmpeg binaries from the 4.7.5 release.  Doing this solved the problem.

 

Quote

2022-07-31 21:40:06.374
Operating System: Linux version 5.4.207-1-MANJARO (builduser@fv-az108-856) (gcc version 12.1.0 (GCC)) #1 SMP PREEMPT Fri Jul 22 07:12:32 UTC 2022
OS/Process: x64/x64
Emby Server version: 4.7.5.0
Operating system: Unix 5.4.207.1
Command Line: /usr/lib/emby-server/EmbyServer.dll -programdata /var/lib/emby -ffdetect /usr/bin/ffdetect-emby -ffmpeg /usr/bin/ffmpeg-emby -ffprobe /usr/bin/ffprobe-emby -restartexitcode 3

App: Emby Web 4.7.5.0
Chrome Windows

http://172.20.0.166:8096/emby/videos/2507234/main.m3u8?DeviceId=614be3e2-adda-435b-bf6a-c1c0d14b6245&MediaSourceId=abec581fbd85326589c7dfcae1d8ca2c&PlaySessionId=42f1e2b466db4040aa73f25c4e6f01e4&api_key=8b56f06e4d594be697e593702f241506&VideoCodec=h264&AudioCodec=ac3,mp3,aac&VideoBitrate=19616000&AudioBitrate=384000&AudioStreamIndex=1&TranscodingMaxAudioChannels=2&SegmentContainer=m4s,ts&MinSegments=1&BreakOnNonKeyFrames=True&ManifestSubtitles=vtt&h264-profile=high,main,baseline,constrainedbaseline,high10&h264-level=52&TranscodeReasons=ContainerBitrateExceedsLimit

http://172.20.0.166:8096/emby/videos/2507234/hls1/main/0.ts?PlaySessionId=42f1e2b466db4040aa73f25c4e6f01e4

{"Protocol":"File","Id":"abec581fbd85326589c7dfcae1d8ca2c","Path":"/storage/red2/movies/10 Cloverfield Lane.mkv","Type":"Default","Container":"mkv","Size":45752504721,"Name":"10 Cloverfield Lane","IsRemote":false,"RunTimeTicks":62147930000,"SupportsTranscoding":true,"SupportsDirectStream":true,"SupportsDirectPlay":true,"IsInfiniteStream":false,"RequiresOpening":false,"RequiresClosing":false,"RequiresLooping":false,"SupportsProbing":false,"MediaStreams":[{"Codec":"hevc","Language":"eng","ColorTransfer":"smpte2084","ColorPrimaries":"bt2020","ColorSpace":"bt2020nc","TimeBase":"1/1000","VideoRange":"HDR10","DisplayTitle":"4K HEVC HDR10","DisplayLanguage":"English","IsInterlaced":false,"BitRate":58894968,"BitDepth":10,"RefFrames":1,"IsDefault":true,"IsForced":false,"Height":2160,"Width":3840,"AverageFrameRate":23.976025,"RealFrameRate":23.976025,"Profile":"Main 10","Type":"Video","AspectRatio":"16:9","Index":0,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Protocol":"File","PixelFormat":"yuv420p10le","Level":153,"IsAnamorphic":false,"AttachmentSize":0},{"Codec":"truehd","Language":"eng","TimeBase":"1/1000","DisplayTitle":"English TRUEHD 7.1 (Default)","DisplayLanguage":"English","IsInterlaced":false,"ChannelLayout":"7.1","BitDepth":24,"Channels":8,"SampleRate":48000,"IsDefault":true,"IsForced":false,"Type":"Audio","Index":1,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Protocol":"File","AttachmentSize":0},{"Codec":"dts","Language":"eng","TimeBase":"1/1000","DisplayTitle":"English DTS-HD MA 7.1","DisplayLanguage":"English","IsInterlaced":false,"ChannelLayout":"7.1","BitDepth":24,"Channels":8,"SampleRate":48000,"IsDefault":false,"IsForced":false,"Profile":"DTS-HD MA","Type":"Audio","Index":2,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Protocol":"File","AttachmentSize":0},{"Codec":"PGSSUB","Language":"eng","TimeBase":"1/1000","Title":"English-PGS","DisplayTitle":"English (Default PGSSUB)","DisplayLanguage":"English","IsInterlaced":false,"IsDefault":true,"IsForced":false,"Type":"Subtitle","Index":3,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Protocol":"File","AttachmentSize":0,"SubtitleLocationType":"InternalStream"},{"Codec":"PGSSUB","Language":"eng","TimeBase":"1/1000","Title":"English-SDH-PGS","DisplayTitle":"English (PGSSUB)","DisplayLanguage":"English","IsInterlaced":false,"IsDefault":false,"IsForced":false,"Type":"Subtitle","Index":4,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Protocol":"File","AttachmentSize":0,"SubtitleLocationType":"InternalStream"},{"Codec":"mjpeg","ColorSpace":"bt470bg","TimeBase":"1/90000","IsInterlaced":false,"BitDepth":8,"RefFrames":1,"IsDefault":false,"IsForced":false,"Height":176,"Width":120,"RealFrameRate":90000,"Profile":"Baseline","Type":"EmbeddedImage","AspectRatio":"15:22","Index":5,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Protocol":"File","PixelFormat":"yuvj444p","Level":-99,"AttachmentSize":0},{"Codec":"mjpeg","ColorSpace":"bt470bg","TimeBase":"1/90000","IsInterlaced":false,"BitDepth":8,"RefFrames":1,"IsDefault":false,"IsForced":false,"Height":120,"Width":213,"RealFrameRate":90000,"Profile":"Baseline","Type":"EmbeddedImage","AspectRatio":"71:40","Index":6,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Protocol":"File","PixelFormat":"yuvj444p","Level":-99,"AttachmentSize":0},{"Codec":"mjpeg","ColorSpace":"bt470bg","TimeBase":"1/90000","IsInterlaced":false,"BitDepth":8,"RefFrames":1,"IsDefault":false,"IsForced":false,"Height":882,"Width":600,"RealFrameRate":90000,"Profile":"Baseline","Type":"EmbeddedImage","AspectRatio":"100:147","Index":7,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Protocol":"File","PixelFormat":"yuvj444p","Level":-99,"AttachmentSize":0},{"Codec":"mjpeg","ColorSpace":"bt470bg","TimeBase":"1/90000","IsInterlaced":false,"BitDepth":8,"RefFrames":1,"IsDefault":false,"IsForced":false,"Height":600,"Width":1067,"RealFrameRate":90000,"Profile":"Baseline","Type":"EmbeddedImage","AspectRatio":"1067:600","Index":8,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Protocol":"File","PixelFormat":"yuvj444p","Level":-99,"AttachmentSize":0}],"Formats":[],"Bitrate":58894968,"RequiredHttpHeaders":{},"ReadAtNativeFramerate":false}

>>>>>>  User policy for Craig
        Enable Playback Remuxing: True
        Enable Video Playback Transcoding: True
        Enable Audio Playback Transcoding: True

>>>>>>  Hardware Decoders for hevc
        [X] NVDEC NVIDIA GeForce GTX 1660 SUPER - H.265 (HEVC)
        [ ] CUVID NVIDIA GeForce GTX 1660 SUPER - H.265 (HEVC)

>>>>>>  Hardware Encoders for h264
        [X] NVENC NVIDIA GeForce GTX 1660 SUPER - H.264 (AVC)

>>>>>>  Selected Codecs
Decoder NVDEC NVIDIA GeForce GTX 1660 SUPER - H.265 (HEVC)
        Adapter #0: 'NVIDIA GeForce GTX 1660 SUPER' ComputeCapability: 7.5
        Max Bitrate: 117 Mbit/s - Frame Sizes: 144x144...8192x8192 - Width Alignment: 2 - Height Alignment: 2
        Color Formats: NV12, P010, P016 - Bit Depths: 8, 10, 12, 14, 16
        Profiles: Main Profile (Level 6.1), Main 10 Profile (Level 6.1), Range Extension (REXT) (Level 6.1)

Encoder NVENC NVIDIA GeForce GTX 1660 SUPER - H.264 (AVC)
        Adapter #0: 'NVIDIA GeForce GTX 1660 SUPER' ComputeCapability: 7.5
        Max Bitrate: 781 Mbit/s - Frame Sizes: max 4096x4096 - Width Alignment: 2 - Height Alignment: 2
        Color Formats: NV12, P010, P016 - Bit Depths: 8, 10, 12, 14, 16
        Profiles: Baseline Profile (Level 6.2), Main Profile (Level 6.2), High Profile (Level 6.2), High 4:4:4 Predictive Profile (Level 6.2)


>>>>>>  FindVideoEncoder - MediaType: h264, UseHardwareCodecs: True, HWA-Mode: Advanced
Info    Checking: 'NVENC NVIDIA GeForce GTX 1660 SUPER - H.264 (AVC)'
Info    Check successful - selecting 'NVENC NVIDIA GeForce GTX 1660 SUPER - H.264 (AVC)'

>>>>>>  FindVideoDecoder - MediaType: hevc, UseHardwareCodecs: True, HWA-Mode: Advanced
Info    Checking: 'NVDEC NVIDIA GeForce GTX 1660 SUPER - H.265 (HEVC)'
Info    Check successful - selecting 'NVDEC NVIDIA GeForce GTX 1660 SUPER - H.265 (HEVC)'

>>>>>>  Processing Plan
        Name                                        CanDoInHW  WillDoInHW  Reason                                                 
        NVDEC NVIDIA GeForce GTX 1660 SUPER -... >> True       True        Hardware Codec                                          
        VideoInput                               >> True       False       Matching hardware context                               
        Scaling                                  >> False      False       Ffmpeg does not include 'superscale_cuda' filter        
        ToneMapping (when possible)              >> False      False       Ffmpeg does not include 'superscale_cuda' filter        
        VideoOutput                              >> True       True        Hardware encoder                                        
        NVENC NVIDIA GeForce GTX 1660 SUPER -... >> True       True        Hardware Codec                                          

>>>>>>  Video Processing Steps for [0:0]: H.265 (HEVC)
        Step                    HW-Context   Format       SW-Format           Size   Next
        HEVC                 >> -            yuv420p10    yuv420p10      3840x2160 >> scale
        scale                >> -            yuv420p10    yuv420p10      1920x1080 >> format
        format               >> -            yuv420p      yuv420p        1920x1080 >> 
 

 

Edited by ctaranto
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...