I am streaming video from a camera to a process that monitors the stream for specific events. I am able to connect to the camera, download the m3u8 playlist, fetch the individual AVI video segments and start working on them.

However, I have noticed that the individual video segments have repeating frames, as if the streaming is inserting some kind of delay for synchronisation purposes.

Unfortunately, there is nothing in the video segments, or the m3u8 file to denote some kind of sync offset and how much that offset might be so that I can seek to that frame and start processing each segment from its particular offset.

When I try to access the video segments via ffmpeg, it reports a range of frames as "missing". Python libraries such as PyAV or pims do not complain for missing frames but I suspect that these repeated frames (appearing as a long pause) at the beginning of the video segments might be filled in by the libraries themselves if they detect some kind of error with the file.

I have also gone through rfc8216 which does mention "discontinuities" but these are marked at the level of segment. My problem here is not with discontinuities from segment to segment, but discontinuities WITHIN the content of a given video segment.

Is there something I may be missing here? What is the origin of these repeated frames and how would I be able to obtain a number of video segments from the camera that when played back, do not suffer from these long intermitent pauses?


Here is the output of ffprobe with -report added. The bit that I am a bit worried about is:

    Input #0, mpegts, from 'stream_0.avi':
      Duration: 00:00:05.89, start: 58029.795556, bitrate: 346 kb/s

...provided that, that start is an offset into the file where the "useful" content starts (?).


Here is the ffmpeg report. I think the cur_dts errors are "filled" in automatically with the value of the first available frame.

The point here is to get some kind of "handle" to these offsets so that I can take them into account when going through the frames across segments and effectively go through an "un-interrupted" sequence of frames just as it would be received from the camera.

Indeed, the files are not plain AVI, they are MPEG-TS.

EDIT3: Here is the newest report on a different capture segment. The previously captured segments were indeed showing as covering an interval of 6 seconds but carried just 2 frames.

These "corner cases" are indicative of the kind of information I would need at the point of processing, just like a video player does.

So, the point here is not so much "just playing the video" or getting access to its frames in the right way, but also being aware of all these little issues which would affect the processing as well. For example, here we have 2 "samples" (2 frames) out of a 6 second window. If this is a glitch of the camera or the network, I would like to get a hint about it because it would help with the processing.

  • When I try to access the video segments via ffmpeg, it reports a range of frames as "missing" --> Rerun with -report added. Share link to report file.
    – Gyan
    Commented Jun 6 at 5:14
  • @Gyan thank you, please see update
    – A_A
    Commented Jun 7 at 15:03
  • That's a ffprobe report, not ffmpeg. You have to run ffmpeg -i SEGMENT -f null - -report .`BTW, your input has extension AVI but is actually MPEG-TS. The non-zero start time is perfectly normal.
    – Gyan
    Commented Jun 8 at 4:39
  • @Gyan Please see "EDIT2". I am already finding this helpful, so at some point, please make sure you post this in some form of an answer. Your "...MPEG-TS.." comment was helpful in finding TS-DUCK and more importantly the "Intro to MPEG-TS" which I am going through at the moment. I was handed AVI files, no library complained when opening them, I did not think twice about it :)
    – A_A
    Commented Jun 9 at 9:49
  • @Gyan Any ideas about the ffmpeg report?
    – A_A
    Commented Jun 11 at 15:17


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.