Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GStreamer - RTSP to HLS / mp4

I try to save RTSP h.264 stream to HLS mp4 files:

gst-launch-1.0 rtspsrc location="rtsp://....." ! rtph264depay ! h264parse ! matroskamux ! hlssink max-files=0 playlist-length=0 location="/home/user/ch%05d.mp4" playlist-location="/home/user/list.m3u8" target-duration=15

As a result - there is only one file ch00000.mp4, which includes the whole videostream (3min instead of 15sec in "target-duration").

If I save to mpegtsmux / ts files - all is ok for the same command.

What is wrong? Thanks in advance.

like image 888
Nick Saw Avatar asked Sep 06 '25 03:09

Nick Saw


1 Answers

HLS consists of MPEG transport stream segments. So first: matroskamux does not make sense here. You will need mpegtsmux instead. To indicate what it really is you normally would name the files with a .ts extension. It may still work for GStreamer as it is just a file name - players may reject playing it because the expect another sort of file format.

E.g.

gst-launch-1.0 rtspsrc location="rtsp://....." ! rtph264depay ! h264parse ! \
mpegtsmux ! hlssink max-files=0 playlist-length=0 location="/home/user/ch%05d.ts" \
playlist-location="/home/user/list.m3u8" target-duration=15
like image 172
Florian Zwoch Avatar answered Sep 07 '25 20:09

Florian Zwoch