I’m using a Synology DS918+ NAS (Intel Celeron J3455 with QuickSync)
I’ve a number of videos in HEVC format - and am using the hardware transcode functionality to convert these to h264 as required.
If the video is resized as part of the transcode, I experience color corruption in the form vertical stripes - the intensity seems correct, but the red and blue coloring seems to seperate. Each stripe looks to be about 16 pixels - and is most noticable in red areas.
This only occurs if the video is resized - eg 1080p->720p. A straight 1080p->1080p transcode does not have this problem.
It also only seems to occur when transcoding h265 to h264, I’ve not seen it in h264->h264 transcodes with resizes.
I’ve also a problem with 4K videos and subtitles.
Without subtitles - the NAS will happily transcode HEVC 4K to 1080p. With subtitles, although the CPU still reads only 10% (again - this is with hardware transcoding) - I get an error warning of a slow server, and the video will not play in real time.
Other than these issues - really impressed with Plex, I hope they can be corrected!
Forgot to mention - currently using Version 1.11.1.4730 (64bit) - but this issue has been present in all versions since I started using Plex a month ago.
I experience the exact same issue on my Synology DS218+ (Intel Celeron J3355, Apollo Lake iGPU).
Vertical bars are appearing, and is very annoying and degrading the global quality.
Here is an illustration of the problem :
The source file is an 1080p HEVC 10 bit movie. This occurs for example when I select 720p, 4 Mbps or any lower quality. If I select 1080p 8 Mbps, there is absolutely no problem, the image is clear even though it gets transcoded.
This issue is particularly annoying to me since I only have a 5 Mbps upload speed, so basically all my videos get transcoded to 720p 4 Mbps when I try to watch remotely.
I hope this gets fixed soon, but this issue is definitely still present with latest 1.13.0.5003 PMS (x64) version for Synology.
The problem doesn’t occur with 8bit video, but the hardware does support hardware decode of 10bit HEVC, (though admitedly only 8bit, not 10bit hardware encode of HEVC). Since Plex currently only encodes to 8bit h264 anyway, this isn’t a limitation of the hardware. As mentioned, there is no problem unless a resize is performed. The corruption appears to be from the resize getting the memory layout of the YUV format wrong, smearing the U and V components out of place.
It’s worth mentioning that Emby media server manages to resize and transcode the same files on the same hardware without this corruption. Plex and Emby both use FFMPEG under the hood from what I gather, so the problem is almost certainly with the wrong colour format being specified to the resize filter.
Also interesting is that forcing Plex to bake in subtitles also fixes the problem (though you now have subtitles baked in… not really a fix…), presumably because the colour space is correctly converted before the subtitle filter is applied (I guess this is done in RGB???)
This is basically taking the frame - making sure it’s in GPU memory, using a hardware scale to resize and convert the format to nv12, and then making sure this frame is in GPU memory.
To fix it - I guess either remove the :format=nv12 (as the buffer is staying in hardware for the encode - I’d have thought it can remain a vaapi surface?)
I’ve tried running the command directly on my DS918+ as the plex user, but for some reason it whines about being unable to connect to the vaapi device:
[AVHWDeviceContext @ 0x22c9d80] Failed to initialise VAAPI connection: -1 (unknown libva error).
Device creation failed: -5.
Failed to set value '/dev/dri/renderD128' for option 'vaapi_device': Input/output error
If one of the developers reads this and has an idea what’s wrong, I’d love to know.
Thanks for the sample and screenshots. I’m not reproducing this here, but I’m on a Kaby Lake processor, so it’s possible that this issue is processor-generation-specific. Could you test a few things for me:
Update to PMS version 1.13.0
Post the CPU model name from /proc/cpuinfo
Run a transcode with these simplified args (and the same env vars as a regular one):
And see if the resulting file has the chroma issue.
This looks to me as if either the scaler and encoder are miscommunicating regarding the plane format of the video, or the scaler is converting to the wrong format. The formats involved are NV12 (where the U and V components are interleaved in a single plane) and YUV420P (where the U and V components are in separate planes).
Unfortunately I’m having trouble kicking off the transcoder manually - and keep getting the following error:
[AVHWDeviceContext @ 0x336fc80] Failed to initialise VAAPI connection: -1 (unknown libva error).
Device creation failed: -5.
Failed to set value '/dev/dri/renderD128' for option 'vaapi_device': Input/output error
I’m guessing there’s an .so file not being found somewhere - I’ll dig into it and see.
[EDIT- Forgot to mention, this is using 1.13.0.5003]
I agree this is likely a miscommunication of surface formats somewhere in the pipeline. I’m trying to get my head round what the problem is though, because 10bit HEVC comes out in YUV420p10le - which is a plane of 2byte 10bit values for intensity, then a 1/4 resolution 2 byte 10bit U plane and a 1/4 resolution 2 byte 10bit V plane. YUV420p 8bit video only uses 1 byte for each component - so a mismatch would explain what looks to be happening with the UV, but the Y (intensity) - is correct (that is, the image is not being stretched weirdly over two frames). Odd.
Aha - yes, that got the transcode working - thanks
The output had the same colour problem though.
Changing scale_vaapi=w=1278:h=538:format=nv12 argument to just scale_vaapi=w=1278:h=538 fixed the colour problem.
Any chance this change could be made in a new release? I guess in the meantime it might be possible to create a proxy script to make this change on the fly.
Sorry, the conversion to NV12 is deliberate (on some hardware, it’s required); I’m hoping we can work out what’s causing the format mismatch within ffmpeg (or the VA driver) and get it resolved there. I’ll see if anybody here has an Apollo Lake system we can investigate further on, and keep you posted if I need any more information. Thanks for the help!
No problem at all - glad the information’s been useful, and hope you manage to get to the bottom of it.
Until the issue can be fixed properly, I’ve slightly hacked my install of Plex to work around the issue on my Synology DS918+.
In case anyone else with this problem is interested, I’ve renamed Plex Transcoder in the Plex installation directory (on my box this was /volume1/@appstore/Plex Media Server) to Plex_Transcoder - and saved the following script in its place (and made it executable).
#!/bin/sh
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
declare -a new_args
forbidden_text=":format=nv12"
for param in "$@"; do
new_args+=("${param//$forbidden_text/}")
done
"${DIR}/Plex_Transcoder" "${new_args[@]}"
Plex now hardware transcodes with resize from 10bit HEVC without corrupting the colour - and the world is good
This turns out to be a bug in the Intel driver when running on Apollo Lake hardware. You can follow the issue thread here; we’ll update the driver in PMS once it’s fixed: https://github.com/intel/intel-vaapi-driver/issues/398