Color corruption on resize when HW Transcoding HEVC content - Synology DS918+ NAS

Same issue in above thread, which was closed last month without it being resolved. Does plex have an ETA for this issue ruining playback for HEVC files that has been present for over a year now?

I am unsure how to apply the script fix as outlined by jaB00M as I am unable to access @appstore.

This colour corruption is not due to HDR -> SDR tone mapping - the scale_vaapi filter just seems broken for Apollo Lake series CPUs found in the DS-X18+ series NASs.

As shown in the linked thread, it causes stripy image corruption when 10bit HEVC files are resized with hardware transcoding, not the washed out tone mapping problem. 10bit colour does not mean HDR btw, (and I encode all my SDR videos with it as it massively reduces banding artifacts).

The problem was avoidable with a script I put together ages ago in the linked thread - but this stopped working with the new transcoder with Plex Server 1.17, so if you’re wanting to use it - stick to 1.16 or earlier.

It’s on my to-do list to update the wrapper script to the new transcoder, as it’s clear this issue has zero priority at Plex. It’s also not a problem with Emby Media Server if you want to use that instead (I’m kind of sick of applying this patch to Plex every release for an issue I fixed FOR THEM over a year ago). Sure - the Apollo Lake bug is in the Intel vaapi drivers, but it’s very avoidable, and Plex is a product (though admittedly one that seems more focused on becoming a 3rd party content portal)

1 Like

@jaB00M We believe we may have a solution to this, and i’ll share a PMS build with you when have have something working. Thank you for the updated report :slight_smile:

jaB00M Thank you for all the work you have done over the past 1-2 years on trying to solve this problem on Plex’s behalf. Unfortunately i have already upgraded PMS to the server version not compatible with your fix.

trumpy81 Please read the link attached in the OP so you can understand the problem. Your response is not addressing the issue at hand. chrisallen looks like he will be managing the problem in the future if you wish to liaise with him.

chrisallen Thank you for following up on this issue. Please let me know if you would like me to collate the previous threads with people trying to fix the same issue. I am also happy to test the PMS build with the proposed solution if that would help.

Considering the effort and expertise jaB00M has provided to date, it would be great for Plex to prioritise a fix for what is considered a major issue considering the increased use of HEVC content. I imagine the fix would be relatively straightforward and quick for Plex to implement from the solution jaB00M has provided in the past.

Having dug into this, the breaking change seems to be that the input to the vaapi h264 encoder now looks like it has to be in nv12 format (previously it seemed to be okay to avoid the explicit surface format conversion).

Anyhow - since the single scale_vaapi format AND rescale seems to be broken, but either on their own seem fine - I’ve split the scale and format into two stages in the filter pipeline - and the world appears good again.

#!/bin/sh
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
declare -a new_args
forbidden_text=":format=nv12"
replacement_text="[0];[0]scale_vaapi=format=nv12"
for param in "$@"; do
  new_args+=("${param//$forbidden_text/$replacement_text}")
done

"${DIR}/Plex_Transcoder" "${new_args[@]}"
3 Likes

Thanks @jaB00M we have some nice improvements coming that should resolve your issue here. I’ll let you know as soon as I have a preview build to share :slight_smile:

2 Likes

It works, you are my Hero @jaB00M!

Thanks jaB00M! Plex should get you on payroll! :slight_smile:

chrisallen do you know when jaB00M’s fix will be implemented? If it is soon then I will avoid trying to get access to @appstore and just wait for an official/preview build.

Please note chrisallen that jaB00M fixed this problem last year as well and it was never implemented into an official build. It would be unfair to jaB00M for the community to continually rely on his/her contribution to fix the same bug in the future.

@Cosm0 / @jaB00M / @pal05 Please install PMS 1.18.1 which should resolve this issue.

3 Likes

Thanks chrisallen - installed and briefly tested, the issue appears to have been fixed!

Massive thanks to jaB00M for all your work!

Hey @chrisallen, does this new version address any quality issues in HW transcoding from HEVC->x264?

Just tested it - and 10bit videos are scaling as nature intended - Thank you!!! :slight_smile:

Glad to hear! :grinning:

Yes it should.

With first test it looks good now, however a particular file which was able to HW transcode (including the vertical strip issue) now revert to software decode:

Its a 4K HEVC Main 10 (no HDR) to 720p conversion which results in this error (however other files with similar specs work):

Oct 16, 2019 20:32:03.020	ERROR	[Transcoder] Error while processing the decoded data for stream #0:0
Oct 16, 2019 20:32:03.019	ERROR	[Transcoder] Failed to inject frame into filter network: Input/output error
Oct 16, 2019 20:32:03.018	ERROR	[Transcoder] Error while filtering: Input/output error
Oct 16, 2019 20:32:03.017	ERROR	[Transcoder] [Parsed_scale_vaapi_1 @ 0x1aeedc0] Failed to start picture processing: 1 (operation failed).

Yes it should as we now use the new intel-media-driver (iHD) for all newer generation processors.

Hey chrisallen, I just tested and it looks pretty bad compared to HW transcoding on v1.17.0.1709. Is this possibly something at the driver/Intel level external to Plex?
Let me know if there’s any additional info I can offer or start a new thread.

Please raise a new thread with a sample file and your server logs that cover the transcode session.

Hello
Can you explain, how to use you “hack” in Ubuntu? Thank you.

Afraid I don’t have an ubuntu machine so cant describe the steps exactly. In anycase, this workaround is no longer necessary as the issue has been fixed in the latest Plex Server releases.