tfabris / CrowCam

A set of Bash scripts to control and maintain a YouTube live cam from a Synology NAS.
GNU General Public License v3.0
4 stars 3 forks source link

Audio desynchronized with video. #14

Open tfabris opened 5 years ago

tfabris commented 5 years ago

Currently the audio stream is desynchronized from the video stream. The audio is several seconds earlier than the video.

To do:

tfabris commented 4 years ago

Status:

To do:

tfabris commented 4 years ago

I have confirmed that doing the top-of-the-hour bounce fixes the issue temporarily. The problem is, the issue recurs at random times, so, sometimes the problem recurs mere minutes after a bounce had fixed it.

If the Synology techs had experimentally implemented this same kind of bounce at a lower level in the code, then, the reasons I'm still seeing the issue recur, must be because of that randomness.

Note that the issue isn't the audio stream... it's the video stream that's the problem. In every example of the issue I've seen, it is clear that the audio stream continues uninterrupted, with no glitches in the sound. The video stream is always the part that glitches. After the video stream experiences a glitch, then the video stream is now running a few seconds behind the audio. Is it possible that the Synology techs had been investigating the wrong path, trying to find problems in the audio encoding, when the real problem is actually with the video? Or more specifically, that the Live Broadcast feature is unable to detect when the video glitches, and thus doesn't know that it needs to bounce the audio stream too?

Example:

Below is a specific set of examples of all those things from yesterday. In particular, this is an example of the desynchronization recurring mere minutes after it was fixed by a bounce.

Audio is synchronized:

The moment where a video glitch causes it to become desynchronized:

Examples of desynchronization immediately after the glitch:

Stream is bounced by the script:

Stream is synchronized after the bounce:

The moment where a video glitch causes it to become desynchronized:

Example of desynchronization after the glitch:

tfabris commented 4 years ago

2020-07-08: Synology support has still been working on this, and they are going to do another round of experiments on my NAS. Details in the private support ticket.

tfabris commented 4 years ago

Synology says they have applied a patch to my unit and that I should observe the stream results and look for desynchronization errors in the results.

2020-07-09 04:04 AM PDT - Synology tech login registered on unit, patch likely applied at that time. 2020-07-09 10:45 AM PDT - Deactivated the hourly stream bounce feature in the CrowCam code, so that if the issue recurs, it will be detectable.

To do:

tfabris commented 4 years ago

Reported to Synology:

I kept an eye on the stream for several days, and I didn't see any recurrences of desynchronization until Sunday the 12th (yesterday). So there is a chance that the recurrence of the issue has significantly decreased, though it is not gone.

