0

I’m trying to inject a video into mediasoup by following this demo https://github.com/versatica/mediasoup-demo/blob/v3/broadcasters/ffmpeg.sh

Command :

ffmpeg -re -v info -stream_loop -1 -i video-audio-stereo.mp4 -map 0:a:0 -acodec libopus -ab 128k -ac 2 -ar 48000 -map 0:v:0 -pix_fmt yuv420p -c:v libvpx -b:v 1000k -deadline realtime -cpu-used -5 -f tee "[select=a:f=rtp:ssrc=1111:payload_type=100]rtp://xxx.xxx.xxx.xxx:49695?rtcpport=43826|[select=v:f=rtp:ssrc=2222:payload_type=101]rtp://xxx.xxx.xxx.xxx:45991?rtcpport=45288

mp4 file here https://github.com/versatica/mediasoup-demo/tree/v3/app/resources/videos

Result : on the web page, I can hear the audio fine but only show the first frame of video, the video’s clock is not running.

https://i.stack.imgur.com/WcrGh.jpg

ffmpeg command seem fine, no error message, still sending video. The mediasoup log seem normal, too.

chrome debug, The framesReceived/s looks weird https://i.stack.imgur.com/tAWT7.jpg

boygiandi
  • 630
  • 10
  • 20
  • No need to use the tee muxer because you're not outputting multiples of the same stream(s). Just do something like: `ffmpeg -re -stream_loop -1 -i input.mp4 -map 0:v:0 -c:v libvpx-vp9 -f rtp rtp://output0 -map 0:a:0 -c:a libopus -f rtp rtp://output1` – llogan Oct 04 '21 at 16:18
  • I found the solution here https://stackoverflow.com/questions/56788387/h264-webrtc-video-streamed-from-ffmpeg-through-janus-is-very-choppy-on-playback/56823716#56823716 – boygiandi Oct 05 '21 at 01:56
  • Did you solve the problem by appending the ffmpeg command with `?pkt_size=1300` like this? `ffmpeg -re -v info -stream_loop -1 -i video-audio-stereo.mp4 -map 0:a:0 -acodec libopus -ab 128k -ac 2 -ar 48000 -map 0:v:0 -pix_fmt yuv420p -c:v libvpx -b:v 1000k -deadline realtime -cpu-used -5 -f tee "[select=a:f=rtp:ssrc=1111:payload_type=100]rtp://xxx.xxx.xxx.xxx:49695?rtcpport=43826|[select=v:f=rtp:ssrc=2222:payload_type=101]rtp://xxx.xxx.xxx.xxx:45991?rtcpport=45288?pkt_size=1300` – HM Moniruzzaman Nov 14 '21 at 10:29
  • Yes, and add keyframe by `-r 30 -g 60` and use & `rtcpport=45288&pkt_size=1300` – boygiandi Nov 15 '21 at 03:43
  • `ffmpeg \-re \-v info \-stream_loop -1 \-i rtmp://3.126.121.45:1935/live/stream\-map 0:a:0 \-acodec libopus -ab 128k -ac 2 -ar 48000 \-map 0:v:0 \-c:v libvpx -minrate 2500k -maxrate 2500k -b:v 2500k -r 30 -g 60 -max_delay 0 -bf 0 -deadline realtime -cpu-used 1 \-f tee "[select=a:f=rtp:ssrc=11111111:payload_type=101]rtp://52.29.30.225:41299?rtcpport=40612&pkt_size=1300|[select=v:f=rtp:ssrc=22222222:payload_type=102]rtp://52.29.30.225:44083?rtcpport=48791&pkt_size=1300" ` But the video freezes randomly. Any idea what might go wrong? – HM Moniruzzaman Nov 18 '21 at 10:36
  • You can try add keyframe more frequently `-r 30 -g 30` – boygiandi Nov 19 '21 at 08:35

0 Answers0