15

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:

  1. browser-independency (most browsers should work)
  2. platform-independent (major platforms should be supported)
  3. work out-of-the-box (no plugins!)
  4. low latency (preferred under 1 sec)
  5. bandwidth is limited (MJPEG is not an option)
  6. 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:

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:

  1. parse the RTSP and extract the h264 stream
  2. restructure the stream (convert it to fragmented MP4)
  3. websocket (see later)
  4. 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?

6
  • 1
    None of the browser is supporting RTSP streaming and they don't have any plan to do so. There are multiple gateway solution which convert from RTSP/RTP to other protocols MPEG-DASH/HLS/WEBRTC. Commented Jan 10, 2020 at 10:13
  • Do you know any gateway solution which is fully open-source (without FFMPEG and etc..)?
    – Daniel
    Commented Jan 10, 2020 at 12:25
  • 2
    Most of the Open-source gateway solution uses ffmpeg - like MP4Box , Shaka Player. Commented Jan 12, 2020 at 17:35
  • Okay, thanks. When ffmpeg extracts h264 frames out of rtsp, it actually does not transcodes only parses the stream?
    – Daniel
    Commented Jan 13, 2020 at 15:20
  • yes, it only streams. no transcoding is done when the rtsp stream is fragmented into mp4 segments Commented Feb 28, 2022 at 16:27

0

Browse other questions tagged or ask your own question.