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
  • Operating System / Platform => Windows 64 Bit
  • opencv-contrib-python 4.2.0.34
  • opencv-python 4.2.0.34
  • Detailed description

    Video is 06.933 sec long with 25 FPS, what makes 173 frames (observed in video player)

    However :

    cap = cv2.VideoCapture(video_path)
    cap.get(cv2.CAP_PROP_FRAME_COUNT)
    

    gives 172 frames. And while counting manual:

    while(cap.isOpened()):
            ret, frame = cap.read()
            if ret == True:
                frame_index += 1
            else: 
                break
    

    it can't go any further than 168 frame

    Sadly I can't share the video file

  • env: OPENCV_VIDEOIO_DEBUG=1
  • env: OPENCV_FFMPEG_DEBUG=1
  • extract frames from your video using FFmpeg and compare with OpenCV output (you may read extracted frames images through imread()): https://stackoverflow.com/questions/10957412/fastest-way-to-extract-frames-using-ffmpeg
  • dump frames information and analyse them: https://stackoverflow.com/questions/27529930/get-video-frames-information-with-ffmpeg
  • We don't help with remote investigation of problems which we are not able to reproduce on our side (because it is very time consuming), but we can take a look on the clear reason of the problem and suggest some fix/workaround.

    @alalek : I talked to my colleagues again and we decided to upload the video after all
    video.zip

    I hope this will bring some clarity for the problem

    Video stream is 1:

      Duration: 00:00:06.93, start: 0.000000, bitrate: 26676 kb/s
        Stream #0:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
        Metadata:
          creation_time   : 2020-04-27T07:51:47.000000Z
          handler_name    : #Mainconcept MP4 Sound Media Handler
        Stream #0:1(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 26491 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc (default)
        Metadata:
          creation_time   : 2020-04-27T07:51:47.000000Z
          handler_name    : ?Mainconcept Video Media Handler
          encoder         : AVC Coding
    

    OpenCV stops decoding after 168 frame.
    Problem is that frames are not flushed from the decoder properly after the stream EOF (passed stream index 0 instead of 1).

    PR with fix will be added soon.