0

I'm working on a project that requires taking rtsp links from youtube, and using ffmpeg to stream those videos to an rtmp server. My solution works, however it is having some issues.

I'm using these settings:

 -max_delay 0 -initial_pause 0 -rtsp_transport udp -i " + inputLink + " -vcodec libx264 -acodec mp3 -ab 48k -bit_rate 450 -r 25 -s 640x480 -f flv "  + stream

inputLink is replaced with the rtsp link, and stream is replaced with the rtmp server link

So this works but here are the issues I'm having:

  • At the beginning of each video, there is a big lag spike/lots of frames dropped, and then the video resyncs and plays normally
  • Some videos would crash ffmpeg, with a "Conversion failed" message and many frames dropped during the conversion/stream.

  • At the end of each video it would start lagging/ dropping frame, right near the end of the video, in other words it doesn't end normally, every video ends by lagging out / dropping frames

I've been struggling for a long time just to get this working, and now I finally did, I just need to perfect it by taking care of those two issues, if anyone has useful information about the rtsp_transport protocol and how to make it stream with no issues, I would greatly appreciate it. Thanks!

1 Answers1

0

You got some settings wrong.

-bit_rate 450: you asked for a 450 bits per second, it's no wonder it drops a lot of frames! It should be 450k.

If you want a 450 kbps stream then use -ab 48k -vb 402k, where 402 = 450 - 48.

The flv format only supports certain audio rates. You need to also use -ar with one of the following values: 44100, 22050 or 11025.

ffmpeg -i rtsp://... -c:v libx264 -c:a mp3 -ab 48k -ar 44100 -vb 402k -r 25 -s 640x480 -f flv test.flv

aergistal
  • 29,947
  • 5
  • 70
  • 92