Ask Your Question

Revision history [back]

Stall in VideoCapture.set(cv2.CAP_PROP_POS_FRAMES, 0)

I'm using python binding of opencv compiled from source with ffmpeg support. When I want to jump between frames, as we know, I can use cap.set(cv2.CAP_PROP_POS_FRAMES, frame_id). This is correct for most videos, but there exists some videos. When I do the same operation on it, the code will stall and no return no error no warning.

As my opencv and ffmpeg are both compiled from source, I can trace the stall is caused by :

  • set(cv2.CAP_PROP_POS_FRAMES, 0)

  • av_seek_frame(ic, video_stream, time_stamp, AVSEEK_FLAG_BACKWARD) in modules/videoio/cap_ffmpeg_impl.hpp

  • seek_frame_internal(AVFormatContext*s, ...) in libavformat/utils.c

  • avio_seek

But I am really not familiar with ffmpeg, and can not figure out the real reason for this issue. Mostly it's caused by video format, but I'm not sure about it.

here is one of the problem-videos: https://drive.google.com/file/d/11irVAfPWQbvktQ5sx2lEZT_A5Wa--rRo/view?usp=sharing

Anyone has ideas about this?