0
  1. How can I send two separate camera streams with one command? (The image from two cameras is sent to the same address but with different ports)

ffmpeg -stimeout 5000000 -rtsp_transport tcp -i "rtsp://admin:password@192.168.0.14:554/Streaming/Channels/101/" -c:v copy -c:a aac -f mpegts udp://176.xxx.xxx.126:91?pkt_size=1316

ffmpeg -stimeout 5000000 -rtsp_transport tcp -i "rtsp://admin:password@192.168.0.15:554/Streaming/Channels/101/" -c:v copy -c:a aac -f mpegts udp://176.xxx.xxx.126:92?pkt_size=1316

If I connect it this way, I receive the same image from the first camera on the two output channels.

ffmpeg -stimeout 5000000 -rtsp_transport tcp -i "rtsp://admin:password@192.168.0.14:554/Streaming/Channels/101/" -c:v copy -c:a aac -f mpegts udp://176.xxx.xxx.126:91?pkt_size=1316 -i "rtsp://admin:password@192.168.0.15:554/Streaming/Channels/101/" -c:v copy -c:a aac -f mpegts udp://176.xxx.xxx.126:92?pkt_size=1316

  1. How can I overlay the logo on the camera image while forwarding it in the same camera streaming?
  2. How can I upload a music file in the same camera streaming and loop it?

1 Answer 1

0

Since you actually asked 3 questions, let's go through it one after the other.

  1. If you want two separate outputs containing different streams, you need to explicitly map them. Your command starts just like your example, but after setting the input, you map everything that's supposed to go into your first output (stream or file doesn't matter) and set the target (file or stream), then map the streams for your 2nd output and set the target.
  2. To overlay a logo, you set your logo image as source and then add it to the video with the overlay filter. This is really easy with just one video stream, but since you have two video streams, and I guess you want the logo in both, you need a complex filter. See FFmpeg Documentation for overlay filter for more details.
    • The use of complex filters alters the way you need to map your streams. Basically you map the input streams not to your files, but to your filters instead. Then you map your filters' output to your files. In the command below I'll use labelled pads for that, see ffmpeg filters documentation for details.
    • Also using any kind of video filter conflicts with streamcopying (the option -c:v copy from your question). You need to set an encoder for this type of streaming. In the following example I'll use libx264 as this is widely compatible with most devices and shouldn't be too much in terms of hardware requirements. In terms of efficiency and bandwidth of course libx265 would be better, but will be too much to encode in real time on many devices. Even better would be a hardware encoder, but to answer this, you need to know on what device exactly the code will be run. Impossible to tell that with a generic command.
  3. You can set an audio file as 3rd source and loop it infinitely with -stream_loop -1 -i your_audio_file_here

All together you command will look like this, placing the logo in the top left corner:

ffmpeg -stimeout 5000000 -rtsp_transport tcp /
    -i "rtsp://admin:[email protected]:554/Streaming/Channels/101/" /
    -stimeout 5000000 -rtsp_transport tcp /
    -i "rtsp://admin:[email protected]:554/Streaming/Channels/101/" /
    -i your_logo_image_here -stream_loop -1 -i your_audio_file_here /
    -filter_complex "[0:v:0][2]overlay[video1]; [1:v:0][2]overlay[video2]" /
    -map "[video1]" -map 3 -c:v libx264 -preset faster -c:a aac -f mpegts udp://176.xxx.xxx.126:91?pkt_size=1316 /
    -map "[video2]" -map 3 -c:v libx264 -preset faster -c:a aac -f mpegts udp://176.xxx.xxx.126:92?pkt_size=1316
3
  • With these settings, he gets this error: Streamcopy requested for output stream 0: 0, which is fed from a complex filtergraph. Filtering and streamcopy cannot be used together.
    – Arky
    Aug 19, 2021 at 16:29
  • You can explain to me on your example the mapping. I do not understand this notation: [0: v: 0] [2] overlay [video1]; [1: v: 0] [2] overlay [video2] relative to: -map "[video1]" -map 3 ............... -map "[video2]" -map 3 ..............
    – Arky
    Aug 19, 2021 at 16:35
  • You are right about the stream copying. I took the codec settings from your questions and forgot these need to be altered as well when overlaying. The answer is adjusted accordingly. The stream selection is a bit too complex to dive into in just a comment. I added some more details to the answer, but everything further should either be taken from the ffmpeg documentation or go into an own question about stream mapping with complex filters.
    – Malte
    Aug 20, 2021 at 9:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .