BladesV
BladesV

Reputation: 93

FFMPEG - broadcast "infinite" mp4 udp via HLS

I have a script which sends an mp4 video via udp in an infinite loop, simulating a live stream. I want to broadcast it via HLS live.

I use the following command:

ffmpeg -i udp://<IP_ADDRESS>: -c:v libx264 -b:v 3000k -c:a aac -b:a 128k -f hls -hls_time 10 -hls_list_size 0 -hls_segment_filename <OUTPUT_TS_DIRECTORY>/output%03d.ts <OUTPUT_M3U8_FILE>

But it doesn't work. Ffmpeg produces no output most of the time, except when I try to send a very small video, in which case it seems to work, but only after it is done receiving the whole video.

Any help would be appreciated. Other methods to accomplish the same as well.

Upvotes: 0

Views: 390

Answers (1)

Gyan
Gyan

Reputation: 93319

You can't pipe a MP4 like that.

MP4s have a single header, and the mp4 demuxer will fail with multiple headers, which will happen when you loop the MP4.

The way to do this inside ffmpeg is to use stream_loop.

ffmpeg -stream_loop -1 -i /path/to/mp4 ...

If you must pipe, convert to a streaming format like MPEG-TS.

ffmpeg -i /path/to/mp4 -c copy out.ts

(Of course, not all codecs can be stored in a MPEG-TS.)

Upvotes: 0

Related Questions