muaz-khan / RecordRTC

RecordRTC is WebRTC JavaScript library for audio/video as well as screen activity recording. It supports Chrome, Firefox, Opera, Android, and Microsoft Edge. Platforms: Linux, Mac and Windows.
https://www.webrtc-experiment.com/RecordRTC/
MIT License
6.57k stars 1.76k forks source link

Is there any way to get video segments in ondataavailable event less than 2 sec key frame interval? #345

Open Hayko-1 opened 6 years ago

Hayko-1 commented 6 years ago

I'm posting blob to the server in ondataavailable event for HLS live streaming. Using ffmpeg to get transport stream segments and to generate a playlist.

ffmpeg -f webm -i \.\pipe\ffpipe -codec:a copy -codec:v copy -hls_time 1 -hls_list_size 0 C:/.../live/palylist.m3u8

According to ffmpeg documentation, when using hls_time: Segment will be cut on the next key frame after this time has passed. So it waits for key frame and generates 2 sec segments, and I'm getting about 4 sec delayed stream.

Is there any way to get video segments in ondataavailable event less than 2 sec key frame interval?

Hayko-1 commented 6 years ago

@muaz-khan, can you please help me. Are there any suggestions for implementing HLS live streaming with minimal delay?

muaz-khan commented 6 years ago

Please check this: https://github.com/Ivan-Feofanov/ws-audio-api

Hayko-1 commented 6 years ago

@muaz-khan, thank you for the answer. It's audio only and as I get from the documentation it has the same issue:

Frame Duration: 2.5, 5, 10, 20, 40, 60

muaz-khan commented 6 years ago

Can you share HLS demo (via email or on github)?

Hayko-1 commented 6 years ago

@muaz-khan, attaching a link to the test project below. https://www.dropbox.com/s/psz9k7aj2arss9h/StreamTest.zip?dl=0 I'm using https://github.com/collab-project/videojs-record that uses RecordRTC. Tried without videojs-record, but the result is the same.

You need to have ffmpeg on your machine (https://ffmpeg.zeranoe.com/builds/) and replace the path in web.config.

P.S. If you'll have any questions please be free to write in comments. I'll do my best to answer as soon as possible. Thanks in advance.