Ask Your Question

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

asked 2018-11-07 02:42:08 -0500

tabsun gravatar image

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:

Anyone has ideas about this?

edit retag flag offensive close merge delete


not all combinations of codec/container support "seeking".

berak gravatar imageberak ( 2018-11-07 06:27:01 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2018-11-07 06:26:27 -0500

supra56 gravatar image

W/out second parameter. Use get.

edit flag offensive delete link more


I want to jump between frames by using set instead of querying display position:)

tabsun gravatar imagetabsun ( 2018-11-07 07:13:34 -0500 )edit

You didn't say jump or scroll.. I used this on raspberry pi 3. frame by frame

supra56 gravatar imagesupra56 ( 2018-11-07 07:35:49 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-11-07 02:40:44 -0500

Seen: 24 times

Last updated: Nov 07