Connecting IP Camera with YouTube using FFMPEG

vcima

n3wb
Joined
Nov 19, 2022
Messages
1
Reaction score
0
Location
Spain
I´m trying to connect my ip camera with Youtube using ffmpeg to convert the stream from RTSP to RTMP.

rtsp_url="rtsp:/xxxxxx"
rtmp_url="rtmp:/xxxxxx"

ffmpeg -rtsp_transport tcp -i $rtsp_url -tune zerolatency -vcodec libx264 -pix_fmt + -c:v copy -c:a aac -strict experimental -f flv $rtmp_url



This works fine, but I have several problems that I don't know how to solve.
  1. Sometimes, for different reasons, I lose the connection with the camera: stoppage during the night, coverage problems... and I don't want the process disconnect from Youtube. How could I do it? Could I put a default image while there is no connection to the camera?
  2. The last question would be. How can I guarantee that the Youtube player id associated with the process is always the same. It is quite inconvenient to have to update the player every time there is a connection problem.
Regards
 

TRLcam

Getting comfortable
Joined
Apr 16, 2014
Messages
292
Reaction score
1,074
Location
Nebraska!
I'm not sure what OS you are running to make ffmpeg go, but I use Linux here for a few YouTube livesteam cameras. I have a bash script that runs every five minutes that checks the bandwidth used. If it falls below a pre-programmed level the script kills ffmpeg and restarts. Some of my live cameras run daytime only. For those I use a script that calculates the sunrise/sunset times based on latitude/longitude. It removes power to the camera one hour after sunset and starts it back up again one hour before sunrise. In the time the camera is off the script kills ffmpg and starts a different script that either plays a stored video or displays a image. This keeps the YouTube link up till the live video starts again.

Some of the cameras utilize cellular wireless links for the internet connection. On these I have a script that pings a dependable internet server every five minutes. It pings three times at two second intervals. If it does not get a response, the controller cuts power to the cell modem for a few seconds and then powers it back up. This usually solves the problem. If not, the script will do it again in five minutes till it starts working again.

I also send log files to a SFTP server at my office. The log files help me keep track what is going on at the remote site. They contain CPU temp, housing temperature inside/out, housing door alarm, solar power stats, UPS status, etc. Most of the cameras are in remote locations, so anything I can do to automate the troubleshooting and repair process saves me much time and expense.

Here is a picture of the control board that makes all this happen. The Raspberry Pi does the YouTube server duties and all the sensor monitoring and control. The black relay is a latching relay that switches the power to the IP camera. The other two relays are used to cycle power to the cellular router and other duties. Sensor inputs are either i2c one wire.

 

Smilingreen

Known around here
Joined
Sep 17, 2021
Messages
3,599
Reaction score
14,374
Location
Tennessee USA
I'm not sure what OS you are running to make ffmpeg go, but I use Linux here for a few YouTube livesteam cameras. I have a bash script that runs every five minutes that checks the bandwidth used. If it falls below a pre-programmed level the script kills ffmpeg and restarts. Some of my live cameras run daytime only. For those I use a script that calculates the sunrise/sunset times based on latitude/longitude. It removes power to the camera one hour after sunset and starts it back up again one hour before sunrise. In the time the camera is off the script kills ffmpg and starts a different script that either plays a stored video or displays a image. This keeps the YouTube link up till the live video starts again.

Some of the cameras utilize cellular wireless links for the internet connection. On these I have a script that pings a dependable internet server every five minutes. It pings three times at two second intervals. If it does not get a response, the controller cuts power to the cell modem for a few seconds and then powers it back up. This usually solves the problem. If not, the script will do it again in five minutes till it starts working again.

I also send log files to a SFTP server at my office. The log files help me keep track what is going on at the remote site. They contain CPU temp, housing temperature inside/out, housing door alarm, solar power stats, UPS status, etc. Most of the cameras are in remote locations, so anything I can do to automate the troubleshooting and repair process saves me much time and expense.

Here is a picture of the control board that makes all this happen. The Raspberry Pi does the YouTube server duties and all the sensor monitoring and control. The black relay is a latching relay that switches the power to the IP camera. The other two relays are used to cycle power to the cellular router and other duties. Sensor inputs are either i2c one wire.

What kind of control board is the that your RPI is plugged into?
 
Top