7

I am reading a .mp4 video file using opencv-python (3.4.3.18) and python (3.6.6)

vid = cv2.VideoCapture(video_path)

The original video has around 59 FPS and I want to reduce it to 10 FPS. So, I set the cv2.CAP_PROP_FPS property using the following,

flag = vid.set(cv2.CAP_PROP_FPS, 10)

(Ref: https://docs.opencv.org/3.4.3/d8/dfe/classcv_1_1VideoCapture.html#a8c6d8c2d37505b5ca61ffd4bb54e9a7c)

However, when I print the flag value it gives False. Which means the property is not supported by backend used by the VideoCapture instance. Hence, when I'm reading the frame using,

return_value, frame = vid.read()

it returns all the 59 frames making the post processing steps more time consuming. How to solve this issue?

himanshurawlani
  • 353
  • 1
  • 3
  • 9
  • 2
    Setting `VideoCapture` frame rate when reading from a file is meaningless -- you will always receive the frames as fast as the decoder can decode them. It's only relevant when reading from a camera. – Dan Mašek Feb 04 '19 at 15:23
  • 2
    Also, what exactly do you envision reducing the frame rate would do? Based on the text at the bottom of your question, it seems you expect it to skip frames? – Dan Mašek Feb 04 '19 at 15:30
  • 1
    Yes, I want to skip frames. I'm feeding these frames to YOLO object detection algorithm. If I don't skip frames then the detection runs through each and every frame which is not needed... – himanshurawlani Feb 05 '19 at 06:24
  • Did you solve this issue? I am having the same problem with Yolo – Snake Jul 01 '19 at 03:52

1 Answers1

0

Have you ever tried to change cv2.waitKey()?

For example: if you have a 60fps video, try to use cv2.waitKey(6000)

sharkbait
  • 2,980
  • 16
  • 51
  • 89