Buffering on webrtc?

The config as below:
Video Cam->RTSP->WCS->WebRTC->Browser,

Is it possible to add some buffering of about 0.25s to 0.5s delay, so that the video can be smoother on network jittering, and i don't mine the delay within about 1 seconds. Thanks
 

Max

Administrator
Staff member
Good day.
WebRTC itself is intended to real time streaming, so stream cannot be buffered directly. But you can republish a stream as RTMP to localhost, set up RTMP outgoing buffer, then play stream republished as WebRTC
RTSP->WCS->RTMP->WCS->WebRTC->Browser
For example:
1. Set the following parameters in flashphoner.properties file
Code:
rtmp_out_buffer_enabled=true 
rtmp_out_buffer_start_size=1000
rtmp_out_buffer_initial_size=1000
2. Capture RTSP stream using REST API
Code:
POST /rest-api/rtsp/startup HTTP/1.1
Host: wcs:8081
Content-Type: application/json

{
    "uri": "rtsp://server/stream",
    "localStreamName": "rtsp_stream1"
}
3. Republish the stream to localhost
Code:
POST /rest-api/push/startup HTTP/1.1
Host: wcs:8081
Content-Type: application/json

{
    "streamName": "rtsp_stream1",
    "rtmpUrl":"rtmp://localhost:1935/live/stream1",
    "rtmpTransponderFullUrl": true
}
4. Play the republished stream stream1 from WCS in browser via WebRTC
In this case, stream will be buffered while RTMP republishing.
 
I have tried as you said, and it can add delay on the video, but i found that the video sometime have distortion. What could be the problem?Thanks
 

Max

Administrator
Staff member
This can be a channel quality/bandwidth issue. Also, it can be video transcoding issue (but normally it should not start unless you are trying to play VP8)
So please provide us RTSP link to test and/or SSH access to the server using this form, we will check.
 
Sent the rtsp link to you, and we connect rthe rtsp using TCP, If not using rtmp, the video is ok without problem, but if added rtmp on the middle, the video sometime have distortion.

We added the following on the properties:
ice_tcp_transport=true
rtmp_out_buffer_enabled=true
rtmp_out_buffer_start_size=500
rtmp_out_buffer_initial_size=500
 

Max

Administrator
Staff member
We checked the stream.
Seems like buffering will not help you. The problems are in the strem itself, VLC also plays it with artifacts and messages like picture is too late in logs:
screenshot.png

ffprobe shows the following errors for the stream
1620287012296.png

When playing it via WebRTC directly, the picture is twitching on this errors (vehicles move back and forth). WebRTC TCP transport just prevents packet losses between WCS and playing client, RTSP stream is interleaved, so it is captured via TCP too.
So if you cannot fix the stream at source side, WebRTC without additional buffering seems the best to play it.
 
If use HTTP Tools>Preference>Input/Codecs->Live555 stream transport->HTTP (default) in VLC Player, the picture is twitching, but if i set the Live555 stream transport to RTP over RTSP (TCP) on VLC Player, no problem is found so far, also if i set the WCS to use TCP to connect rtsp, the video is normal, but after adding RTMP on the middle, it will have problem. So it should be fine on TCP connection.
 

Max

Administrator
Staff member
If use HTTP Tools>Preference>Input/Codecs->Live555 stream transport->HTTP (default) in VLC Player, the picture is twitching, but if i set the Live555 stream transport to RTP over RTSP (TCP) on VLC Player, no problem is found so far
We experiencing the same problems in VLC with this setting
1620292160784.png

Seems like problematic frames are in the stream itself. So buffering will not help in this case. The buffering via RTMP republishing may be useful only if packets flow is not smooth, and may be pause between consecutive packets. But if some packets are lost or received out-of-band, buffering is unuseful.
 
Top