Back to Blog
homelab
7 min read

Jellyfin stutters: Transcoding

A follow-up to my arr stack post: how Jellyfin chooses between direct play and transcoding, why one TV stuttered on a 4K Dolby Vision film, and why the Raspberry Pi struggles.

Tang Yetong
Tang Yetong
Full Stack Developer and former Data Analyst Intern at Fivetran with a background in government digital services and blockchain technology.

At the end of my arr stack post I wrote that the TVs "can stream pretty smoothly most of the time" and that transcoding was outside the scope of the blog. This is the blog about the transcoding part, now that I've had the setup running for a few weeks.

I would say that transcoding is one of the biggest pain points of running the arr stack on a Raspberry Pi instead of a mini PC. To sum up transcoding: a video file is a bundle of a video format, one or more audio formats, and a container around them. A TV can only play the formats its hardware and app understand, and older TVs understand fewer of them. Jellyfin handles that in one of three ways:

Diagram · how Jellyfin plays a file3 ways, 4 cases
A video file is a bundle
Container.mkv, .mp4VideoHEVC, Dolby VisionAudioAAC, AC3

The TV can only play the formats its hardware and app understand, so Jellyfin checks every part of the bundle against what the TV can take.

Direct play
Sent as it isSent as it isSent as it is
Almost nothing
Direct stream
RepackagedSent as it isSent as it is
Cheap
Transcode · audio only
Sent as it isSent as it isConverted
Fairly cheap
Transcode · video
Sent as it isRe-encodedSent as it is
Heavy
UntouchedRepackaged, no re-encodingConvertedRe-encoded

The Pi struggles with video because it has no hardware video encoder, so the work lands on its CPU. Many mini PCs can hand this job to their graphics hardware, such as Intel's Quick Sync, so the same transcode barely registers.

This one is more of a notes post than a tutorial.

The stutter

One night my parents put on Fury on the TV and it stuttered badly. Not a dropped frame here and there, but stop-start playback, as if the network was lagging. There were a few guesses as to why that was happening, for example the Ethernet being too slow for the 4K movie that was being streamed, transcoding, and so on, but it was only one movie, so I shrugged and moved on.

The next night The Departed did the same thing. The movie was borderline unwatchable, so I went looking.

Look at the session, not the device

Jellyfin's dashboard shows every live session (Profile → Dashboard), and for each one it tells you whether it is "Direct playing" or transcoding, and why. Open it while the stutter is happening and the reason is usually right there in the live session information.

Here is what it showed for the TV (running the Jellyfin Android TV app 0.20.0):

Readout · the live sessionDashboard
Jellyfin Android TV 0.20.0Transcoding
Video4K · Dolby VisionRe-encodedHeavy
AudioItalian, EnglishDolby Digital (AC3) 5.1AACConverted
12frames per secondVideo encoding speed
Standing stillReal time

The TV's app told Jellyfin it can't play AC3, so the audio gets converted. The video is re-encoded at about half of real time, so it stutters.

Why one TV converts what another plays

The TV, or really the Jellyfin app running on it, tells Jellyfin which formats it can decode. Jellyfin checks every part of the file against that list. Whatever is on the list plays as it is, and whatever is missing gets converted. That is why the same file can direct play on one TV and transcode on another. The file doesn't change, the list does.

A file has several things in it: the container around everything, the video, the HDR on top of it, the audio and any subtitles. Each comes in several formats, and the TV has to understand each one it meets.

Guide · formats and who plays themRough guide, not a rule
Container
MP4The most widely supported container.Almost everywhere
MKVUsed by most releases. A TV that doesn't like it but is fine with what's inside only needs a direct stream, which is cheap.Most modern TVs
Video
H.264 (AVC)The old reliable. Most 1080p releases use it.Almost everywhere
HEVC (H.265)Smaller files at the same quality. Nearly every 4K release uses it.Most modern TVs
AV1The newest, with the best compression. Still rare in releases.Depends on the TV
HDR
HDR10The baseline HDR that most 4K TVs understand.Most modern TVs
Dolby VisionHDR with extra scene-by-scene data. Needs a TV and app that support it, otherwise the picture may have to be converted.Depends on the TV
Audio
AACCompact and everywhere. Usually stereo or 5.1.Almost everywhere
AC3 (Dolby Digital)The classic 5.1 track on DVDs and many releases.Most modern TVs
E-AC3 (Dolby Digital Plus)The newer Dolby track used by streaming releases. It can carry Atmos.Most modern TVs
DTSThe other big surround format. Often missing on TVs.Depends on the TV
TrueHD, DTS-HD MALossless Blu-ray and 4K audio. Big, and usually needs a soundbar or receiver to handle it.Depends on the TV
Subtitles
SRT (text)Plain text that the app draws itself, so there is nothing to convert.Almost everywhere
PGS (image)Pictures from Blu-rays. Can force Jellyfin to burn them into the picture, which means re-encoding the video.Often burned in

Which formats a TV can play depends on its chip and on the app running on it, so treat the bars as a rough guide. Dolby and DTS formats need licences, which is part of why cheaper and older TVs skip some of them.

So the cheap, easy combination is H.264 video with AAC audio, because nearly everything plays it. The risky one is the opposite end: Dolby Vision video with a Dolby or DTS audio track. Any one of those can be the thing a particular TV doesn't understand.

What Radarr and Sonarr will actually download

