Search code examples
javahttp-live-streamingrtmprtp

How can I broadcast HLS in Java?


Currently, I have an FFMPEG command that takes in an RTMP stream of my webcam (accessed from my web server), and generates a master index HLS file, which references 4 alternative transcoded indexes in 240p, 360p, 480p, 720p.

I can see the sub-indexes and see the video chunks being generated for each quality (and play them)

Now, I want to create a very very basic Java web server using Spring which broadcasts this hls stream to any client that accesses the client site server, which has a embedded video player (something like videoJS). So I would have two instances of a server, one the media server which transcodes, and the other the web server to stream and play the transcoded media.

This video player would access the RTMP or RTP stream using something like videoJS with an URL like "localhost:8080/test/index.m3u8".

How can I go about creating the Java server that streams the master index file? I just need some idea of how to stream the video from the index file being generated.


Solution

  • You don’t “stream” the file. You just host the file via http. The player will then connect and request the file. It will then parse it, and request the video segments. All over http. The server is just a dumb http server. No “streaming” required, no extra server side intelligence required.