Different and unexpected behavior with webrtcbin and appsrc in Chrome and Firefox
KrzychuZ
krzys95 at gmail.com
Wed Sep 12 09:28:43 UTC 2018
Hi!
I am working on an app based on GStreamer (gstreamer-sharp) that sends video
and audio that it generates, over webrtc to web browsers. My problem is that
in Chrome the received video is smooth but audio is delayed by about 600ms,
while in Firefox a/v stay in sync but the video is visibly stuttering.
I'm using slightly modified samples from here
https://github.com/centricular/gstwebrtc-demos
My pipeline is as follows:
const string PIPELINE_DESC = @"webrtcbin name=sendrecv
appsrc name=videosrc ! clockoverlay ! videoconvert ! queue ! vp8enc
deadline=1 ! rtpvp8pay !
queue ! application/x-rtp,media=video,encoding-name=VP8,payload=97 !
sendrecv.
appsrc name=audiosrc ! audioconvert ! audioresample ! queue ! opusenc !
rtpopuspay !
queue ! application/x-rtp,media=audio,encoding-name=OPUS,payload=96 !
sendrecv.
";
I configure the sources in a following way:
var audiosrc = pipe.GetByName("audiosrc");
var src = new Gst.App.AppSrc(audiosrc.Handle);
src.StreamType = AppStreamType.Stream;
src.IsLive = true;
Gst.Audio.AudioChannelPosition[] position = {
AudioChannelPosition.FrontLeft, AudioChannelPosition.FrontRight };
var ainfo = new Gst.Audio.AudioInfo();
AudioInfo = ainfo;
ainfo.SetFormat(Gst.Audio.AudioFormat.F32, SampleRate, 2, position);
var audioCaps = ainfo.ToCaps();
src["caps"] = audioCaps;
src["format"] = Format.Time;
var videosrc = pipe.GetByName("videosrc");
src = new Gst.App.AppSrc(videosrc.Handle);
src.StreamType = AppStreamType.Stream;
src.IsLive = true;
var vinfo = new Gst.Video.VideoInfo();
VideoInfo = vinfo;
vinfo.SetFormat(VideoFormat.Bgra, 640, 360);
vinfo.FpsD = 1;
vinfo.FpsN = 25;
vinfo.InterlaceMode = VideoInterlaceMode.Progressive;
src["caps"] = vinfo.ToCaps();
src["format"] = Format.Time;
I timestamp buffers this way (I don't know if it is correct):
NumVSamples += 1;
vbuffer.Pts = Util.Uint64Scale((ulong)NumVSamples,
(ulong)Gst.Constants.SECOND, (ulong)FrameRate);
vbuffer.Dts = Util.Uint64Scale((ulong)NumVSamples,
(ulong)Gst.Constants.SECOND, (ulong)FrameRate);
vbuffer.Duration = Util.Uint64Scale((ulong)NumVSamples,
(ulong)Gst.Constants.SECOND, (ulong)FrameRate);
NumASamples += numSamples;
buffer.Pts = Util.Uint64Scale((ulong)NumASamples,
(ulong)Gst.Constants.SECOND, (ulong)SampleRate);
buffer.Dts = Util.Uint64Scale((ulong)NumASamples,
(ulong)Gst.Constants.SECOND, (ulong)SampleRate);
buffer.Duration = Util.Uint64Scale((ulong)NumASamples,
(ulong)Gst.Constants.SECOND, (ulong)SampleRate);
What I noticed in Chrome is that at the beginning of the connection, audio
is in sync but after few seconds it gets delayed. Here
https://imgur.com/a/YnsEEb5 are screenshots from chrome://webrtc-internals
where you can see how size of the jitter-buffer increases. I also find the
spike in packetsReceivedPerSecond a little suspicious.
I would appreciate any input and suggestions on what I am possibly doing
wrong.
Thanks in advance
Krzysztof
--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
More information about the gstreamer-devel
mailing list