Search code examples
ffmpegstreamyoutube-apirtsp

ffmpeg multiple rtsp cameras into sigle stream to youtube


I have two rtsp ip cameras (dlink) and I want combine (merge) 2 stream in one video output and put it to yutube (live streaming).

My first step is ok and my command is:

ffmpeg 
-i "rtsp://xxxxxx:[email protected]/live2.sdp" 
-i "rtsp://xxxxxx:[email protected]/live2.sdp" 
-filter_complex "
nullsrc=size=1600x448 [base]; 
[0:v] setpts=PTS-STARTPTS, scale=800x448 [upperleft]; 
[1:v] setpts=PTS-STARTPTS, scale=800x448 [upperright]; 
[base][upperleft] overlay=shortest=1 [base]; 
[base][upperright] overlay=shortest=1:x=800 [base]" 
-map [base] test.mp4

My test.mp4 video output is ok.

After that, I try to send this video to youtube live with this command:

ffmpeg 
-i "rtsp://xxxxxx:[email protected]/live2.sdp" 
-i "rtsp://xxxxxx:[email protected]/live2.sdp" 
-filter_complex "
nullsrc=size=1600x448 [base]; 
[0:v] setpts=PTS-STARTPTS, scale=800x448 [upperleft]; 
[1:v] setpts=PTS-STARTPTS, scale=800x448 [upperright]; 
[base][upperleft] overlay=shortest=1 [base]; 
[base][upperright] overlay=shortest=1:x=800 [base]" 
-map [base] -f flv "rtmp://a.rtmp.youtube.com/live2/xxx-xxxx-xxxx-xxxx"

But the youtube stream does not receive data. (It seems to start but do not see the image). I think is a audio problem. But I don't know how to insert a fake audio (I don't want audio).

Is there a solution?

Thanks, Mattia


Solution

  • Try this, with dummy audio

    ffmpeg 
    -i "rtsp://xxxxxx:[email protected]/live2.sdp" 
    -i "rtsp://xxxxxx:[email protected]/live2.sdp"
    -f lavfi -i anullsrc  
    -filter_complex "
    [0:v] setpts=PTS-STARTPTS,scale=800x448,setsar=1[upperleft]; 
    [1:v] setpts=PTS-STARTPTS, scale=800x448,setsar=1[upperright]; 
    [upperleft][upperright]hstack[base]" 
    -map [base] -map 2 -f flv "rtmp://a.rtmp.youtube.com/live2/xxx-xxxx-xxxx-xxxx"