# How to imbed the video frames from the inference pipeline in the web

**URL:** https://discuss.roboflow.com/t/how-to-imbed-the-video-frames-from-the-inference-pipeline-in-the-web/6597
**Category:** 🤝  Community Help
**Created:** [July 22, 2024, 10:34am UTC](https://discuss.roboflow.com/t/how-to-imbed-the-video-frames-from-the-inference-pipeline-in-the-web/6597 "2024-07-22T10:34:43Z")
**Posts on this page:** 7
**Page:** 2

<div class="post-metadata">

### Author: ![Grzegorz](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/grzegorz/32/2877_2.png) [@Grzegorz](https://discuss.roboflow.com/u/Grzegorz)
#### Post date: [July 26, 2024, 11:44am UTC](https://discuss.roboflow.com/t/how-to-imbed-the-video-frames-from-the-inference-pipeline-in-the-web/6597/21 "2024-07-26T11:44:45Z")

</div>

Since the drop you observe is between `inference_pipeline` without `streamlit` and `inference_pipeline` with frames transferred through `streamlit` it seems the problem is outside of `inference` scope. I’d suggest checking with `chatgpt` as it seems it provides quite useful hints.

I just asked `chatgpt` and got suggestion to replace

```auto
    frame_placeholder.image(frame_rgb)

```

with

```auto
    with frame_placeholder.container():
        st.image(frame_rgb, use_column_width=True)

```

I hope you got enough hints to put you into good start, good luck!

---

<div class="post-metadata">

### Author: ![Mubashir\_Waheed](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/mubashir_waheed/32/4838_2.png) [@Mubashir\_Waheed](https://discuss.roboflow.com/u/Mubashir_Waheed)
#### Post date: [July 26, 2024, 11:58am UTC](https://discuss.roboflow.com/t/how-to-imbed-the-video-frames-from-the-inference-pipeline-in-the-web/6597/22 "2024-07-26T11:58:09Z")

</div>

One observation

I am displaying the stream with both the streamlit and open cv and I am getting same fps[8-10] for both even tho I am not sending frames/encoding/decoding for open cv. The only change I made was adding the streamlit  
You can see the code I am not using the `frame-rgb` for open cv.

```js
       // annotated coming here after process eg labeling, drawing of polygon etc 
        frame_rgb = cv2.cvtColor(annotated_frame, cv2.COLOR_BGR2RGB)
        frame_placeholder.image(frame_rgb)

        window_info = cv2.getWindowImageRect('Resizable Window')
        width, height = window_info[2], window_info[3]

        # Check if the window is minimized or hidden
        if width <= 0 or height <= 0:
            print("Window is minimized or not properly visible, skipping frame.")
            return # Skip this frame and continue with the next one

        try:
        # original annotated frame[not passed through streamlit]
            resized_frame = cv2.resize(annotated_frame, (width, height))
        except cv2.error as e:
            print(f"Error resizing frame: {e}")
            return # Skip this frame and continue with the next one

        # Display the resized frame in the window
        cv2.imshow('Resizable Window', resized_frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            cv2.destroyAllWindows()
            raise SystemExit("Program terminated by user")

```

Thank you so much for your help. I will try to trouble shoot and see what can I done

---

<div class="post-metadata">

### Author: ![Grzegorz](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/grzegorz/32/2877_2.png) [@Grzegorz](https://discuss.roboflow.com/u/Grzegorz)
#### Post date: [July 26, 2024, 5:02pm UTC](https://discuss.roboflow.com/t/how-to-imbed-the-video-frames-from-the-inference-pipeline-in-the-web/6597/23 "2024-07-26T17:02:55Z")

</div>

Thanks for sharing the observation, I have some suspicions on the script context setup by `streamlit`, however when I was running from my MackBook I did not experience fps drop… I will investigate further when time allows, currently we have new features that take priority. Many thanks once again!

---

<div class="post-metadata">

### Author: ![Mubashir\_Waheed](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/mubashir_waheed/32/4838_2.png) [@Mubashir\_Waheed](https://discuss.roboflow.com/u/Mubashir_Waheed)
#### Post date: [July 27, 2024, 9:36am UTC](https://discuss.roboflow.com/t/how-to-imbed-the-video-frames-from-the-inference-pipeline-in-the-web/6597/24 "2024-07-27T09:36:15Z")

</div>

I don’t think it’s possible to increase the fps with the streamlit

> **[Can streamlit display 60 fps video from frames?](https://discuss.streamlit.io/t/can-streamlit-display-60-fps-video-from-frames/26971)**
>
> I’ve been using Streamlit for a real time dashboard, and while data has been fast, video has been really slow. When I say video, I mean frames, because this would be reading from a camera or server providing images. Another way of framing this...

---

<div class="post-metadata">

### Author: ![Grzegorz](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/grzegorz/32/2877_2.png) [@Grzegorz](https://discuss.roboflow.com/u/Grzegorz)
#### Post date: [August 1, 2024, 5:41pm UTC](https://discuss.roboflow.com/t/how-to-imbed-the-video-frames-from-the-inference-pipeline-in-the-web/6597/25 "2024-08-01T17:41:56Z")

</div>

Hi @Mubashir_Waheed , thank you for following-up!

I personally think the challenge is with async nature of streamlit server and with opencv frames producer being non-async. But I’m not `streamlit` guru and unfortunately I have no time to deep dive into this rabbit hole…

Streaming over network is non-trivial task, that’s one of the reasons people make available solutions like [mediamtx](https://github.com/bluenviron/mediamtx), but it’s more involved than `streamlit` because you have to figure out all components of pipeline.

Anyways - thank you very much for trying `inference`, please keep in touch if yo have any issues with `inference_pipeline`!

---

<div class="post-metadata">

### Author: ![Mubashir\_Waheed](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/mubashir_waheed/32/4838_2.png) [@Mubashir\_Waheed](https://discuss.roboflow.com/u/Mubashir_Waheed)
#### Post date: [August 6, 2024, 12:35pm UTC](https://discuss.roboflow.com/t/how-to-imbed-the-video-frames-from-the-inference-pipeline-in-the-web/6597/26 "2024-08-06T12:35:32Z")

</div>

Ok I tried the mediamtx as well but even the simple stream doesn’t work on windows machine. I am getting black screen in browser. I opened the issue on Github but no response

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex029/uploads/roboflow1/original/1X/bb6edbfa56d0cf2ee603f061e9e09103502cc8cc.png) [@system](https://discuss.roboflow.com/u/system)
#### Post date: [August 27, 2024, 12:36pm UTC](https://discuss.roboflow.com/t/how-to-imbed-the-video-frames-from-the-inference-pipeline-in-the-web/6597/27 "2024-08-27T12:36:23Z")

</div>

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

[Previous page](https://discuss.roboflow.com/t/how-to-imbed-the-video-frames-from-the-inference-pipeline-in-the-web/6597.md?page=1)
