# CV\_CAP\_PROP\_BUFFERSIZE when playing movie

**URL:** <https://forum.opencv.org/t/cv-cap-prop-buffersize-when-playing-movie/7511>\
**Category:** C++\
**Tags:** videoio\
**Created:** [February 10, 2022, 11:12am UTC](https://forum.opencv.org/t/cv-cap-prop-buffersize-when-playing-movie/7511 "2022-02-10T11:12:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![f.miztree](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/f.miztree/32/4461_2.png) [@f.miztree](https://forum.opencv.org/u/f.miztree)\
**Post date:** [February 10, 2022, 11:12am UTC](https://forum.opencv.org/t/cv-cap-prop-buffersize-when-playing-movie/7511/1 "2022-02-10T11:12:04Z")

</div>

I’m sorry if my words are difficult to understand as this is my first post to such a professional form and I’m not a native speaker of English .

I have three questions about CV\_CAP\_PROP\_BUFFERSIZ.  
1\>Does X.set(CV\_CAP\_PROP\_BUFFERSIZE,n) also work when X is a movie object, not captures from camera?  
2\> And if it does, could some of the frames be dropped because of the long time delay?  
3\>Also, if I call X.set(CV\_CAP\_PROP\_BUFFERSIZE,1) in one thread, does it affect to the other thread using VIdeoCapture?

(My detailed situation)  
I’m trying to play a movie while recording with OpenCV and this goal was achieved with three threads, timer thread(controlls timing),recording thread and playing thread which are defined as methods in a class object. When I practice all of them, the playing speed of movie is fast enough to realize the original fps. However when I practice just two thread, timer and playing, its fps comes to 0.9 times of the original one. I’m suspecting the cause of this situation is cap.set(CV\_CAP\_PROP\_BUFFERSIZE,1) in recording thread.

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [February 10, 2022, 12:31pm UTC](https://forum.opencv.org/t/cv-cap-prop-buffersize-when-playing-movie/7511/2 "2022-02-10T12:31:40Z")

</div>

changing a property of one instance of VideoCapture has no effect on other instances of VideoCapture.

it shouldn’t matter from which thread the object’s property is changed. if it does, that would be a bug.

I don’t know if VideoCapture is thread-safe. as long as an instance is only used from one thread at a time, all should be good.

VideoCapture of a video file _never_ drops frames. a buffer size has no meaning in this situation. the implementation either decodes on demand, or keeps a small buffer for performance reasons.

---

<div class="post-metadata">

**Author:** ![f.miztree](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/f.miztree/32/4461_2.png) [@f.miztree](https://forum.opencv.org/u/f.miztree)\
**Post date:** [February 10, 2022, 12:42pm UTC](https://forum.opencv.org/t/cv-cap-prop-buffersize-when-playing-movie/7511/3 "2022-02-10T12:42:29Z")

</div>

Thank you for your answers.  
They are very helpful for me.

~  
X.set(CV\_CAP\_PROP\_BUFFERSIZE,1) improved the performance of playing thread, and it realized the original fps!

Thank you.

---

<div class="post-metadata">

**Author:** ![f.miztree](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/f.miztree/32/4461_2.png) [@f.miztree](https://forum.opencv.org/u/f.miztree)\
**Post date:** [February 11, 2022, 3:55am UTC](https://forum.opencv.org/t/cv-cap-prop-buffersize-when-playing-movie/7511/4 "2022-02-11T03:55:57Z")

</div>

I have one more question.

When a buffer is tried to get by opencv? Soon after the room’s generation by “read” or when CPU is free?

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [February 11, 2022, 9:42am UTC](https://forum.opencv.org/t/cv-cap-prop-buffersize-when-playing-movie/7511/5 "2022-02-11T09:42:33Z")

</div>

I don’t know.

if you need to know, you would have to investigate the code that interfaces with FFMPEG:

> <https://github.com/opencv/opencv/blob/4.x/modules/videoio/src/cap_ffmpeg.cpp>

---

<div class="post-metadata">

**Author:** ![f.miztree](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/f.miztree/32/4461_2.png) [@f.miztree](https://forum.opencv.org/u/f.miztree)\
**Post date:** [February 12, 2022, 1:55am UTC](https://forum.opencv.org/t/cv-cap-prop-buffersize-when-playing-movie/7511/6 "2022-02-12T01:55:54Z")

</div>

I see.  
Thank you very much!
