Add delay to player

Max

Administrator
Staff member
I take it if I adjust the buffer parameters I can add a delay of 1min?
Yes, this should work
Code:
rtmp_out_buffer_enabled=true
rtmp_out_buffer_start_size=30000
rtmp_out_buffer_initial_size=30000
Please note this requires more Java heap memory for buffering
And rmtp should work with cdn setup we have?
Yes. You can set up RTMP buffering and republishing on Origin server, then subscribers can play both streams from edge.
 

Azhar Ali

Member
Hi Max,

I set up a test server and installed v728 on it.

I updated the settings to the following:
Test 1
Code:
rtmp_transponder_stream_name_prefix =rtmp_
rtmp_transponder_full_url=false
rtmp_out_buffer_enabled=true
rtmp_out_buffer_start_size=30000
rtmp_out_buffer_initial_size=30000
I modified the screen-sharing example and added the following to re-publish it to the local rtmp server.
Code:
session.createStream({
        name: streamName,
        display: localVideo,
        constraints: constraints,
        rtmpUrl: 'rtmp://localhost:1935/live'
    }).on(STREAM_STATUS.PUBLISHING, function(publishStream){
Then I used the player in the demos to play the stream with the stream name as rtmp_streamnName. I shows grey box with status is playing. I waited several mins but it stayed like this. I would have imagined it would start playing after 1min or so of the screen I was sharing.

Test 2
I also tried to turn on the full url setting for the rtmp and performed the same test.

Code:
rtmp_transponder_stream_name_prefix =rtmp_
rtmp_transponder_full_url=true
rtmp_out_buffer_enabled=true
rtmp_out_buffer_start_size=30000
rtmp_out_buffer_initial_size=30000
In this case, player started playing the video straight away with NO delay but it stops playing every time after 1 min or so. publishing is still going on and if you start playing again it works again but stops after a min again.

Not sure if I have missed something or there is a problem. I have emailed some screenshots and also the ssh details to the server.

Hopefully something simple I have missed.

Regards
Azhar
 

Max

Administrator
Staff member
Good day.
Unfortunately, we confirm the issue: RTMP bufferization does not work on video only streams (screen sharing stream is video only). We reproduced it on our test servers.
So we raised the ticket WCS-2847 to fix it.
As workaround, you can publish screen sharing stream using microphone. The mic can be muted, but audio track should be in the stream.
rtmp_transponder_stream_name_prefix=rtmp_
rtmp_transponder_full_url=true
These are the mutual exclusive settings. You should set
Code:
rtmp_transponder_stream_name_prefix=
rtmp_transponder_full_url=true
then use the full URL to set stream name to republish
Code:
var rtmpUrl='rtmp://localhost:1935/live/rtmp_' + streamName
session.createStream({
        name: streamName,
        display: localVideo,
        constraints: constraints,
        rtmpUrl: rtmpUrl
    }).on(STREAM_STATUS.PUBLISHING, function(publishStream){
 

Azhar Ali

Member
Hi Max,
thanks for that. I will test this with audio-only as this is our use case but I was testing this on demo app just for ease.

Regards
Azhar
 

Azhar Ali

Member
Hi Max,

I modified the media devices examples to republish to rmtp as well. I tested with audio only stream and same problem happened. When playing the rtmp_streamName, the player stayed blank. So it seems bufferization only works when both video and audio tracks are available.

I tested this again with audio and video and it worked fine as expected with delay. However, to get a 1min delay I had to set the properties to the following.

rtmp_out_buffer_start_size=60000
rtmp_out_buffer_initial_size=60000

I tried them as you suggested with the following


rtmp_out_buffer_start_size=30000
rtmp_out_buffer_initial_size=30000

but that gave me roughly 30 sec delay. Is that what you would expect?

regards
Azhar
 

Max

Administrator
Staff member
So it seems bufferization only works when both video and audio tracks are available.
Yes, we confirm that. We work on it in ticket WCS-2847 and let you know when fix it.
As workaround, you can publish audio+video stream and then mute audio or video as you need.
However, to get a 1min delay I had to set the properties to the following.

rtmp_out_buffer_start_size=60000
rtmp_out_buffer_initial_size=60000
Yes, that's right. The buffer is filled, then RTMP transponder get data from buffer and send them to stream. So 30000 looks a mistype, sorry.
 

Azhar Ali

Member
Thanks for letting me know.

I will be patient but do you have an estimate on it. We have a new service which we want to put live in about 23 days and this a key part of it. We do have a workaround to do multiple streams delayed one from OBS but OBS one sometimes gets choppy sound as they both use the same mic as the source.

I am not sure I can risk the audio + video workaround, as our service is audio-only and video requires more upload speed and quality of sound is extremely important to our service, and sending video might compromise that.

Any guidance if you can provide would be helpful.

Regards
Azhar
 

Max

Administrator
Staff member
I will be patient but do you have an estimate on it.
We usually give no ETA for forum tickets, but in your case we will fix it before your deadline.
I am not sure I can risk the audio + video workaround, as our service is audio-only and video requires more upload speed and quality of sound is extremely important to our service, and sending video might compromise that.
A muted video track in a stream has a small bitrate (below 30 kbps in our tests), so it should not take a much upload bandwidth, for example
1597634808129.png
 

Max

Administrator
Staff member
Good day.
We fixed the issue with audio only and video only streams republishing as RTMP with bufferization enabled in build 5.2.744. Please update and check.
 

Azhar Ali

Member
Thanks max, will test.

One question, does origin needs to update only or edge servers needs to be on 744 as well. Just checking as we would need to update them and then create templates etc. for autoscale purpose.
 

Max

Administrator
Staff member
One question, does origin needs to update only or edge servers needs to be on 744 as well.
You should only update the server where stream is republished to localhost as RTMP. So it's enough to update Origin only.
 

Azhar Ali

Member
Hi Max,
Update to 744 and tested and it still does not work for audio-only stream.

I modified the media devices examples to republish to rmtp as well. I tested with audio only stream and same problem happened. When playing the rtmp_streamName, the player stayed blank and did not play any audio after 1min. Tried again with audio and video and video played after 1min.

Tried the same with video only stream, it works for that but audio-only stream is still broken as it seems.

You have the server details from my previous email. Can you please check. This is the version which shows on the demo site v.0.5.28.2753-5.2.744

Regards
Azhar
 

Max

Administrator
Staff member
Good day.
We checked audio only streaming with republishing as RTMP in Media Devices example on your server, and the stream plays correctly with 60 seconds delay.
Please don't forget to disable video playback for playing audio only streams (see screenshot, "Play video" switch should be disabled)
1598253824669.png

In Player example, you should use constraints constraints: {video: false, audio: true}
Also, we recommend to disable RTP activity detection or inscrease default activity timeout in server settings
Code:
rtp_activity_timeout=120
 

Azhar Ali

Member
Thanks Max, that probably was the reason for it. I will do the test again.

What's the RTP activity for? Do we need it for audio-only streams?

There are few settings for rtp to disabled rtp_activity_audio , rtp_activity_video, is both needs to be turned off?

Is it enough to turn them off on origin only?
 

Max

Administrator
Staff member
What's the RTP activity for? Do we need it for audio-only streams?
The set of RTP activity options is intended to control stream publishing and stop it if no media data is received during time interval (60 seconds by default)
There are few settings for rtp to disabled rtp_activity_audio , rtp_activity_video, is both needs to be turned off?
To disable RTP activity checking, both options should be turned off
Is it enough to turn them off on origin only?
In your case, they should be turned off on edge servers because the stream is published on edge to be played by subscribers, so the publish session for delayed stream can be stopped while waiting media data for 60 seconds.
Also, you can increase this timeout from 60 seconds to 120 fro example, this should be enough
Code:
rtp_activity_timeout=120
This also should be done on edge servers.
 

Azhar Ali

Member
Hi Max,

I have updated the live servers and in terms of delay all is working fine. We are starting with 10second delay.

However, we have an issue with the quality of the sound on the rtmp version of the stream. WebRTC to WebRTC audio quality if pretty sharp but the RTMP version, audio comes a bit muffled for about 2 seconds, and then it gets clear. This happens every time we talk but audio-only appears muffled on rtmp for 2-3 seconds.
Any idea?
 

Max

Administrator
Staff member
However, we have an issue with the quality of the sound on the rtmp version of the stream. WebRTC to WebRTC audio quality if pretty sharp but the RTMP version, audio comes a bit muffled for about 2 seconds, and then it gets clear. This happens every time we talk but audio-only appears muffled on rtmp for 2-3 seconds.
This happens due to audio transcoding: stream is published via WebRTC in Opus codec, then it is republished as AAC, and then it is played in browser as Opus. So, to improve the sound quality, you should configure SDP for RTMP republishing in /usr/local/FlashphonerWebCallServer/conf/media_transponder.sdp file to prevent unneeded resampling 48 kHz -> 44,1 kHz -> 48 kHz
Code:
v=0
o=- 1988962254 1988962254 IN IP4 0.0.0.0
c=IN IP4 0.0.0.0
t=0 0
a=sdplang:en
m=video 0 RTP/AVP 95 96
a=rtpmap:95 H264/90000
a=fmtp:95 profile-level-id=4de01f;packetization-mode=0
a=rtpmap:96 H264/90000
a=fmtp:96 profile-level-id=4de01f;packetization-mode=1
a=recvonly
m=audio 0 RTP/AVP 108
a=rtpmap:108 mpeg4-generic/48000/1
a=rtpmap:96 mpeg4-generic/8000/1
a=rtpmap:97 mpeg4-generic/11025/1
a=rtpmap:98 mpeg4-generic/12000/1
a=rtpmap:99 mpeg4-generic/16000/1
a=rtpmap:100 mpeg4-generic/22050/1
a=rtpmap:104 mpeg4-generic/24000/1
a=rtpmap:102 mpeg4-generic/32000/1
a=rtpmap:103 mpeg4-generic/44100/1
a=recvonly
and increase Opus encoder bitrate to at least 32 kbps in flashphoner.properties file
Code:
opus.encoder.bitrate=32000
Both settings should be done on Origin server only.
 
Last edited:

Azhar Ali

Member
Hi Max,

I don't have this file on my server at this location. /usr/local/FlashphonerWebCallServer/media_transponder.sdp

Is that correct? I can create it and would it get picked up itself as its present now?

thanks for the help
 
Top