(Since I'm merely observing the critters on the live cam, and the critters do not always make noises that correspond with clear obvious movements, so it is possible that there were other recurrences which I did not notice.)

Links to examples of desynchronization that I noticed:

2020-07-12 11:05:23 am - https://bit.ly/38R3KwK - Squirrel jumps onto feeder from above the camera. Video is slightly desynchronized from audio, you can hear the squirrel's footfalls on the roof of the feeder very briefly before you see the squirrel.

2020-07-12 11:43:28 am - https://bit.ly/32d21k3 - Crow - Video is slightly desynchronized from audio, you can hear the crow's feet hit the platform very briefly before you see its feet hit.

2020-07-12 11:44:05 am - https://bit.ly/2WhncxJ - Juvenile atop feeder begs from parent - Video is very clearly desynchronized from the audio. The juvenile is the one with the pink mouth who flaps its wings and opens its mouth wide when it begs. The juvenile voice has more of a "honk" sound than the parent, it sounds a little bit like a kazoo. You can clearly hear the juvenile cawing about one second before the video shows it, and it repeats several times, so it's very clear.

(By the way, I have checked the version of the video which is archived on the Synology NAS itself, by opening up Surveillance Station app and viewing the "Timeline" of that last instance that I linked above. The Video on the NAS is fine, the audio+video are in perfect synchronization, so the issue is reproducing only in the Live Broadcast to YouTube.)

tfabris commented 4 years ago

2020-07-29:

Examples of recurrence after the 2020-07-09 patch was applied:

2020-07-22 3:30:15 pm - Audio is ahead of video by a few seconds, sounds of the crow's footfalls are heard a few seconds earlier than the actions are seen. Continues for at least 2 minutes or more: https://bit.ly/2CSYoWu 2020-07-22 5:05:07 pm - Same stream, audio is back to normal synchronization: https://bit.ly/3jQvdE3

2020-07-12 11:44 am - Audio is ahead of video: https://bit.ly/2WhncxJ

In the meantime:

tfabris commented 4 years ago

To do:

tfabris commented 4 years ago

Syno techs patched the system after the most recent "normal" update. The patch occurred 2020-07-31 at approximately 3:45-3:50 am PDT.

To do:

tfabris commented 4 years ago

2020-08-09 - Examined the video stream for the last several days since the techs applied their manual patch on 2020-07-31. The only timing glitch I've seen is the previously-mentioned one at 2020-08-02 4:12:50 pm PDT.

Reporting to Synology Support that the problem is solved for me EXCEPT that it needs to be put into a public release to be considered finished.

tfabris commented 4 years ago

To do:

tfabris commented 4 years ago

The corresponding bug is expected to be fixed in the next full release of Surveillance Station. The upcoming 8.2.8 hotfix will not include the fix.

In the meantime, to keep my existing patch:

sudo synoservicectl --status pkgctl-SurveillanceStation
sudo synoservicectl --stop pkgctl-SurveillanceStation
sudo synoservicectl --status pkgctl-SurveillanceStation

sudo cp -p ~/ssrtmpclientd /var/packages/SurveillanceStation/target/sbin/

sudo synoservicectl --start pkgctl-SurveillanceStation
sudo synoservicectl --status pkgctl-SurveillanceStation

(The above has been done - 2020-11-15 - Surveillance station version was 8.2.8-6335 at the time.)

tfabris commented 4 years ago

Audio desynchronization was noticed on 2020-08-16 - No changes or updates had been made to the SS software, and, I checked the logs and there were no detected problems with my home internet during this period of time.

3:21 pm - Crow: https://youtu.be/PuwxChpIXak?t=2368 4:14 pm - Crow, mouth open: https://youtu.be/PuwxChpIXak?t=5542 4:17 pm - Crow family visit, 3 crows. Very hot day, crows have their mouths open: https://youtu.be/PuwxChpIXak?t=5703 4:18:51 pm - Crows - Audio is correctly in synch: https://youtu.be/PuwxChpIXak?t=5802 4:19:18 pm - Video glitch, audio becomes desynchronized at the point of the video glitch: https://youtu.be/PuwxChpIXak?t=5826 4:19:36 pm - Crow departs, audio desynchronization can be noticed at the point of departure: https://youtu.be/PuwxChpIXak?t=5841 4:20:20 pm - Video glitch/jump (no one around to check audio timing): https://youtu.be/PuwxChpIXak?t=5886 4:44:26 pm - Squirrel, audio and video are back in sync: https://youtu.be/PuwxChpIXak?t=7334

tfabris commented 4 years ago

Audio desynchronization noticed: 2020-09-03 Thu - 11:15:48 am - Steller's Jay, sound is desynchronized: https://youtu.be/6yIcWebh0hY?t=964

I noticed this on 2020-09-04. Then I checked the version of the software and it was the 8.2.8 version which was expected to mess this up. Applying the manual patch now, on 2020-09-04 8:45 am.

tfabris commented 1 year ago

I'm noticing the audio desynchronization even without the RTMP daemon in the mix. Even when not broadcasting to YouTube, just viewing Surveillance Station directly through its web UI, the desynch is there, and that's with the latest version of the software.

tfabris commented 1 year ago

Tried a firmware upgrade of the Dahua camera. Its UI tool said "the firmware is up to date" which was a lie, there was a newer version downloadable from their web site, dated August 2022. Installed that firmware and it doesn't fix the problem, there's still a desynch between audio and video.