Skip to content

Commit 6c50444

Browse files
committed
Update code docs
1 parent 7084c9d commit 6c50444

4 files changed

Lines changed: 164 additions & 2 deletions

File tree

docs/data/search.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/module-deviceCapabilities.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/source_api_Items.bs.html

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,47 @@
1616
}
1717
postData.DeviceProfile = getDeviceProfile()
1818

19+
' Dynamically adjust transcoding segment length and bitrate based on the video's
20+
' bitrate, duration, and the device's video buffer size to prevent buffer overflow
21+
' and playlist-too-large errors during HLS playback.
22+
if isValid(videoMetadata) and isValid(videoMetadata.json) and isValid(videoMetadata.json.MediaSources) and isValid(videoMetadata.json.MediaSources[0])
23+
mediaSource = videoMetadata.json.MediaSources[0]
24+
sourceBitrate& = 0
25+
videoDurationSeconds = 0
26+
27+
if isValid(mediaSource.Bitrate)
28+
sourceBitrate& = mediaSource.Bitrate
29+
end if
30+
31+
if isValid(mediaSource.RunTimeTicks) and mediaSource.RunTimeTicks > 0
32+
videoDurationSeconds = Int(mediaSource.RunTimeTicks / 10000000)
33+
end if
34+
35+
if sourceBitrate& > 0 and videoDurationSeconds > 0
36+
bufferSize& = getDeviceBufferSize()
37+
transcodingParams = calculateOptimalTranscodingParams(sourceBitrate&, videoDurationSeconds, bufferSize&)
38+
39+
' Apply optimized segment length to all video transcoding profiles
40+
if isValid(postData.DeviceProfile.TranscodingProfiles)
41+
for each profile in postData.DeviceProfile.TranscodingProfiles
42+
if isValid(profile.Type) and profile.Type = "Video"
43+
profile.SegmentLength = transcodingParams.segmentLength
44+
end if
45+
end for
46+
end if
47+
48+
' Reduce max streaming bitrate only when segment length alone isn't enough.
49+
' Never set MaxStreamingBitrate below the source bitrate + 10% headroom - doing
50+
' so would cause Jellyfin to reject a remux/direct-stream as exceeding the limit.
51+
if transcodingParams.maxBitrate > 0
52+
minAllowedBitrate& = sourceBitrate& * 11& \ 10&
53+
if transcodingParams.maxBitrate >= minAllowedBitrate&
54+
postData.DeviceProfile.MaxStreamingBitrate = transcodingParams.maxBitrate
55+
end if
56+
end if
57+
end if
58+
end if
59+
1960
if subtitleTrackIndex <> SubtitleSelection.none and subtitleTrackIndex <> SubtitleSelection.notset
2061
postData.SubtitleStreamIndex = subtitleTrackIndex
2162
end if

docs/source_utils_deviceCapabilities.bs.html

Lines changed: 121 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)