[FFmpeg-user] Receiving streams from two RTP stream sources, stacking them and sending to RTMP

Nestor Morales nestor.morales at system73.com
Mon Feb 11 12:01:05 EET 2019


Hello,

thanks for your answer.

yes, CPU is normal, so I discard performance issues. See the attached
screenshot.

I managed to make it work, but now I have some issues with the audio, which
has a really long delay (last test, up to 21 seconds delayed):

1) For each RTP input, re-encode it and re-timestamp it using vsync drop
option. Then, send it to a local UDP socket.
/usr/bin/ffmpeg \
  -vsync drop -protocol_whitelist file,udp,rtp -analyzeduration 30M
-probesize 30M -i janus1.sdp \
  -c:v libx264 -preset veryfast -tune zerolatency \
  -g 60 -keyint_min 30 -sc_threshold 0 -dts_delta_threshold 0 \
  -b:v:0 1000k -profile:v:0 baseline \
  -c:a aac -b:a 128k -ar 48000 \
  -filter_complex \
    "
        [0:v]fps=fps=30, setpts='(time(0)*1000000 - RTCSTART) / ((1/30) *
1000000)';
        [0:a]aresample=async=1:min_hard_comp=0.100000,
asetpts='PTS-STARTPTS'
    " \
  -strict experimental \
  -max_muxing_queue_size 1024 \
  -f mpegts udp://127.0.0.1:100001

/usr/bin/ffmpeg \
  -vsync drop -protocol_whitelist file,udp,rtp -analyzeduration 30M
-probesize 30M -i janus2.sdp \
  -c:v libx264 -preset veryfast -tune zerolatency \
  -g 60 -keyint_min 30 -sc_threshold 0 -dts_delta_threshold 0 \
  -b:v:0 1000k -profile:v:0 baseline \
  -c:a aac -b:a 128k -ar 48000 \
  -filter_complex \
    "
        [0:v]fps=fps=30, setpts='(time(0)*1000000 - RTCSTART) / ((1/30) *
1000000)';
        [0:a]aresample=async=1:min_hard_comp=0.100000,
asetpts='PTS-STARTPTS'
    " \
  -strict experimental \
  -max_muxing_queue_size 1024 \
  -f mpegts udp://127.0.0.1:100002

2) Do the mosaic, using the previously re-timestamped UDP inputs:
/usr/bin/ffmpeg \
  -vsync 1 -protocol_whitelist file,udp,rtp -analyzeduration 5M -probesize
5M -i udp://127.0.0.1:10001 \
  -vsync 1 -protocol_whitelist file,udp,rtp -analyzeduration 5M -probesize
5M -i udp://127.0.0.1:10002 \
  -c:v libx264 -preset veryfast -tune zerolatency \
  -g 60 -keyint_min 30 -sc_threshold 0 -dts_delta_threshold 0 \
  -b:v:0 1000k -profile:v:0 baseline \
  -c:a aac -b:a 128k -ar 48000 \
  -filter_complex \
    "
        [0:v]fps=fps=30, setpts='(time(0)*1000000 - RTCSTART) / ((1/30) *
1000000)', scale=320x480[vid1];
        [1:v]fps=fps=30, setpts='(time(0)*1000000 - RTCSTART) / ((1/30) *
1000000)', scale=320x480[vid2];
        [vid1][vid2]hstack;
        [0:a]aresample=async=1:min_hard_comp=0.100000,
asetpts='PTS-STARTPTS'
    " \
  -max_muxing_queue_size 1024 \
  -strict experimental \
  -f flv "rtmp://a.rtmp.youtube.com/live2/####-####-####-####"

I guess that I should re-timestamp the audio properly, but I am still on
it. Any suggestions?

Best regards,
NĂ©stor

PS: Sorry for the long signature, I noticed about it just after sending the
email. It is removed now.

[image: image.png]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 337393 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-user/attachments/20190211/9c5660d9/attachment.png>


More information about the ffmpeg-user mailing list