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

End of video speeds up then disappears, losing 30 or more minutes of video. #31

Closed tfabris closed 4 years ago

tfabris commented 5 years ago

Twice today I have observed a weird situation where the camera video "speeds up" at the end of the video like it was a time lapse and then that section is later lost completely.

Conditions:

I had this happen again, with the next split section, the one that started at 11:34 am:

tfabris commented 5 years ago

THEORY:

TO DO:

tfabris commented 5 years ago

My theory was incorrect. The second occurrence of the speedy up part was during my Timeline views, but the archive ended up fixing itself and all video was there.

Later, on the 19th, I spent a lot of time in the 3pm hour looking at the Timeline and it didn't mess up the stream at all.

tfabris commented 5 years ago

I'm going to close this bug because I haven't seen a recurrence. It may have been a particular YouTube mess-up which was a one-off. Reopen if you see it again.

tfabris commented 5 years ago

I think this has been fixed by one of the attempted fixes for issue #23.

Example:

Video: 2019-05-21 https://youtu.be/Ne1XrvA0Y4Q

Video plays fine for most of the day up until 6:13:08 pm, at which point it starts jumping and fast forwarding from 6:13:09 pm up until 6:17:something pm at which point it ends due to a bounce.

Here is the log of that bounce:

Error 2019-05-21 18:19:10 CrowCam Controller - The configurationIssues contains a bad value. Value retrieved was: videoIngestionFasterThanRealtime
Info  2019-05-21 18:19:10 CrowCam Controller - The network is up, but the YouTube stream is down. Pausing to give it a chance to come up. Inner stream test loop, retry attempt 1 of 3 . Sleeping 30 seconds before trying again.
Error 2019-05-21 18:19:42 CrowCam Controller - The configurationIssues contains a bad value. Value retrieved was: videoIngestionFasterThanRealtime.
Info  2019-05-21 18:19:42 CrowCam Controller - The network is up, but the YouTube stream is down. Pausing to give it a chance to come up. Inner stream test loop, retry attempt 2 of 3 . Sleeping 30 seconds before trying again.
Error 2019-05-21 18:20:13 CrowCam Controller - The configurationIssues contains a bad value. Value retrieved was: videoIngestionFasterThanRealtime.
Error 2019-05-21 18:20:13 CrowCam Controller - Bouncing the YouTube stream, because it was unexpectedly down.
Info  2019-05-21 18:20:15 CrowCam Controller - Pausing, after bringing down the stream, before bringing it up again.
Info  2019-05-21 18:21:50 CrowCam Controller - Done bouncing YouTube stream.

The log didn't catch the issue until about six minutes after the issue started occurring. Possibly because it doesn't check for the problem every moment, it only starts checking for the problem about once every five minutes. That explains the gap where it didn't notice the issue right away. But once it started checking, boy howdy did it catch a valid issue and did a valid bounce.

The subsequent video stream after the bounce is: https://youtu.be/jLAipmnPNnc It starts at 6:21:53 pm and it's playing perfectly fine at one second per second up until EOD.

tfabris commented 4 years ago

My code correctly detects this problem when it occurs, and it bounces the stream.

However, lately, bouncing the stream doesn't seem to fix the problem as often as it did before. After a bounce, the stream still gets "VideoIngestionFasterThanRealtime" error messages, and then the video has to bounce again. This fills the video playback history with a bunch of separated video segments which are only a few minutes long each. Many of these segments exhibit the "fast zoomy time scale" problem which is emblematic of this bug. But some of them don't.

Things I have done so far, to try to fix the problem:

Things to try:

tfabris commented 4 years ago

Note: Observation that I see on the camera itself while the issue is occurring:

So the problem doesn't seem to be the camera. Is it the synology?

To investigate: is there a way to have the camera squirt directly to YouTube without the Synology in the middle?

tfabris commented 4 years ago

More thoughts:

To do:

tfabris commented 4 years ago

Tried changing some of the camera settings in Synology Surveillance Station:

To do:

tfabris commented 4 years ago

This morning's feed (2019-09-24) has been doing well. The problem did not recur for the entire morning, which is very promising (though more bake time is needed to be sure). The issue usually recurs multiple times each morning, and today, no problems yet. I made the following changes yesterday (2019-09-23), so it's likely to be one of these things that fixed it:

My first guess is that it was the bandwidth setting, since I'm expecting that the other three settings only govern the communication between the camera and the Synology, something that's never been, an issue, and isn't currently an issue. That leaves pretty much the bandwidth.

