illuspas / Node-Media-Server

A Node.js implementation of RTMP/HTTP-FLV/WS-FLV/HLS/DASH/MP4 Media Server
https://www.npmjs.com/package/node-media-server
MIT License
5.96k stars 1.52k forks source link

How to reduce the live delay #18

Open dev-kang opened 6 years ago

dev-kang commented 6 years ago

const config = { rtmp: { port: 1935, chunk_size: 4096, gop_cache: false, ping: 1, ping_timeout: 1 }, http: { port: 8000, allow_origin: '*' }, auth: { play: false, publish: false, secret: 'nodemedia2017privatekey' } };

Is there a document for the configure?

illuspas commented 6 years ago

First make sure that the publish side uses low latency encoding parameters. E.g : x264 enable "-tune zerolatency"

"gop_cache:false" can reduce the delay. But it is best to turn it on and implement latency reduction logic on the side of player.

pattarmanjunath50 commented 6 years ago

How Can I add the -tune zerolatency into the config object? Is it in dashFlags of config.trans?

ryangriggs commented 6 years ago

I also am interested. Can you give more information on low-latency options? I'm using ffmpeg with a live h.264 stream input, transcoding back to h.264 with a lower bandwidth. I'm seeing about 4-6 seconds of latency on LAN. Latency is NOT decreased if I do a straight -c copy vs transcoding.

pattarmanjunath50 commented 5 years ago

Hi, I am seeing about 25-30 seconds delay in the live streaming and It increases as the livefeed is kept running for long time. I am using the HLS for live streaming on my web page. Please help

LorenzHope commented 5 years ago

+1

mizoRC commented 5 years ago

Hi! How we can reduce the live delay of hls(m3u8). I have 25-35seconds of delay.

Sigma721 commented 4 years ago

Hi

Did anyone manage to reduce delay time here?

Systemcheck commented 3 years ago

No, same problem here. I switch to another package now.

danielehrhardt commented 3 years ago

Hi! How we can reduce the live delay of hls(m3u8). I have 25-35seconds of delay.

Did you ever find a Solution?

danielehrhardt commented 3 years ago

No, same problem here. I switch to another package now.

Which one?

Brandonza commented 3 years ago

Hi! How we can reduce the live delay of hls(m3u8). I have 25-35seconds of delay.

Did you ever find a Solution?

No, I did not. I have switched to the Nginx RTMP solution. You can play around with the length of the segments, but remember to stay within Apple's recomodations. https://developer.apple.com/documentation/http_live_streaming/hls_authoring_specification_for_apple_devices

Nemra1 commented 3 years ago

Same problem here.. Delay 25 second

KCGD commented 2 years ago

Hello! I haven't found the same solution but I did find that reducing the chunk size will decrease latency. At a chunk size of 500 I get around 3.5 seconds of latency, where as the default 60000 will get you around 10 seconds.

chunk_size: 500

AleksandarKomazec commented 1 year ago

Guys. I am not 100% sure but the problem is next: I need 100% accurate low latency live stream for RC vehicles that we are making. Camera stream is cut into segments. In my case this is 8 seconds length segment (You can see this live in m3u8 file). When client joins and needs stream, the newest segment can be sent. But the problem is because in my case, segment length is 8 seconds which means the lowest latency is about 8 seconds. I tried to reduce segment length to 1 using this option: hlsFlags: "[hls_time=1:hls_list_size=1:hls_flags=delete_segments]", But this is not possible for some reason. Node media server ignores it, and use 8 seconds instead. I dug into soruce code and found that ffmpeg works received these arguments from config. This is so far what I got.

STingerOid commented 7 months ago

When client joins and needs stream, the newest segment can be sent. But the problem is because in my case, segment length is 8 seconds which means the lowest latency is about 8 seconds. I tried to reduce segment length to 1 using this option: hlsFlags: "[hls_time=1:hls_list_size=1:hls_flags=delete_segments]", But this is not possible for some reason. Node media server ignores it, and use 8 seconds instead.

This happens because ffmpeg ignores hls_time if it lower than keyframes interval in video stream. In my case i changed in OBS Studio keyframe interval to 1 sec (default 0 is set it to auto), and my segments duration is 1s now. Found this information here.