Search code examples
ffmpegrtsp

FFmpeg - capture a rtsp stream and re-stream it to another rtsp-server


I want to capture a Rtsp-stream from a Live-CAM which I then want to re-stream to another Rtsp-server. Basically, my computer will work as a relay-server using FFMpeg.

I have tried this temporary command but I cannot get it working i.e.

ffmpeg.exe -i rtsp://InputIPAddress:554/mystream -preset medium -vcodec libx264 -tune zerolatency -f rtsp -rtsp_transport tcp rtsp://localhost:8554/mysecondstream

I have then tried, for testing purposes, using FFplay to watch the stream from localhost as follows:

ffplay rtsp://localhost:8554/mysecondstream

but no luck.

Anyone who can help me out? Thanks.


Solution

  • Well, I found that this one works:

    ffmpeg -rtsp_transport tcp -i "rtsp://123.123.123.123:554/mystream1" -rtsp_transport tcp -c:v copy -f rtsp rtsp://234.234.234.234:554/mystream2
    

    Works even on an Android phone where I have FFmeg running. However, I am not really pleased with it. I hope I can improve it further.

    EDIT: adding "-use_wallclock_as_timestamps 1" makes the stream stable.