paullouisageneau / libdatachannel

C/C++ WebRTC network library featuring Data Channels, Media Transport, and WebSockets
https://libdatachannel.org/
Mozilla Public License 2.0
1.81k stars 366 forks source link

Set the interval for sending key frames #760

Open Von-github opened 2 years ago

Von-github commented 2 years ago

When I was using libdatacahnnel, I found that only one key frame was sent. After packet loss, the video receiver could only play the first frame (the audio is normal). May I ask how to set parameters to solve this problem 6f62ddb2f2961e07c212df9a099ee74

paullouisageneau commented 2 years ago

The key frame interval is an encoder setting, so you have to set it on the encoder outside of libdatachannel.

However, are you sure only one key frame is actually sent? Note that the connection shows continuous very high packet loss over time (about 30%), not just once. That's why playback would be stuck, irrelevant of the number of keyframes.

I'd need more information about your setup, but from the symptoms it looks more like a duplicate of https://github.com/paullouisageneau/libdatachannel/issues/740. Does the issue still happen with last master?

Von-github commented 2 years ago

I'm using a "streamer" and the video is the sample, encoded using generate_h264.py

Von-github commented 2 years ago

I tried the latest master and found that the problem was still unresolved

2微信图片_20221128113906

1微信图片_20221128113832 The keyframe is still only sent once, and if the packet is lost, it cannot be decoded later.

I am using the code in the streamer to create an H264 video clip. How do I set the IFRAME INTERVAL?

paullouisageneau commented 1 year ago

The keyframe is still only sent once, and if the packet is lost, it cannot be decoded later.

That's not the actual problem here. As you can see on the graphs, the connection experiences very high packet loss: 20K packets are lost while 30K are received, meaning the packet loss rate is roughly 40%. Nothing will play if nearly half of packets are lost. Do you run the example locally or across a network?

I am using the code in the streamer to create an H264 video clip. How do I set the IFRAME INTERVAL?

You mean "keyframe interval". The generate_h264.py script calls ffmpeg under the hood to encode as h264. You can change the default keyframe interval by modifying the script and adding -x264opts "keyint=XX" to the ffmpeg command line.