Repository navigation
Conversation
Some cameras answer the first DESCRIBE after their RTSP server restarts with video only (seen on an LG/KT LPK6200WI, whose server restarts when clients reconnect - for example when OpenCCTV restarts). go2rtc keeps that connection, and when it reconnects it only re-attaches the tracks it already had, so the audio never comes back by itself. Recordings, the AAC/Opus transcoders and the players all stay silent until go2rtc is restarted by hand. The camera probe made it worse: it ran in that window, saw no audio and cleared the camera's audio flag, which hides the speaker button. Watch for it in the monitor loop: when a camera that has audio is connected without an audio track for 15 s, restart go2rtc so it connects again from scratch. Deleting and re-adding the stream over the API is not enough, because go2rtc only drops the name and the running producer keeps its consumers. Retry after 1 and 5 minutes, then give up and clear the audio flag. The probe no longer clears the flag on its own.
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.
Problem
Sometimes the camera audio disappears for good after OpenCCTV restarts, or after the camera's RTSP server restarts, while video keeps working. Recordings, the AAC/Opus transcoders and the players all stay silent until go2rtc is restarted by hand. The Opus transcoder then logs
Error opening input: Invalid data found when processing inputevery 5 s.My camera is an LG/KT LPK6200WI. Its RTSP server restarts when a client connection drops, and the first DESCRIBE after that restart can come back with video only. When this happened, go2rtc's producer listed only
video, recvonly, H264, although a DESCRIBE a minute later returned video + AAC.go2rtc does not recover from this on its own. When a producer reconnects, it only re-attaches the receivers it already has (
internal/streams/producer.go,reconnect):Deleting the stream and adding it back over the API does not help either. go2rtc only drops the name, and the running producer keeps its consumers.
The camera probe made it worse. If it runs in that window, it sees no audio and clears the camera's audio flag, which hides the speaker button in the app.
Change
audioMissing(info, stream)reports whether the camera's own connection is up without arecvonlyaudio track. It ignores our transcoders (ffmpeg:<stream>#…), which read from the stream itself.AudioRecoveryhandles a camera that has audio but whose connection has been up without an audio track for 15 s. It asks forgo2rtc.restart(), then retries after 1 and 5 minutes. After that it gives up and clears the audio flag. The flag is set again if audio comes back later.Restarting go2rtc briefly interrupts every camera. I chose it because it is the only way I found to make go2rtc connect to a camera again from scratch. It only happens when a camera that is known to have audio is sending none.
Testing
bun testpasses (76 tests, including new ones foraudioMissingand the backoff).bun run typecheckpasses.?videorestream and had its audio flag set. The instance loggedcamera stream has no audio track, reconnecting camerasand restarted its go2rtc after 15 s, then again a minute later. The main instance and its camera were not affected.