'How to live stream a local video using FFmpeg

I am trying to get used to the FFmpeg library, and currently, I have been trying to stream local video on VLC using FFmpeg.

The command I have been using is:

$ ffmpeg -i sample.mp4 -v 0 -vcodec mpeg4 -f mpegts udp://127.0.0.1:23000

I have not been able to stream the file on VLC.

Any help is appreciated.



Solution 1:[1]

My guess is that you are trying to play in VLC using the URL udp://127.0.0.1:23000 as you have it in the FFmpeg command. In VLC, try using udp://@:23000 instead.

Solution 2:[2]

In the first terminal:

$ ffmpeg -i sample.mp4 -v 0 -vcodec mpeg4 -f mpegts udp://127.0.0.1:23000

Open a second terminal and use:

$ ffplay udp://127.0.0.1:23000

Solution 3:[3]

It works, but it's ugly on VLC.

On MacOS Catalina with:

ffmpeg -f avfoundation -framerate 30 -i "0" -f mpeg1video -b 200k -r 30 -vf scale=640:360 udp://127.0.0.1:5555

and it works well with:

ffplay -fflags nobuffer -flags low_delay -framedrop -strict experimental   udp://127.0.0.1:5555

Solution 4:[4]

Along with @Omy's answer be sure to add -re before the input to ensure realtime (normal) livestreaming than sending too many UDP payloads at once. For instance,

ffmpeg -re -i sample.mp4 -v 0 -vcodec mpeg4 -f mpegts udp://127.0.0.1:23000

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 Jeankowkow
Solution 2 Jeankowkow
Solution 3 Jeremy Caney
Solution 4 xsb