Transcoding 4K movies with PGS subtitles

Server Version#: 1.24.5.5173

My Server:
OS: Unraid
CPU: Intel i7-5930K
GPU: GTX 1080Ti
RAM: 16GB

My client:
Samsung QN90A TV.

My problem:
Most 4K Blu-ray rips use PGS subtitles, which I have discovered is an image-based format that my TV doesn’t support natively, so Plex is forced to transcode and burn-in the subtitles into the video stream.

I installed the GTX 1080Ti and enabled hardware transcoding to attempt to get these 4k rips playing properly on my TV, but still it will not play without buffering. If I try playing without subtitles, but still force transcoding, they play flawlessly.

My questions:
Do PGS subtitles prevent NVENC from operating properly? If so, is there any way around this?
Would using a modern Intel CPU with Quicksync work any better than with my 1080Ti?

Plex Transcoder Statistics.log (31.0 KB)

Yes, Burning subtitles (VOBSUB, DVDRIP, or PGS) impede HW transcoding.

What you see is:

  1. HW decode
  2. CPU subtitle burning on each video frame
  3. HW encode of the resultant video frame.

When subtitle burning is active, the transcoder ‘(HW)’ output is suppressed so you know it’s not doing everything in HW.

1 Like

Thanks for the info @ChuckPa , good to know why it isn’t working. Is there some way I could upgrade my server to make this work, or is 4k video with burned subtitles currently an impossibility on Plex?

@talsemgeest

If, as part of your media curation process, you take the time to burn in the one subtitle which you will use, leaving only audio and video streams in the file, hardware transcoding will then work normally.

This is because the subtitle text will have become an integral part of the image. The video won’t reflect “subtitle” status. PMS will be able to use all hardware.

Now, if you have a strong enough machine, (i7-7700 or above), you won’t notice the burning until you get more than 3 streams burning 4K subtitles and transcoding audio.

Well, I do have a i7-8700 an whenever I try to transcode a 4K movie (HDR) with hw transcoding turned on and a subtitle that is not supported by the player (for example pgs in Plex Web or VobSUB in Android), the movie buffers every 10 to 15 seconds. The CPU is at 20% average.

If I look at the cmd used for transcoding I can see that hw decoding and encoding is fully working, so what is the bottleneck here? Maybe the software tonemapping or the data transfer to the gpu?

This complex filter is used by the plex transcoder:
[0:5]scale=3840:2160[0];[0:0][0]overlay[1];[1]scale=w=1280:h=720:force_divisible_by=4[2];[2]format=p010,tonemap=mobius[3];[3]format=pix_fmts=nv12[4];[4]hwupload[5]

Alternatively, acquire a SRT version of the subtitles (at the interwebs) or convert the PGS stream to SRT. Introduction: convert image-based subtitles to SRT with Subtitle Edit

Thanks alot for the reply, but I’m already doing this to circumvent this problem. I’m just curious why this is happening and if there is a solution to this problem. If it should be possible to watch three streams in parallel with burning, I wonder why I am not able to watch a single one.

I also tried it with tonemapping turned off, but the problem still remains. (However, it seems that it buffers slightly less often). It is also happening on my second plex server (i7-7700 root server at Hetzner).

In my opinion this means that the bottleneck is caused by either burning in the subtitles or the data-transfer (after decoding the video it has to be transferred to the cpu for software image processing and then back to the gpu for encoding).

If this is true, it means that the only possible solution to this problem is to do the subtitle burning with the gpu (if that is possible at all). According to ffmpeg there is a filter that can be used to to image overlay with opencl, but I don’t know if it can be used to do an overlay of image-based subtitles. (FFmpeg Filters Documentation )

I believe that this is the same issue that is described here:

Thus, I think that a solution to this would help many of us who are struggling with 4K movies.

I disabled tonemaping and not hw transcoding. By that I wanted to exclude that software tonemapping is the bottleneck.

Image subtitle burning is limited to a single thread so it doesn’t matter what your overall CPU usage is but rather what a single core’s usage is (as well as memory bandwidth and bandwidth between the GPU). Your bottleneck is likely a combination of the above. So when you have 20% CPU usage, you likely have a single core that’s pegged at 100% doing this process.
To summarize, for each frame between the GPU decoding the frame and reencoding it:

  • The hardware decodes in a process parallel to the CPU
  • The CPU copies the decoded image frame out of the GPU. That’s going to be ~16-32MB (depend on the exact format used)
  • The CPU then has to burn in subtitles (a single threaded process)
  • The CPU copies this final image into the GPU for encode

That has to be done 24x a second (assuming you are playing content that’s 23.976fps). It wasn’t long ago that people were struggling to burn in PGS subtitles on 1080p content when they were fully capable of transcoding entirely in software when not burning in.

2 Likes

Thank you very much for this detailed response.

So I assume that I have the following options:

  1. Continue to convert (at least forced) subtitles to srt as a workaroud.

  2. Switch to a CPU with an even higher single core performance than a i7-8700 (but I don’t know what performance is sufficient).

  3. Force all my family members to always use a reasonable player that supports all kinds of subtitles. (But I doubt that they would be happy about it or even understand what I am talking about :rofl: ).

Nevertheless, thanks a lot for taking the time to respond. I really appreciate it. :plexheart:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.