Broadcast: audio stream tests + subtitle/seek drift correction#60
Open
Grimothy wants to merge 6 commits into
Open
Broadcast: audio stream tests + subtitle/seek drift correction#60Grimothy wants to merge 6 commits into
Grimothy wants to merge 6 commits into
Conversation
…ssing
- Add hls_dir field to BroadcastStatus dataclass and get_status() return
- Add hls_dir to BroadcastStatusResponse Pydantic model
- Pass hls_dir through in GET /broadcast/{network_id}/status route
- Include /dvr/recordings/ in DVR URL pattern matching
… subtitles When the video URL uses ffmpeg's `#range=<n>-` byte-seek URL suffix against Emby's static endpoint (which doesn't advertise duration metadata), ffmpeg waits for the next GOP boundary before emitting the first video packet. The subtitle URL is independently server-pre-seeked via Emby's startPositionTicks path segment so its cues land at PTS 0 — meaning subtitles land ~1-3s AHEAD of the video's first PTS, leaving the user with a "tad slow or fast" desync. - Add `_probe_video_first_pts()`: writes a 0.5s TS chunk to a tmpfile via ffmpeg, then runs ffprobe on the file to extract the real first-packet PTS. Cached per BroadcastProcess instance so it's only paid for once per broadcast. - In `_build_ffmpeg_command()`: when `seek_seconds > 0` (byte-seek path) and subtitles are active, probe and apply `-itsoffset +<PTS>` to the subtitle input to shift cues forward to the video's GOP start. - Read 1.5s probe budget added to broadcast startup (acceptable for live broadcast start which is already slow). - 2 new tests: drift_correction applies with probed PTS > 0.1s, and skips when probe returns 0 (no_seek or pure_server_transcode path). - Refactor 1 existing test to mock the 2-step subprocess.run (ffmpeg + ffprobe) instead of the original single-ffprobe assumption. Empirically measured drift: 1.400s on item 817 (Night at the Museum), 1.483s on item 437 (Interstellar) — bounded by GOP size, typically < 3s for HEVC. Live validation: test 2 broadcast with seek=3500 produced subtitle cues at PTS 4.124s (rebased cue offset + 1.4s drift correction), versus 2.724s without correction — exactly aligned with the video's GOP-boundary start.
…am fields Mirror the BroadcastConfig dataclass fields added in earlier work so the HTTP boundary accepts the same payload: - audio_stream_index: optional preferred-language audio stream index (resolved by Laravel from the media server metadata). - subtitles_enabled: request the proxy to detect/expose embedded subtitle tracks as a toggleable WebVTT rendition in the HLS output. - subtitle_url + subtitle_language: explicit subtitle URL resolved by Laravel from the media server metadata (covers embedded AND external sidecar-file subtitles). - subtitle_seek_seconds: independent seek offset for the subtitle URL. 0 means the subtitle is already server-pre-seeked (Emby startPositionTicks rebased the cues); > 0 means seek locally with -ss and correct via -itsoffset. The next_stream_config mirror lets the proxy pre-queue auto-transition without waiting for a Laravel round-trip.
Tests for the audio_stream_index field flow in BroadcastConfig: ensure the proxy honors the explicit audio stream index when set, and falls back to the default (first audio) stream when not set.
…st-processing" This reverts commit 50c28de.
# Conflicts: # src/broadcast_manager.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Broadcast subsystem: audio stream handling tests and subtitle/seek drift correction. Pairs with m3u-editor single-authority seek work.
Commits
Notes