Repository navigation
Include AAC audio in the native HLS fallback writer - #669
Merged
Merged
Conversation
When go2rtc native HLS is unavailable, the FFmpeg HLS writer now muxes the source's audio track alongside video, but only when audio is enabled for the stream (record_audio && !audio_disabled). With audio disabled the output stays video only, exactly as before. - AAC with codec config is stream-copied; other codecs (G.711 etc.) are skipped with a single log_info and video output is unaffected. - Packets are routed to output streams by media type rather than forced to stream 0, so audio-before-video RTSP sources work. - Audio is rescaled from its own timebase and has its own monotonic DTS tracker; video PTS/DTS fixups are unchanged. - Only video refreshes the thread's liveness timestamp, and max_interleave_delta is capped at 1s when audio is muxed. - Writers recreated after reconnection are initialized with the audio stream before their header is written. Closes #651 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
The native HLS writer tests were built by ctest but not by the coverage job, so codecov saw no hits for the HLS fallback audio changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Closes #651
Summary
When go2rtc native HLS isn't available, LightNVR's own FFmpeg HLS writer now muxes the camera's audio track, only when audio is enabled for the stream (
record_audio && !audio_disabled, the same rule as the detection thread and MP4 recorder). With audio disabled, nothing changes: the thread never selects the audio track, the writer gets no audio stream, and any stray audio packets are dropped. The output is video only, as it is today.Copy-only plus a clear skip (the acceptable first-PR option from the issue):
log_infoper stream, and video is unaffected. AAC without extradata is also skipped, because it would makeavformat_write_header()fail and take video down with it.mp4_writer_utils.cis keyed by stream name and would collide with the MP4 recorder's instance for the same camera.Details
hls_writer_initialize_av(writer, video, audio)is new.hls_writer_initialize()wraps it with no audio.streams[0], so audio-before-video RTSP sources work.max_interleave_deltais capped at 1s when audio is muxed, so a stalled audio track can't hold live video back.Testing
tests/unit/test_hls_cleanup.cuse the fixture's H.264 video plus a sine-wave AAC track encoded in the test (listed before video):ctest: 156/158 pass.test_sod_unifiedandtest_sod_vocfail on missing image/model arguments, which is unrelated.ENABLE_GO2RTC=OFFagainst a live RTSP source with audio, played in hls.js.🤖 Generated with Claude Code