Yes, this topic keeps popping up from time to time also here on SO.
I've read a lot about this topic and also tried some solutions but I have some constraints:
- browser-independency (most browsers should work)
- platform-independent (major platforms should be supported)
- work out-of-the-box (no plugins!)
- low latency (preferred under 1 sec)
- bandwidth is limited (MJPEG is not an option)
- no transcode!
So going forward: an H264 stream seems perfect for constraints 1 and 2.
Also my source produce a live H264 (to be exact: MPEG-4 AVC, part 10) into an RTSP container.
But RTSP is still not supported in browser.
What I've checked:
- How to embed streaming rtsp media into an html5 page
- How can I display an RTSP video stream in a web page?
- stream RTSP to HTML website
- Displaying RTSP on website
- stream RTSP to HTML website
- How to get RTSP stream over web application
- RTSP solution for JavaScript/HTML5
- Streaming via RTSP or RTP in HTML5
All the posts above are related to this question, and a lot of valuable information was there.
Also I've read a very good article from 2014 (!) which is detailed and quite forward-looking.
So, as of today, the best solution would be this:
- parse the RTSP and extract the h264 stream
- restructure the stream (convert it to fragmented MP4)
- websocket (see later)
- fMP4 can be easily played by HTML5 video if the browser has the MSE (alternative is to use broadway.js that is cool but CPU intensive)
There are solutions where the step 1 and 2 happens on server side, then the fMP4 is pushed into a websocket. The client consumes the data from websocket and pass it to MSE components for displaying.
The article from 2014 shows that step2 can also happen on client side. In this case only step 1 happens on the server, then h264 is pushed into the websocket, and on the client side there is the restructuring and displaying of course.
Streamedian seemed a good solution for the first sight, but they doesn't publish their server side codes, and also their site returned with 502 error for a day.
I don't want to use GStreamer or ffmpeg, they are both too heavy.
However there are nice items which can help:
- MP4Box.js - segment an MP4 file for use with the Media Source Extension API
- mux.js - inspection and manipulation tools for video files
Going back to my list, step2 can be done with MP4Box - at least I believe / hope.
Step3 and step4 are straightforward, there are tons of howtos on these ones.
However I'm a bit puzzled with step1. It shall be done on server side, preferably in a language which can interact with websockets easily (like java).
That is the point of my question: I need to extract the h264 stream from RTSP in java, how can I do it simple but without calling external programs?