Radarr (movies) and Sonarr (TV) know nothing about your TVs. They pick a release using the quality profile you give them, and a quality profile is mostly about resolution and source (for example 1080p Blu-ray or 2160p WEB-DL), with a size range. It says nothing about the video codec or the audio.

Custom formats are where you can be pickier. A custom format matches words in the release name, like x265, DV, Atmos or TrueHD, and gives it a score. Give a format a positive score to prefer it, or a negative one to avoid it. Without any, a 4K profile will happily grab whichever release ranks best for that quality, Dolby Vision and Dolby audio included. That is how a file like this one ended up on the Pi. Radarr and Sonarr also never convert anything. They download the release as it is.

The tags in a release name are what you can match on. Here are two made-up examples, taken apart:

Decoder · reading a release nameExample names, not real releases
The kind that needs transcoding for me
2160pResolution (4K)WEB-DLSource (a streaming service)DVDolby VisionHDRHDR10DD5.1AC3 audio (Dolby Digital)H.265HEVC video

Plays fine on a TV that handles Dolby Vision and Dolby audio. Otherwise the Pi has to convert it.

The kind that nearly always direct plays
1080pResolution (Full HD)WEB-DLSource (a streaming service)AAC2.0AAC stereo audioH.264AVC video

Both formats are understood almost everywhere, so there is nothing for the Pi to convert.

The audio was cheap, the video wasn't

Converting audio on its own is cheap, even for a Pi. If AC3 to AAC was the only thing happening, I'd never have noticed.

The expensive part was the video. The session showed the picture being re-encoded as well, and the Raspberry Pi 5 has no hardware video encoder, so that happens in software on the CPU. The CPU can only manage 12 frames per second, which is half of real time.

Converting AC3 doesn't normally force a video re-encode, so the picture was probably being converted for its own reason, most likely the Dolby Vision or HDR handling. The dashboard lists the transcoding reason for each stream, so that is the place to confirm it. Either way, this is what happened to this file:

Diagram · where the stutter comes fromAudio and video
The audio
The video
My other TVNo Time to Die has AAC audionothing to convertDirect play

That also explains why my other TV was fine. It direct-played No Time to Die because that file's audio is AAC, so there was nothing to convert.

The fix: get the TV to accept AC3

If the TV plays AC3 as it is, nothing gets converted and the Pi never has to touch the video. All of this is in the TV's Jellyfin app, under Settings → Playback:

Checklist · Settings → PlaybackOne at a time

Change one setting at a time and check the dashboard in between, so you know which one made the difference.

The fallback: stop downloading Dolby Vision

If none of those settings work, then that TV can't play Dolby audio through this app, and I can't fix that from the Pi.

What I can do is change what comes in. In my case, the Dolby Vision release is the one where the video got re-encoded as well, so the fallback is to tell Radarr to avoid them. A 4K HDR10 or a 1080p release with the same audio would at worst cost the Pi an audio conversion.

On the other hand, a TV streamer is coming

The house is getting a TV streamer, and the hope is that it takes some of the transcoding off the Pi and lets us play more video formats. That is mostly true, but not quite the way I first pictured it.

A streamer doesn't transcode anything on the Pi's behalf. What it does is run the Jellyfin app on better hardware, with a decoder that understands more formats (HEVC, Dolby Vision, Dolby Digital and so on) and usually the licences for them. When the app tells Jellyfin "I can play that", Jellyfin direct plays and the Pi just sends the file. So the conversion doesn't move to the streamer, it stops being needed.

Diagram · where the work goesWhy a streamer helps

There are catches. Streamers differ a lot, so check the specs for the formats from the guide above (HEVC, Dolby Vision, Dolby Digital and Digital Plus) before buying. The TV and soundbar still matter, since the streamer can decode Dolby Vision but the TV has to be able to show it, and lossless audio like TrueHD needs a soundbar or receiver to handle it. And whatever the streamer still can't play will still land on the Pi.

A graph I can look at without opening a terminal

While I was at it, I wanted something nicer than SSH to see what the Pi was doing. I set up Beszel, a lightweight monitoring dashboard, and it showed the Pi straight away. It's at port 8090 on the Pi.

For "what happened last night", I pick 12 or 24 hours and look at the CPU and the disk charts.

Beszel can also send alerts when a threshold is crossed, but it needs a notification method such as email set up first, which I haven't done yet.

Tags

Jellyfin
Transcoding
Raspberry Pi
Dolby Vision
Radarr
Sonarr
Beszel
Self-hosted
Homelab
Tang Yetong

Tang Yetong

Full Stack Developer and former Data Analyst Intern at Fivetran with a background in government digital services and blockchain technology.

Related Articles

Featured image for Jellyfin stutters: Heavy processing
4 mins

Jellyfin stutters: Heavy processing

homelab

A follow-up to my transcoding post: Jellyfin stuttered on direct play too. The Pi's CPU was at 90%+ because qBittorrent and Bazarr were working through four seasons of a show at once.

Jellyfin
qBittorrent
Bazarr
+5
Read Article: Jellyfin stutters: Heavy processing
Featured image for Jellyfin: Avoiding subscriptions like the plague
14 mins

Jellyfin: Avoiding subscriptions like the plague

homelab

How I set up an arr stack (Jellyfin, Radarr, Sonarr, Prowlarr and qBittorrent) with Docker Compose on a Raspberry Pi 5 8GB and a 1TB external hard drive.

Arr Stack
Raspberry Pi
Docker
+5
Read Article: Jellyfin: Avoiding subscriptions like the plague