5 ms·
What process should I follow if I want to stream a normal webcam to the web using my own webserver? I would like to just query the webcam and post it on the sit
by worldmerge 4y ago
What process should I follow if I want to stream a normal webcam to the web using my own webserver? I would like to just query the webcam and post it on the site without outside streaming like youtube or twitch.
- woleium 4y agono need for a webserver. just buy a network enabled camera. they are like $20
- thakoppno 4y agoone solution that might work for you and may approach some definition of simplicity would be ffmpeg + caddy + videojs. basically use ffmpeg to make an m3u8. use caddy to serve the video files and the html/js. videojs will rebox the m3u8 for your friends using chrome/android.
- paxys 4y agoThere are tons of libraries and commands (e.g. ffmpeg) that will save a still frame from a camera input. Build a web page around that using whatever stack you like.
- jeffbee 4y agoOn a network camera like an Axis you can just curl down a frame.
- mindcrime 4y agoIf you want a very low FPS stream you can do what @paxys mentioned and just take stills from the camera and serve them in an HTML page and refresh as often as you like. Let the user refresh the page, or use javascript to do it automatically. If you want more of a "proper" video stream (whatever that means) one good choice is to use Icecast[1][2]. It makes it pretty easy to set up audio and video streams and publish them. [1]: https://icecast.org/ https://icecast.org/ [2]: https://en.wikipedia.org/wiki/Icecast https://en.wikipedia.org/wiki/Icecast
- tshaddox 4y agoOr even without JavaScript: https://en.wikipedia.org/wiki/Meta_refresh https://en.wikipedia.org/wiki/Meta_refresh
- mindcrime 4y agoHeh, you're right of course. Can't believe I forgot about that. Even I've fallen into the rut of only thinking of Javascript for any kind of interactivity on the Web. Uggghhh.
- IncRnd 4y agoIt's super easy to do this. You can hook ffmpeg to capture webcam and send that into nginx. Then, nginx will natively run HLS to stream the video over the web. I do something similar and run nginx in a docker container, so all I need to do is 1) run a docker container and 2) run ffmpeg elsewhere to send an input stream to the docker container. There are tutorials all over the web for doing this. Try searching for "ffmpeg nginx rtmp hls docker" without quotes.
- fuzzfactor 4y agoOBS Studio is supposed to do streaming from a PC's webcam in Windows or Linux, somewhat similar to how an actual netcam streams but the netcam doesn't need a PC & software to do the streaming. With a netcam the PC is only needed to set up the netcam, then the netcam streams by itself, connected directly to your network, the PC can then be turned off. Either way you would be opening a port on your firewalls/routers to match the one you select for your camserver-PC (or netcam), for viewers to access the cam at yourIPaddress:port by using a media player like VLC or even the old Windows Media Player, which accepts a specific port for streaming media from a numerical or named IP address. Basically you use the "port forwarding" features of your router to allow the internet WAN to connect to your private LAN through that one specific port only, where the camera stream is present. This is considered a "pinhole" in your firewall. The viewing user does need to use a media player that has the proper codecs installed to play the format that your particular cam is sending. With encoding software like OBS you can choose to stream other formats besides the native cam output if you want.
- arcanemachiner 4y agoThis is a script I used to do this with just VLC as the server AND the client. There should be a way to get it working from a browser, but it serves as a possible inspiration that runs well without having to install the kitchen sink to get it working. The DEVICE_NUMBER may need to be changed (e.g, 0, 1, 2, 3, 4, etc.) #!/bin/bash # to view the stream, open with VLC: http://your-ip:8088/ http://your-ip:8088/ if [ "$1" != ""]; then DEVICE_NUMBER=$1 else DEVICE_NUMBER=4 fi cvlc -vvv v4l2:///dev/video$DEVICE_NUMBER --sout '#transcode{vcodec=mjpg,acodec=none}:std{access=http,mux=mpjpeg,dst=0.0.0.0:8888}'
- lesuorac 4y agoI've used an rtsp sever [1] along with hls.js [2] so that I can have it in a nicer webpage and then stuck it all behind a vpn (wireguard). [1]: https://github.com/aler9/rtsp-simple-server https://github.com/aler9/rtsp-simple-server [2]: https://github.com/video-dev/hls.js/ https://github.com/video-dev/hls.js/