Stream MP4 over HTTP without segments

Viewed 5137

I'm trying to stream MP4.

If you stream MP3, you can stream it to something (maybe via RTMP or via IceCast) and watch it via HTTP (but no HLS). Your live MP3 file is something like: http://example.com/live.mp3. Here you can listen to live generated MP3.

Now I want something simular with MP4. I want to stream MP4 (AVC/H.264) to a server (maybe via RTMP) and want to receive the livestream on this location: http://example.com/live.mp4. I don't want to use HLS (with it's M3U8 file and TS-files).

Is this possible?

I know it works with a already generated MP4, after you converted it to a FastStart/WebOptimised MP4, but I want a LIVE mp4.

1 Answers

First of all you compare apples and bananas: mp3 is a codec and mp4 is a Container.

If you would just "stream" an mp4 file, you would just stream binary data without giving the Decoder any clue about what it is looking at. Thats where HLS and Co. come in.

As you mention, in order to stream mp3, one needs some Addition like Icecast or an rtmp Server. Same if you want to stream AVC/AAC: you can use e.g. DASH, HLS, rtmp, rtsp, udp with mpeg2 Transport stream as Container and your stream is ready. (most of the stuff somehow is based on mpeg2ts)

The Problem is with the client-side requirements. If you like it to be HTML5 compatible and cross-platform, currently you basically can only use HLS or DASH for live streaming.

In case the Receiver application can be something different than Flash or HTML5, one of the most simple ways that does not imply the usage of an additional Streaming Server is to use UDP Streaming of an mpeg2 Transport stream.

I'll add a very simplified drawing so you might get an idea how the different Technologies work:

Streaming methods

Additionally there are constantly new Technologies coming up, e.g. i do use WebRTC for live Streaming to HTML5 Browsers in my recent applications.

In theory you could just stream the .mp4 binary data but the Client would need to be very well prepared for it. In case the Client does not receive the moov Atom at the start of file, it is not really receiving an mp4 stream anymore but just a binary AVC/AAC stream. This is more or less exactly how MPEG DASH works. It stores the needed Information for Decoding as a separate file along with the binary file chunk for a certain, short time period.

[EDIT] as i just stepped over it, here a related ffmpeg command:

ffmpeg -i D:\input.mxf -s 640x360 -hls_list_size 30 -hls_flags delete_segments+append_list+omit_endlist -hls_list_size 1 -f hls c:\xampp\htdocs\out.m3u8

Then i downloaded and extracted this to my webservers root: https://github.com/video-dev/hls.js

From there i opened the demo page from hls.js: http://localhost/hls/demo/index.html - and entered the url to my m3u8 "http://localhost/out.m3u8" there and it played my live video fine. Without installing any plugins to my browser ;-)

Source: Change ffmpeg input on the fly

Related