Skip to content

Instantly share code, notes, and snippets.

@bogsen
bogsen / fix-plex-hdr-subtitles.md
Last active June 28, 2024 13:46
Fix Plex transcoding HDR videos very slowly when burning subtitles in at the same time

What?

For some reason, although Plex supports hardware-accelerated HDR tone mapping, Plex decides not to use it when subtitles need to be burned in. This results in extremely slow transcoding on hardware that should be able to keep up using hardware acceleration. I've noticed this issue on my server with Intel QuickSync, and this fix is made specifically for that case.

Before the fix, the SW tone mapping was only able to do 6-7 fps on a i5 7400T for an HDR 4K->1080p transcode. With the fix, that same transcode happens with HW tone mapping, and goes up to 82 fps. Even for HDR 4K->4K, this CPU is able to do 35 fps using QuickSync, thus keeping up with at least one video stream.

#!/usr/bin/env python
from evdev import InputDevice, list_devices, ecodes
from os import system
FILTER_ALL = 0x10
FILTER_STYLUS = 0x04
DEFAULT_FILTER = FILTER_ALL
device = None
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
int main() {
int fd = open("/dev/fb0", O_WRONLY);
while (1) {
ioctl(fd, 1074032001);
sleep(1);
}