Pixel Format
After tinkering with my media machine I found myself with some media played in Kodi where the audio worked fine, but the video showed seconds per frame. This also resulted in hundreds of skipped frames and occasional buffering. Basically, it was unwatchable. What I found curious was that it worked fine on both Chromecast gen1 and my Sony Blue-Ray. Or at least partly, but that is outside the scope of this article, but gave some hints that something was not correct. I therefore went to investigate.
The clue was that only some of the videos had this issue, so I first checked if there was some difference with the format. Luckily, Emby displays media info, and while I first thought it was related to the bit rate, one thing that stood out was that the one “Pixel Format” 1, the one that worked using yuv420p
and the ones that did not was using yuv420p10le
2. After looking around for a while I found out that while Raspberry Pi 4 supported 4K with hardware decoding, it did not support HDR video. That is, it support 8-bit (SDR), but not 10-bit (HDR) 3 4. This was a vital clue to the reason behind the choppy playback, but I now just had to solve it somehow with my current media library.
Therefore I dove back into ffmpeg to figure out how it can check and convert the pixel format. Probe gave the information for each stream, so it was just to grab that and store it away. Then it was just to add a --compat
flag where it always converts to yuv420p
for compatibility to Raspberry Pi. Finally it was just a matter to add a filter on top of the existing filters to make the conversion 5. There may be a reason to add more to the list if necessary.
Finally I tried it on one video, and it worked on the first try. Now on to converting all videos I have already converted, which should take a couple of hours.