IP Camera RTSP Stream to Youtube Live
Do you wish you to embed your IP camera's video stream on website? There are many paid video stream service which can convert and store your video stream, however, you may want to use the free service such as Youtube Live. After I searched for a while on Internet, I found the method to stream the camera feed on Youtube Live from my Windows 10 computer.
1# Install the ffmpeg software on PCYoutube Live supports RTMP video stream protocol, the first step we need to convert the RTSP to RTMP on our computer. Here we use the open-source and free ffmpeg software, it can turn your computer to a media stream server, hence converts your RTSP video stream to RTMP, it's a cross platform solution can be run on Windows, Linux, Mac OS.
Step 1: Download the ffmpeg software: http://ffmpeg.zeranoe.com/builds/
Step 2: Unzip the compressed file, and move the folders to your PC's drive.
2# Find IP Camera's RTSP URLAfter we successfully installed the ffmpeg software on the PC, and now we can enter the commands to use the software. Then, we need to find the rtsp url of the IP camera. Different brand of IP cameras have different rtsp url. Here we take the Yoosee Wi-Fi cameras as an example. The RTSP URL of Yoosee Camera is as below:
rtsp://IPaddress:554/onvif1 rtsp://IPaddress:554/onvif2Before using the above RTSP URL, you need to change the IP address to your camera's IP address e.g. 192.168.1.3; Yoosee Wi-Fi cameras offer two separate RTSP streams for its main stream and sub-stream. Onvif1 is the main stream which delivers 1280x720p HD video, while the onvif2 is the sub-stream delivers 640x320 resolution video. Depends on your network environment, if your Internet speed is moderate not fast, you may use the sub-stream, instead of using the main stream.
Please running the VLC media player to verify if you can play the camera's RTSP video stream on your computer.
3# Create Live Streaming on YoutubeGo to youtube channel, click [Get started] on the right column of upload page to create the live streaming on Youtube. Giving it a title and description, then choose encoder, now it will show a encoder setup, you can find the server url rtmp://a.rtmp.youtube.com/live2 and stream name/key information. We will use these two information for the video streaming.
4# Convert RTSP stream to RTMP by ffmpegWe know the camera's rtsp URL and Youtube Live Stream server url and the stream name/key. All things are ready, now we need to run the ffmpeg to convert the RTSP stream to RTMP, then automatically upload it to Youtube Live server by command as below:
ffmpeg -f lavfi -i anullsrc -rtsp_transport udp -i rtsp://192.168.1.3:554/onvif1 -tune zerolatency -vcodec libx264 -t 12:00:00 -pix_fmt + -c:v copy -c:a aac -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/stream namePlease note before running the above command, you need to change the rtsp URL and RTMP server url to yours. In this example, we use the UDP connection, rather than TCP, because we failed to use the tcp port in our test, if you encounter error, you may try the TCP port by simply replace the udp with tcp.