# Stream webcam video to webpage opencv c++

**URL:** <https://forum.opencv.org/t/stream-webcam-video-to-webpage-opencv-c/5628>\
**Category:** C++\
**Created:** [October 14, 2021, 9:29am UTC](https://forum.opencv.org/t/stream-webcam-video-to-webpage-opencv-c/5628 "2021-10-14T09:29:03Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![rap](https://avatars.discourse-cdn.com/v4/letter/r/977dab/32.png) [@rap](https://forum.opencv.org/u/rap)\
**Post date:** [October 14, 2021, 9:29am UTC](https://forum.opencv.org/t/stream-webcam-video-to-webpage-opencv-c/5628/1 "2021-10-14T09:29:03Z")

</div>

Hi,  
I have program that run my webcam to show the video in c++. I want to stream this video to a webpage. But I didn’t have idea how to process it in c++. I saw some technologies like, ffmpeg, zmq Images…  
Can I have some help please.

---

<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:** [October 14, 2021, 9:37am UTC](https://forum.opencv.org/t/stream-webcam-video-to-webpage-opencv-c/5628/2 "2021-10-14T09:37:16Z")

</div>

you’ll have to build some kind of webserver, running on your local machine.

unless you process images, using opencv, it’s probably best to use ffmpeg or gstreamer directly.

---

<div class="post-metadata">

**Author:** ![rap](https://avatars.discourse-cdn.com/v4/letter/r/977dab/32.png) [@rap](https://forum.opencv.org/u/rap)\
**Post date:** [October 14, 2021, 9:49am UTC](https://forum.opencv.org/t/stream-webcam-video-to-webpage-opencv-c/5628/3 "2021-10-14T09:49:31Z")

</div>

Hi, thank you for your quick response.  
I use opencv to process my images received from my webcam. What I want is to display them on a future web page.  
All right, so I need to stream my video to my server and get it from their to show on my webpage. Is in it ?  
I’m a beginner so sorry if I don’t know the exact terms. I’m trying to exploit the opencv library and link it with the web.

---

<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:** [October 14, 2021, 9:53am UTC](https://forum.opencv.org/t/stream-webcam-video-to-webpage-opencv-c/5628/4 "2021-10-14T09:53:55Z")

</div>

do you have gstreamer support in videoio ?  
(you could try a server pipeline with VideoWriter)

> [@rap](#):
>
> I’m trying to exploit the opencv library

sounds somewhat a bad idea here.  
it’s a computer-vision library, not a video streaming one

---

<div class="post-metadata">

**Author:** ![rap](https://avatars.discourse-cdn.com/v4/letter/r/977dab/32.png) [@rap](https://forum.opencv.org/u/rap)\
**Post date:** [October 14, 2021, 9:58am UTC](https://forum.opencv.org/t/stream-webcam-video-to-webpage-opencv-c/5628/5 "2021-10-14T09:58:13Z")

</div>

Yes i think I have, but I don’t use it. I use V4L2 for videocapture. But as I understand, I need to transform my video in stream and send it to my server to be use ?  
Oh ok, I just use opencv to do some image processing. After I show it.

---

<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:** [October 14, 2021, 10:07am UTC](https://forum.opencv.org/t/stream-webcam-video-to-webpage-opencv-c/5628/6 "2021-10-14T10:07:01Z")

</div>

this seems to be “not well planned”.

are you even _allowed_ to start a server, which is visible to the _public_ internet ?  
most network providers forbid this.  
do you own a _static_, publicly visible ip ? know about NAT routers ?

---

<div class="post-metadata">

**Author:** ![rap](https://avatars.discourse-cdn.com/v4/letter/r/977dab/32.png) [@rap](https://forum.opencv.org/u/rap)\
**Post date:** [October 14, 2021, 10:08am UTC](https://forum.opencv.org/t/stream-webcam-video-to-webpage-opencv-c/5628/7 "2021-10-14T10:08:53Z")

</div>

No I don’t know anything about network and IP addressing. I’m just starting to get interested in it.

---

<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:** [October 14, 2021, 6:18pm UTC](https://forum.opencv.org/t/stream-webcam-video-to-webpage-opencv-c/5628/8 "2021-10-14T18:18:50Z")

</div>

this might be too advanced for you.

and it’s also off-topic. this forum is for OpenCV, not for web (server) development.

you need to learn how various web technologies work and how to use them.

---

<div class="post-metadata">

**Author:** ![rap](https://avatars.discourse-cdn.com/v4/letter/r/977dab/32.png) [@rap](https://forum.opencv.org/u/rap)\
**Post date:** [October 15, 2021, 8:15am UTC](https://forum.opencv.org/t/stream-webcam-video-to-webpage-opencv-c/5628/9 "2021-10-15T08:15:03Z")

</div>

all right thank you for this information

---

<div class="post-metadata">

**Author:** ![emcp](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/emcp/32/3699_2.png) [@emcp](https://forum.opencv.org/u/emcp)\
**Post date:** [November 6, 2021, 8:31am UTC](https://forum.opencv.org/t/stream-webcam-video-to-webpage-opencv-c/5628/10 "2021-11-06T08:31:45Z")

</div>

> <https://stackoverflow.com/questions/20314524/c-opencv-image-sending-through-socket>

RAP, try this if you want… I cannot get it to work which is why I am here… but the problems are not OPENCV … but the socket programming

also see socket programming how to here

[https://beej.us/guide/bgnet/html/index-wide.html](https://beej.us/guide/bgnet/html/index-wide.html)

Hope it helps you
