Convert RTSP to HLS using FFmpeg

If you want to play the streaming on iOS devices. You should use HTTP Live Streaming (HLS). HLS is the only one way to play the streaming for iOS.

FFmpeg supports convert the RTSP streaming to HLS. FFmpeg calls it “segment”. This is a document about segment arguments.
https://www.ffmpeg.org/ffmpeg-formats.html#segment_002c-stream_005fsegment_002c-ssegment

ffmpeg -fflags nobuffer \
-rtsp_transport tcp \
-i rtsp://your-rtsp-server:8554/CH001.sdp \
-vsync 0 \
-copyts \
-vcodec copy \
-movflags frag_keyframe+empty_moov \
-an \
-hls_flags delete_segments+append_list \
-f segment \
-segment_list_flags live \
-segment_time 1 \
-segment_list_size 3 \
-segment_format mpegts \
-segment_list /tmp/stream/index.m3u8 \
-segment_list_type m3u8 \
-segment_list_entry_prefix /stream/ \
/tmp/stream/%d.ts
FFmpeg will generate index.m3u8, 1.ts, 2.ts,3.ts, ….
index.m3u8 is a list file. It will tell the player what files should be downloaded and played.

Then you should start your server(express or gin) let the browser can access files.

Set the src attribute of <video> in your html file.

<video id="video-player" controls preload="none">
<source src="/stream/index.m3u8" type="application/x-mpegURL">
</video>
You can play the streaming on the Safari of iOS devices.