ant-media / Ant-Media-Server

Ant Media Server is a live streaming engine software that provides adaptive, ultra low latency streaming by using WebRTC technology with ~0.5 seconds latency. Ant Media Server is auto-scalable and it can run on-premise or on-cloud.
https://antmedia.io
Other
4.31k stars 637 forks source link

HLS segment is unexpectedly large when pushing RTMP from RTSP using Gstreamer #5257

Open timantmedia opened 1 year ago

timantmedia commented 1 year ago

Short description

Unexpected HLS media segment duration when generating multiple RTMP streams from one input RTSP stream using Gstreamer. It was found that .ts media segment duration is too long.

When pushing the streams by FFmpeg with the same configuration it was fine, but with Gstreamer the segments are unexpectedly large.

Application HLS configuration settings

Segment List Size: 5 Segment Duration: 2

Gstreamer Command

gst-launch-1.0 rtspsrc location=<SRC_RTSP_URL> ! rtph264depay ! h264parse ! flvmux ! rtmpsink location=<AMS_RTMP_URL>

M3U8 File

Attached is the .m3u8 file where #EXTINF value should be around 2 but the value is more than 100 using GStreamer.

Expected behavior

The segment size should always been inline with what has been configured in the application settings.

Actual behavior

The segment size is larger than whats configured.

Ask your questions on Ant Media Github Discussions

mekya commented 1 year ago

I think the problem is about the keyframe interval because AMS waits for the keyframe to split the ts file.

I don't have too much experience in GStreamer.
Could you just check change the keyframe interval in gstreamer command?

Alternatively, Ant Media Server can be configured to split the ts file according to the duration. On the other hand, it likely causes some playback issues. You can split by time by adding split_by_time to the hlsflags in the application's properties file with this key

settings.hlsflags=split_by_time
MauricioMurga commented 1 month ago

Any news on this?

If I create a stream and add to it a RTMP url pointing to rtmps://Domain-Name:8443/LiveApp/streamId, the segments' duration will not be consistent and incorrect:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:14
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:EVENT
#EXT-X-DISCONTINUITY
#EXTINF:14.400000,
conference_room_fab7970c-b4f9-491c-90f4-160fe6c9d1dbMerged-2024-10-18_07-02-37.010000000000.ts
#EXTINF:5.975000,
conference_room_fab7970c-b4f9-491c-90f4-160fe6c9d1dbMerged-2024-10-18_07-02-37.010000000001.ts
#EXTINF:10.200000,
conference_room_fab7970c-b4f9-491c-90f4-160fe6c9d1dbMerged-2024-10-18_07-02-37.010000000002.ts
#EXTINF:10.155000,
conference_room_fab7970c-b4f9-491c-90f4-160fe6c9d1dbMerged-2024-10-18_07-02-37.010000000003.ts
#EXTINF:10.242000,
conference_room_fab7970c-b4f9-491c-90f4-160fe6c9d1dbMerged-2024-10-18_07-02-37.010000000004.ts

AMS 2.11.3

Expected behavior

Segments should have correct duration and manifests should reflect consistent segment durations.

Actual behavior

Segment durations are all over the place and segment real duration do not correspond to what it's stated on manifest. HLS.js player cannot play correctly these files.