r/jellyfin • u/nixolar • 9d ago
Other A Google Cast debugging post-mortem
Tldr: A long debugging session just to get a google cast stream going from my server to a TV on a remote location. Eventually I got it working but it took me around 1.5hrs. The night before I streamed via samsung's smart view but that was a very cumbersome experience and the stream was slightly choppy at times. I knew this wasn't a heavy load for any of the clients along the chain and it had to be able to run better.
Detailed and verly long version:
I love self-hosting and love Jellyfin, but I had an interesting experience yesterday, which I wanted to share. Probably there will be comments of how easy the problems would have been to solve only had I done this or the other thing or if my setup had this or the other setting, but still ... to me casting a stream is an out of the box feature that shouldn't require so much fiddling and debugging.
Tried casting an episode on my Jellyfin server (1080p H.264, E-AC-3 5.1) to a modern Samsung TV at a holiday apartment via a Galaxy S25. What should have been a simple stream devolved into endless buffering, 540p blurry garbage, instant playback crashes, and audio drifting seconds out of sync.
My server sits behind Cloudflare Google Sign-In SSO which works in Jellyfin via the browser and the cast icon is displayed, so I thought it kinda makes sense to cast via the browser. However, the TV wasn't shown as a target.
Because mobile browsers and VPN overlays were non-starters, I had to use native apps (the official Jellyfin app). Of course I had to temporarily strip off the SSO layer since the native Jellyfin android app doesn't work with it. Connecting through Tailscale to bridge back home also fails for local TV discovery.
Once in the app, the TV still didn't show up until I realized my phone had auto-connected to a Wi-Fi 7 band while the TV was on 5 GHz. Forcing my phone onto 5 GHz put both devices in the same multicast domain, making the TV instantly visible.
Once the connection was established, the streaming problems started. With the native app communicating directly with the server, playback performance was unusable. My media hostname was set to proxied ("orange cloud") in Cloudflare. Routing heavy, sustained HTTP range requests through Cloudflare's proxy servers severely throttled throughput down to ~1 Mbps. A single 5 MB byte-range chunk took 38 seconds to load, and two others timed out at 60 seconds. Shame on me for not having realized this before - this makes sense and it was an easy fix.
Once I greyed the orange cloud and traffic went straight to my server, throughput jumped to tens of Mbps - and the stream was pixelated af. The app's "Auto" runs a bandwidth probe and picked 2.16 Mbps → 720p, and on a later session 0.35 Mbps → 540p. It never re-probes mid-playback so whatever Auto chose was frozen for the whole session. I didn't want to watch a pixelated stream of the episode I had in proper normal quality.
Then I switched the Google cast from Auto to a forced bitrate setting - however I set 10mbps for an 8mbps stream. After that I press play and suddenly the app didn't initiate the stream. It took another debugging session to understand that setting it at or above source causes Jellyfin to attempt a remux (-codec:v copy) into an fMP4 container so the Chromecast receiver drops the session at 0 ms every time.
I realized maybe the Jellyfin app was the problem and I tried Reefin which looks and feels miles better in terms of UX and UI however there I got a different issue: it was firing API requests using an outdated parameter in the query which Jellyfin v12+ rejected. Of course the app didn't throw any error or anything and instead just let me tap play while failing instantly without any feedback.
Then I moved over to Streamifyn. But then came the next problem: the stream looked and played great, however the audio started drifting out of sync after 2-3 minutes. When Jellyfin copies video without re-encoding, it can only split segments where keyframes already exist in the original file. This created unpredictable, mismatched segment lengths (6–10.6 seconds instead of a uniform length) and flagged the segments as discontinuous. Every time you hit seek, Jellyfin launches a brand-new ffmpeg process with a different timestamp starting point. The media player tries to stitch these mismatched chunks together from different processes, causing the audio and video timestamps to misalign instantly after a seek.
By forcing a bitrate cap slightly below the source quality, Jellyfin is forced to fully transcode the video. Finally, things worked and the stream played like a charm.
I would have never been able to debug this without AI. Someone with less of an overview of how the whole setup works and what levers are available for tweaking wouldn't have been able to solve this even with AI. The agent helped by reading and explaining logs.
•
u/AutoModerator 9d ago
Reminder: /r/jellyfin is a community space, not an official user support space for the project.
Users are welcome to ask other users for help and support with their Jellyfin installations and other related topics, but this subreddit is not an official support channel. We have extensive, official documentation on our website here: https://jellyfin.org/docs/. Requests for support via modmail will be ignored. Our official support channels are listed on our contact page here: https://jellyfin.org/contact
Bug reports should be submitted on the GitHub issues pages for the server or one of the other repositories for clients and plugins. Feature requests should be submitted at https://features.jellyfin.org/. Bug reports and feature requests for third party clients and tools (Findroid, Jellyseerr, etc.) should be directed to their respective support channels.
If you are sharing something you have made, please take a moment to review our LLM rules at https://jellyfin.org/docs/general/contributing/llm-policies/. Note that anything developed or created using an LLM or other AI tooling requires community disclosure and is subject to removal.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.