-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix VOD issues with longer keyframe intervals #3671
Fix VOD issues with longer keyframe intervals #3671
Conversation
1b140b3
to
6168884
Compare
I think calling ffprobe for every segment on each api call is going to introduce too much latency. Given that ffmpeg is writing the segments to mp4 files itself, don't we know that each segment must start with a keyframe? If so, can we just pull back the start time ahead of the current segment to ensure the first keyframe is prior to the start of the event? This makes me want to drop the VOD module even more. |
ffprobe on keyframes only should be pretty quick - not more than a few seconds for an hour of video. But yeah, I think we should try to avoid it actually. When I did this for some reason I thought the recordings were stored in longer files - I didn't realize they were segmented into ~ 10s clips. In that case probing is pretty unnecessary as most of these segments will actually just have 1 keyframe (when using the long I-frame intervals). We still need to pass some keyframe durations to the VOD module to have the HLS segmented properly, but trivially using the recording duration may work fine. |
737ace4
to
314e05b
Compare
Just passing the recording duration as a single keyFrameDuration seems to work. However, I don't have any cameras set up with I-frame intervals less than 4 seconds - would be good if someone else could test to make sure that things still work fine with those camera settings. |
I tested on one of my cams that has keyframes every 2 seconds:
seems to continue working fine in that case as well. |
I would still prefer to avoid the call to ffprobe altogether. For now, we should just assume that the keyframe is at the beginning of the first segment and seek from there. The vast majority of users won't benefit from VOD cutting that segment into smaller parts. In the future, we should piggyback on the existing ffprobe call to check the duration of the segment here and add this to the database. |
Sure, I can remove it. To be clear, this means not attempting to clip the first clip which actually affects cameras with short I-frame intervals the most - they may get an extra few seconds at the beginning of their clips. |
When using keyframe intervals of a few seconds or longer, and especially when using the H264+/H265+ codec variants with very long keyframe intervals, the VOD segmentation breaks. There are 2 main issues:
vod_ts()
) with the downloaded clip length (fromrecording_clip()
)vod_manifest_segment_durations_mode
toaccurate
does not work. This results in the manifest not matching the media. Also, the segmenting can often result in segments with no keyframes. These two problems will generally cause playback to fail.This PR uses ffprobe to get the keyframe durations, fixing 1) by adjusting the offset to the previous keyframe and 2) by using the
keyFrameDurations
field to give the VOD module enough information to create working manifests/segments.