# 60 FPS video proccessing

**URL:** <https://forum.opencv.org/t/60-fps-video-proccessing/12067>\
**Category:** Python\
**Tags:** programming\
**Created:** [February 21, 2023, 9:22am UTC](https://forum.opencv.org/t/60-fps-video-proccessing/12067 "2023-02-21T09:22:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![GopalKharkar](https://avatars.discourse-cdn.com/v4/letter/g/8e7dd6/32.png) [@GopalKharkar](https://forum.opencv.org/u/GopalKharkar)\
**Post date:** [February 21, 2023, 9:22am UTC](https://forum.opencv.org/t/60-fps-video-proccessing/12067/1 "2023-02-21T09:22:46Z")

</div>

Hi there, I am trying to proccess 60fps video using opencv cv2.VideoCapture method but when we proccess the video the output video is getting slow and dropping the fps. For this problem i tried some solutions like multithreading but in that case video getting fast than the normal video speed. How do i get the normal speed of the 60fps video in opencv ?

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [February 21, 2023, 10:08am UTC](https://forum.opencv.org/t/60-fps-video-proccessing/12067/2 "2023-02-21T10:08:22Z")

</div>

> [@GopalKharkar](#):
>
> normal speed of the 60fps

there is no thing like that  
(unreasoable expectation, assuming, you’re using off-the -shelf hw)

> [@GopalKharkar](#):
>
> multithreading but in that case video getting fast than the normal video speed.

how would that be ? are you trying to _write_ a video file ?  
(and _that_ runs too fast, bc processing makes it time-lapse ?)

> [@GopalKharkar](#):
>
> when we proccess the video the output video is getting slow

processing isn’t for free. please _show_, what you’re doing, maybe we can help optimizing it a bit

> [@GopalKharkar](#):
>
> multithreading

opencv does a lot of _data-parallel_ multithreading under the hood. tacking your own _thread parallel_ thing on top of it rarely helps (and threads aren’t for free, either)

again, show hw / os / opencv version / code

---

<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 21, 2023, 5:40pm UTC](https://forum.opencv.org/t/60-fps-video-proccessing/12067/3 "2023-02-21T17:40:14Z")

</div>

show us what you did. nobody can debug what they aren’t being shown.

---

<div class="post-metadata">

**Author:** ![GopalKharkar](https://avatars.discourse-cdn.com/v4/letter/g/8e7dd6/32.png) [@GopalKharkar](https://forum.opencv.org/u/GopalKharkar)\
**Post date:** [February 23, 2023, 7:23am UTC](https://forum.opencv.org/t/60-fps-video-proccessing/12067/4 "2023-02-23T07:23:31Z")

</div>

hw- Dell 11th Gen Intel(R) Core™ i7-11390H @ 3.40GHz 2.92 GHz  
os- windows 11pro  
opencv version- 4.6.0

---

<div class="post-metadata">

**Author:** ![GopalKharkar](https://avatars.discourse-cdn.com/v4/letter/g/8e7dd6/32.png) [@GopalKharkar](https://forum.opencv.org/u/GopalKharkar)\
**Post date:** [February 23, 2023, 7:26am UTC](https://forum.opencv.org/t/60-fps-video-proccessing/12067/5 "2023-02-23T07:26:06Z")

</div>

> [@berak](#):
>
> are you trying to _write_ a video file ?

I am trying to read the video of 60fps

---

<div class="post-metadata">

**Author:** ![GopalKharkar](https://avatars.discourse-cdn.com/v4/letter/g/8e7dd6/32.png) [@GopalKharkar](https://forum.opencv.org/u/GopalKharkar)\
**Post date:** [February 23, 2023, 7:35am UTC](https://forum.opencv.org/t/60-fps-video-proccessing/12067/7 "2023-02-23T07:35:53Z")

</div>

```auto
 if os.path.isfile(self.frame_source) and pathlib.Path(self.frame_source).suffix.lower() in ['.mp4', '.mov',
                                                                                                        '.avi', '.mkv']:
                cap = cv2.VideoCapture(self.frame_source)
            else:
                raise TypeError("Unsupported file type or file extensions.")

            try:
                while True:
                    if cap and not cap.isOpened:
                        break

                    if cap:
                        ret, frame = cap.read()

                    if cap and ret:
                        h, w = frame.shape[:2]
                        if w > h:
                            p = abs(h - w) // 2
                            frame = cv2.copyMakeBorder(frame, p, p, 0, 0, cv2.BORDER_CONSTANT)

                    if ret:
                        # detect & generate face landmarks using mediapipe.
                        self.detect_face_landmarks(frame)
                        # save landmarks in PLY
                        self.save_ply(tc)

                        if self.need_visualiser:
                            pcd, vis, app = self.open3d(pcd, vis, app)

                        self.frm += 1
                        tc.add_frames(1)

                    # display frames in window.
                    if cap or ret:
                        cv2.imshow("Vide File", frame)

                    # press 'esc' key to quit frame display and visualiser.
                    if cv2.waitKey(1) & 0xFF == 27:
                        break

```

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [February 23, 2023, 9:15am UTC](https://forum.opencv.org/t/60-fps-video-proccessing/12067/8 "2023-02-23T09:15:10Z")

</div>

> [@GopalKharkar](#):
>
> ```auto
> # detect & generate face landmarks using mediapipe.
> self.detect_face_landmarks(frame)
> # save landmarks in PLY
> self.save_ply(tc)
> 
> if self.need_visualiser:
> pcd, vis, app = self.open3d(pcd, vis, app)
> 
> ```

probably the bottleneck here …

please _properly profile_ your code, before making assumptions about what / how to optimize
