-1

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

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
vcima
  • 421
  • 1
  • 7
  • 20
  • Concerning 2., using https://www.youtube.com/channel/CHANNEL_ID/live or [YouTube Data API v3](https://developers.google.com/youtube/v3/) or [YouTube Livestreaming API](https://developers.google.com/youtube/v3/live/getting-started) to retrieve latest videos/lives should do the trick. – Benjamin Loison Nov 19 '22 at 11:58
  • If you know Python, you may use a Python script that keeps sending video frames when the camera disconnects. I don't think it's possible using FFmpeg command line, because FFmpeg process terminates when the camera disconnects (and when large time is used, it just waits). Python examples for reading and writing video using FFmpeg: [Reading and decoding](https://stackoverflow.com/a/60572878/4926757). [Encoding and writing](https://stackoverflow.com/a/70476737/4926757). [Reading and decoding](https://stackoverflow.com/a/66341885/4926757). All sample are without audio. – Rotem Nov 19 '22 at 22:38

1 Answers1

0

Without developping a tiny application with Gstreamer or LibAV which handle camera or disconnection issue i think you couldn't switch to an image in case of disconnection.

You could use supervisor (https://supervisord.org/) or something like that to ensure ffmpeg retries in case of disconnection.

For 2 i'm not sure if we can guarantee the playerid.

Regards