Though theoretically it could possibly be the UDP setting. I could see how, if TCP transport caused the video to come in "hitches and spurts" instead of a steady stream of UDP packets, such a hitchyness could get forwarded up to the YouTube server too. That would tend to trigger the VideoIngestionFasterThanRealtime issue. So UDP vs TCP is also a suspect.

With regards to video quality, 2048 is not that bad compared to 3072, but I'd really like to keep it at 3072 if I can. The extra clarity is worth it to me, if we can swing it. So it's important to try to narrow this down more solidly.

To do:

tfabris commented 4 years ago

Last night I set the following back to their original settings: Surveillance Station, IP Camera, Device Settings, Advanced:

I left the camera's own bandwidth setting, and the Surveillance Station bandwidth setting, at 2048.

Everything is still working fine this morning. Conclusion: Having the bandwidth at 3072 was the root of the problem all along. I only have ±6mbps theoretical max upstream available anyway. Something changed at Comcast recently which caused 3072 upstream to become an unexpected problem.

I'll update my dox and close this issue as "fixed".

EDIT: Later, looking back, the resulting saved archive video of this one, on 2019-09-26 from sunrise until the VideoIngestionFasterThanRealtime reboot at 10:30 am, was not good. Even though it seemed fine "live", there was something wrong with the archive. The video was "stop-start", playing a second of video then a second of freeze, and repeating, the whole time. And the script didn't get an error for any of it until about 10:30 am ish. So having it set to TCP/2048 wasn't the perfect solution.

tfabris commented 4 years ago

Today I saw one instance of VideoIngestionFasterThanRealtime at about 10:30 am.

So it could be that the problem might not have been the bandwidth. Trying the following settings (starting 2019-09-26 ±2:30pm):

Surveillance Station, IP Camera, Device Settings, Advanced:

tfabris commented 4 years ago

On 2017-09-27 at 11:17 am:

2017-09-27 at 4:47pm

To do: Try some other settings to see if this can be fixed.

tfabris commented 4 years ago

2019-09-29 10:48 am - Tried setting everything back to:

Surveillance Station, IP Camera, Device Settings, Advanced:

Camera and Synology:

Also rebooted camera and Synology at 10:54 am for good measure.

tfabris commented 4 years ago

A similar issue occurred with similar but not identical symptoms:

One PARTICULARLY INTERESTING NOTE:

tfabris commented 4 years ago

Added long and short bounce durations, and reduced the amount of hysteresis on stream issues.

Now it will only bounce the stream for 5 seconds for network blips and stream issues. Let's see if this makes things better?

Hopefully this will:

tfabris commented 4 years ago

New code seems to have worked. This morning 2019-10-01 at 8:08:43 am, it did a bounce due to a detection of VideoIngestionFasterThanRealtime. The detection was short (1 min hysteresis starting at 8:07), and the bounce was short (5 sec), with the video dropping out only from 8:08:35 to 8:08:51 in the archive, but keeping the same video stream.

In addition, this fixed audio desynchronization as described in issue #14. Though the audio desynch problem was not detected by the script in any way (it had been going on for quite a while before the bounce), the short bounce fixed the issue at the time.

Also I did not see any video problems when the bounce occurred, only the audio issue.

tfabris commented 4 years ago

New bounce code is working super well for the last few days. Closing issue.

tfabris commented 4 years ago

Experimenting with putting the speed up to 3072 again, leaving everything else as-is (UDP mode is on).

To do:

tfabris commented 4 years ago

Noticed some troubles with start/stop video this evening and went back down to 1080p/2048/UDP to make things work smoother.

tfabris commented 4 years ago

The larger bandwidth is not the sole reason for the zoomy fast VideoIngestionFasterThanRealtime problem. It was set to 1080p/2048/UDP last night, but this morning there were a ton of VideoIngestionFasterThanRealtime bounces.

Doing the short 5-second bounces indeed seems to fix the zoomy fast instances. When a 5-second bounce occurs, if I look at the archived video, I see the zoomy fast problem right before the bounce, then it's corrected by the bounce. So it helps.

Also I think setting it to the lower bandwidth might possibly still decrease the overall long-term frequency of the zoomy fast problem. It just definitely doesn't fix it completely.

tfabris commented 4 years ago

I tried 2 second bounces and got a lot of instances where the zoomy fast problem did not get fixed. It's at 4 seconds now and doing OK, with the zoomy fast problem getting fixed commonly by the four second bounces.

I found that the zoomy fast problem tends to coincide with Comcast network problems. I think this is all down to just "bad comcast" and I've worked around it as best I can for now.