I want to get the camera video stream and broadcast it with RTSP on Windows.
I can play the camera video with
> ffplay -f dshow -i "HP HD Webcam"
But if I try start the stream with
> ffmpeg -f rtsp -i video="HP HD Webcam" rtsp://localhost:8888/live.sdp
The stream does not start. The console shows
ffmpeg version ...
configuration: ...
libavutil 55. 6.100 / 55. 6.100
libavcodec 57. 15.100 / 57. 15.100
libavformat 57. 14.100 / 57. 14.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 15.100 / 6. 15.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
And if I use ctrl+c to break it, an error shows
video=HP HD Webcam: Immediate exit requested
How can I properly stream the camera to RTSP with ffmpeg?
First, you have to create an RTSP server, then Push Video stream from Webcam to RTSP server. once server is up, Read the Stream from RTSP server. Follow the steps below in Ubuntu:
Open Terminal and execute following
$ sudo apt-get install ffmpeg
$ sudo apt-get install v4l-utils
Step 1: Open a new terminal and Download SimpleRTSP server package:
$ wget https://github.com/aler9/rtsp-simple-server/releases/download/v0.16.0/rtsp-simple-server_v0.16.0_linux_amd64.tar.gz
Extract downloaded package:
$ tar -xzvf rtsp-simple-server_v0.16.0_linux_amd64.tar.gz
Step 2: Check for your internal IP address with following command:
$ ifconfig
Copy an IP address eg. 192.168.XXX.XXX
Step 3: Now, Start RTSP Server
$ rtspServer=192.168.XXX.XXX:rtsp://192.168.XXX.XXX:8554/webCamStream ./rtsp-simple-server
(Add your IP address in the above command)
Step 4: Open a new terminal
$ v4l2-ctl --list-devices
(Ensure you have a webcam plugged in and installed > sudo apt-get install v4l-utils) This will give a list of all the camera devices plugged into your system eg.
UVC Camera (046d:0825) (usb-0000:00:14.0-1):
/dev/video0
/dev/video1
Step 5: You can now, push video stream from webcam to RTSP server:
$ sudo ffmpeg -f v4l2 -framerate 24 -video_size 480x480 -i /dev/video0 -f rtsp -rtsp_transport tcp rtsp://192.168.XXX.XXX:8554/webCamStream
(add your IP address, port, and stream name in the above command)
Step 6: Last step is to check and view your RTSP feed: open a new terminal and check with the following command
$ ffplay "rtsp://192.168.XXX.XXX:8554/webCamStream"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With