Android TV - "Lag" with some ASS embedded subtitles - Duvel - 2025-03-23
Hi
Got an issue with a very specific situation.
Have a movie with following specs:
Video : 4k HEVC SDR
Audio : Dolby Digital+ 5.1 English + French
Subtitles : Embedded ASS (English + French + French Forced)
The problem happens on Android TV. No issue on Web player
The movie is transcoded to the Android TV box as
Video : HEVC --> HEVC 3600
Audio : EAC3 -> AAC
So, when subtitles are off, the movie just play fine.
But whenever I activate any of the subtitles, first it takes like one minute of black screen before the movie plays again ( and I can see the subtitles), but then the movie "lags" non stop. Every 5 seconds or so, it hangs 1-2 seconds. And it remains in this lagging state indefinitely (well I let it play like this at least 15 minutes and then stopped because it aint funny)
When I disable the subtitles, everything is working fine again.
I restarted the android box and made dozen of restarting movie attempts, its always the same behavior.
I inspected the server logs, and I cant find anything obvious.
Those are the logs I see for that stream when the subtitles are on and the movie is lagging
Code: [2025-03-23 08:58:34.981 +01:00] [INF] Removing item, Type: "Episode", Name: "Only Gunshots to Guide Us", Path: "", Id: c53d897f-9ea1-ee68-ebdd-a885a3aff984
[2025-03-23 08:58:36.472 +01:00] [INF] Stopping ffmpeg process with q command for "/cache/jellyfin/transcodes/a05fc672d55ca3769b77ea7c967cf139.m3u8"
[2025-03-23 08:58:36.487 +01:00] [INF] User policy for "tom". EnablePlaybackRemuxing: True EnableVideoPlaybackTranscoding: True EnableAudioPlaybackTranscoding: True
[2025-03-23 08:58:37.000 +01:00] [INF] "/usr/lib/jellyfin-ffmpeg/ffmpeg" "-analyzeduration 200M -probesize 1G -fflags +genpts -i file:\"/media/plex/movies/The Brutalist (2024) [imdbid-tt8999762]/The Brutalist (2024) [imdbid-tt8999762] - [WEBRip-2160p][EAC3 5.1][x265]-Amen.mkv\" -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:2 -map -0:s -codec:v:0 copy -tag:v:0 hvc1 -bsf:v hevc_mp4toannexb -start_at_zero -codec:a:0 libfdk_aac -ac 2 -ab 256000 -af \"volume=2\" -copyts -avoid_negative_ts disabled -max_muxing_queue_size 2048 -f hls -max_delay 5000000 -hls_time 6 -hls_segment_type mpegts -start_number 0 -hls_segment_filename \"/cache/jellyfin/transcodes/223dc7e671c56b077afe78050de67ca9%d.ts\" -hls_playlist_type vod -hls_list_size 0 -y \"/cache/jellyfin/transcodes/223dc7e671c56b077afe78050de67ca9.m3u8\""
[2025-03-23 08:58:39.957 +01:00] [INF] Stopping ffmpeg process with q command for "/cache/jellyfin/transcodes/223dc7e671c56b077afe78050de67ca9.m3u8"
[2025-03-23 08:58:40.045 +01:00] [INF] FFmpeg exited with code 0
[2025-03-23 08:58:40.089 +01:00] [INF] "/usr/lib/jellyfin-ffmpeg/ffmpeg" "-analyzeduration 200M -probesize 1G -ss 00:16:59.518 -fflags +genpts -i file:\"/media/plex/movies/The Brutalist (2024) [imdbid-tt8999762]/The Brutalist (2024) [imdbid-tt8999762] - [WEBRip-2160p][EAC3 5.1][x265]-Amen.mkv\" -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:2 -map -0:s -codec:v:0 copy -tag:v:0 hvc1 -bsf:v hevc_mp4toannexb -start_at_zero -codec:a:0 libfdk_aac -ac 2 -ab 256000 -af \"volume=2\" -copyts -avoid_negative_ts disabled -max_muxing_queue_size 2048 -f hls -max_delay 5000000 -hls_time 6 -hls_segment_type mpegts -start_number 146 -hls_segment_filename \"/cache/jellyfin/transcodes/223dc7e671c56b077afe78050de67ca9%d.ts\" -hls_playlist_type vod -hls_list_size 0 -y \"/cache/jellyfin/transcodes/223dc7e671c56b077afe78050de67ca9.m3u8\""
[2025-03-23 08:58:40.704 +01:00] [INF] FFmpeg exited with code 0
[2025-03-23 08:58:40.705 +01:00] [INF] Deleting partial stream file(s) "/cache/jellyfin/transcodes/a05fc672d55ca3769b77ea7c967cf139.m3u8"
[2025-03-23 08:58:42.216 +01:00] [INF] Playback stopped reported by app "Android TV" "0.18.6" playing "The Brutalist". Stopped at "1021563" ms
[2025-03-23 08:58:59.618 +01:00] [INF] Stopping ffmpeg process with q command for "/cache/jellyfin/transcodes/223dc7e671c56b077afe78050de67ca9.m3u8"
[2025-03-23 08:58:59.677 +01:00] [INF] User policy for "tom". EnablePlaybackRemuxing: True EnableVideoPlaybackTranscoding: True EnableAudioPlaybackTranscoding: True
[2025-03-23 08:58:59.687 +01:00] [INF] FFmpeg exited with code 0
[2025-03-23 08:58:59.688 +01:00] [INF] Deleting partial stream file(s) "/cache/jellyfin/transcodes/223dc7e671c56b077afe78050de67ca9.m3u8"
[2025-03-23 08:59:00.582 +01:00] [INF] "/usr/lib/jellyfin-ffmpeg/ffmpeg" "-analyzeduration 200M -probesize 1G -i file:\"/media/plex/movies/The Brutalist (2024) [imdbid-tt8999762]/The Brutalist (2024) [imdbid-tt8999762] - [WEBRip-2160p][EAC3 5.1][x265]-Amen.mkv\" -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:2 -codec:v:0 libx265 -tag:v:0 hvc1 -preset veryfast -crf 28 -maxrate 5670772 -bufsize 11341544 -profile:v:0 main -x265-params:0 no-scenecut=1:no-open-gop=1:no-info=1:subme=3:merange=25:rc-lookahead=10:me=star:ctu=32:max-tu-size=32:min-cu-size=16:rskip=2:rskip-edge-threshold=2:no-sao=1:no-strong-intra-smoothing=1 -force_key_frames:0 \"expr:gte(t,n_forced*3)\" -vf \"setparams=color_primaries=bt709:color_trc=bt709:colorspace=bt709,scale=trunc(min(max(iw\,ih*a)\,min(4096\,4096*a))/2)*2:trunc(min(max(iw/a\,ih)\,min(4096/a\,4096))/2)*2,format=yuv420p,subtitles=f='/var/lib/jellyfin/data/subtitles/4/48c12e9c-c90f-88bd-0ddf-f89dbbb3a898.ass':fontsdir='/cache/jellyfin/attachments/3965a22f3c402aa7fcf0e428816fce84'\" -start_at_zero -codec:a:0 libfdk_aac -ac 2 -ab 256000 -af \"volume=2\" -copyts -avoid_negative_ts disabled -max_muxing_queue_size 2048 -f hls -max_delay 5000000 -hls_time 3 -hls_segment_type mpegts -start_number 0 -hls_segment_filename \"/cache/jellyfin/transcodes/aa048532f2450d798b0a15100ed58a1b%d.ts\" -hls_playlist_type vod -hls_list_size 0 -y \"/cache/jellyfin/transcodes/aa048532f2450d798b0a15100ed58a1b.m3u8\""
[2025-03-23 08:59:01.229 +01:00] [INF] Playback stopped reported by app "Android TV" "0.18.6" playing "The Brutalist". Stopped at "1035544" ms
[2025-03-23 08:59:25.956 +01:00] [INF] Stopping ffmpeg process with q command for "/cache/jellyfin/transcodes/aa048532f2450d798b0a15100ed58a1b.m3u8"
[2025-03-23 08:59:29.872 +01:00] [INF] FFmpeg exited with code 0
[2025-03-23 08:59:29.908 +01:00] [INF] "/usr/lib/jellyfin-ffmpeg/ffmpeg" "-analyzeduration 200M -probesize 1G -ss 00:17:15.000 -i file:\"/media/plex/movies/The Brutalist (2024) [imdbid-tt8999762]/The Brutalist (2024) [imdbid-tt8999762] - [WEBRip-2160p][EAC3 5.1][x265]-Amen.mkv\" -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:2 -codec:v:0 libx265 -tag:v:0 hvc1 -preset veryfast -crf 28 -maxrate 5670772 -bufsize 11341544 -profile:v:0 main -x265-params:0 no-scenecut=1:no-open-gop=1:no-info=1:subme=3:merange=25:rc-lookahead=10:me=star:ctu=32:max-tu-size=32:min-cu-size=16:rskip=2:rskip-edge-threshold=2:no-sao=1:no-strong-intra-smoothing=1 -force_key_frames:0 \"expr:gte(t,n_forced*3)\" -vf \"setparams=color_primaries=bt709:color_trc=bt709:colorspace=bt709,scale=trunc(min(max(iw\,ih*a)\,min(4096\,4096*a))/2)*2:trunc(min(max(iw/a\,ih)\,min(4096/a\,4096))/2)*2,format=yuv420p,subtitles=f='/var/lib/jellyfin/data/subtitles/4/48c12e9c-c90f-88bd-0ddf-f89dbbb3a898.ass':fontsdir='/cache/jellyfin/attachments/3965a22f3c402aa7fcf0e428816fce84'\" -start_at_zero -codec:a:0 libfdk_aac -ac 2 -ab 256000 -af \"volume=2\" -copyts -avoid_negative_ts disabled -max_muxing_queue_size 2048 -f hls -max_delay 5000000 -hls_time 3 -hls_segment_type mpegts -start_number 345 -hls_segment_filename \"/cache/jellyfin/transcodes/aa048532f2450d798b0a15100ed58a1b%d.ts\" -hls_playlist_type vod -hls_list_size 0 -y \"/cache/jellyfin/transcodes/aa048532f2450d798b0a15100ed58a1b.m3u8\""
[2025-03-23 09:02:44.095 +01:00] [INF] WS "95.182.169.137" request
[2025-03-23 09:02:51.158 +01:00] [INF] Deleting partial stream file(s) "/cache/jellyfin/transcodes/914813a812d72414ea4b6ae86e34c728.m3u8"
Any hint ??
RE: Android TV - "Lag" with some ASS embedded subtitles - Efficient_Good_5784 - 2025-03-23
Could you share the relevant ffmpeg log for a laggy stream?
RE: Android TV - "Lag" with some ASS embedded subtitles - Duvel - 2025-03-23
(2025-03-23, 08:59 AM)Efficient_Good_5784 Wrote: Could you share the relevant ffmpeg log for a laggy stream?
Fast answer as usual 
I attached the ffmpeg log file
Attachement failed, too big.
I uploaded the file here https://limewire.com/d/3tquN#1tyNo0p2EM
RE: Android TV - "Lag" with some ASS embedded subtitles - Efficient_Good_5784 - 2025-03-23
Could you please share with a site like pastebin.com?
It would be nice to not need to download a file from the internet.
If it's too big for pastebin.com, just find where it shows the stream mapping.
Copy the text from that and bellow.
RE: Android TV - "Lag" with some ASS embedded subtitles - theguymadmax - 2025-03-23
What are your server specs? Your software transcoding and your CPU can't keep up.
RE: Android TV - "Lag" with some ASS embedded subtitles - Duvel - 2025-03-23
(2025-03-23, 04:27 PM)Efficient_Good_5784 Wrote: Could you please share with a site like pastebin.com?
It would be nice to not need to download a file from the internet.
If it's too big for pastebin.com, just find where it shows the stream mapping.
Copy the text from that and bellow. https://pastebin.com/MtS4TYVi
(2025-03-23, 04:28 PM)theguymadmax Wrote: What are your server specs? Your software transcoding and your CPU can't keep up.
PowerEdge T640
Intel® Xeon® Gold 5118 CPU @ 2.30GHz - 12 cores
128 Gb RAM.
Got VMware ESXi 8 on bare metal.
The jellyfin server VM has 16 vCPU and 32 Go RAM.
This is my server right now. The top 4 movies are on stream and all transcoding.
![[Image: image.png]](https://i.ibb.co/XZXXCHmp/image.png)
Dell Idrac + Vmware host
Jellyfin server VM
![[Image: image.png]](https://i.ibb.co/vCGwKxyH/image.png)
The CPU is usage is high indeed but it handle the 4 transcodes with no issue and theres still room for more.
The difference is that all movies being transcoded now are 1080p, while the movie I reported here is a 2160, that might be the issue.
But out of the 4 times I tested this movie, on 3 of them I was alone on the server, and the CPU peaked at 70% max, and each time I had this lag issue, while all other stuff ran fine.
Do we need an IBM mainframe to transcode a 2160p movie while displaying subtitles ? :-)
RE: Android TV - "Lag" with some ASS embedded subtitles - TheDreadPirate - 2025-03-23
You are CPU encoding to HEVC. Much slower than H264. Disabling HEVC encoding should help a lot. But adding a GPU for hardware acceleration is ideal.
For the record. Most users have some form of hardware acceleration available. Nearly all Xeons do not have an iGPU with Quick Sync. Most consumer Intel CPUs do.
RE: Android TV - "Lag" with some ASS embedded subtitles - Duvel - 2025-03-23
@TheDreadPirate
I dont want to rely on a GPU (and I got a good one) because of the power consomption, and because all in one, my jellyfin server works perfectly fine most of the time with CPU only.
I will thus disable the HEVC transcoding and retry
Thanks !
RE: Android TV - "Lag" with some ASS embedded subtitles - TheDreadPirate - 2025-03-23
CPU transcoding uses MUCH MUCH more power than GPU transcoding. AND the GPU would transcode multiple times faster. Yes, there is some idle power draw, but much less than you'd expect. Less than 15-20w for modern Nvidia GPUs. With transcoding power usage around 30w. Versus 50-100w for a CPU to transcode a video at less than half the speed.
RE: Android TV - "Lag" with some ASS embedded subtitles - Efficient_Good_5784 - 2025-03-24
You're not forced to use a dedicated GPU.
When people build a power-efficient media server machine, it's with the expectation that a CPU that contains an iGPU is used.
If possible, we recommend that you use an Intel CPU that has an iGPU so you can use QSV.
Intel GPUs produce really great transcoding results quality-wise.
And since the iGPU is part of the CPU, you save yourself the extra watts burned at idle from a discrete GPU.
|