'FFMPEG Streaming using RTMP

I'm trying to create a stream using ffmpeg to send a video to a Red5 Server. I've already managed to do this using this command:

ffmpeg -re -y -i "Videos\Video1.mp4" -c:v libx264 -b:v 600k -r 25 -s 640x360 -t 40 -vf yadif -b:a 64k -ac 1 -ar 44100 -f flv "rtmp://192.168.0.12/live/videostream"

My problem is, when ffmpeg finishes encoding the video, it stops the stream, and thus cuts the video short for 5-10 seconds (for short videos), but this gets worse on larger videos.

Is there a way to stop this behavior? I was trying to add a blank 10 second video before and after the original video, but due to some encoding options, I always end up losing audio. And this only kind-of works on the short videos, but on longer videos the problem is still there.

Any recommendations?



Solution 1:[1]

I don't believe its possible to tell FFMpeg to keep the connection open after reading the end of the source file. You would most likely have to use Xuggler or some custom modification of FFMpeg to accomplish such a thing.

Solution 2:[2]

It may be caused by your file or your file length.

When a file ended, ffmpeg will show info like this:

enter image description here

I came to this issue when I push a 11s mp4 videos, when I change to a long mp4 file with 10+ minutes, it works well.

So you can use another mp4 file with proper length.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Paul Gregoire
Solution 2 LF00