<div dir="ltr"><div>Hi,</div><div><br></div><div>To avoid filing a duplicate, I added info and log to this existing issue : </div><div><a href="https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/411">https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/411</a><br></div><div><br></div><div>The minimal test case is:</div><div><code>gst-launch-1.0 uridecodebin uri=``<a href="https://download.blender.org/durian/trailer/sintel_trailer-480p.mp4">https://download.blender.org/durian/trailer/sintel_trailer-480p.mp4</a></code> <code>! videoconvert ! webrtcsink</code><br></div><div>which throws an error while :<br></div><div><code>gst-launch-1.0 uridecodebin uri=``<a href="https://download.blender.org/durian/trailer/sintel_trailer-480p.ogv">https://download.blender.org/durian/trailer/sintel_trailer-480p.ogv</a></code> <code>! videoconvert ! webrtcsink</code><br><div class="gmail_quote"><div class="gmail_attr">(replacing .mp4 by .ogv)</div><div class="gmail_attr">works...</div><div class="gmail_attr"><br></div><div class="gmail_attr">Kind regards,</div><div class="gmail_attr"><br></div><div class="gmail_attr">Vincent</div><div dir="ltr" class="gmail_attr"><br></div><div dir="ltr" class="gmail_attr">On Mon, Nov 20, 2023 at 3:07 PM Mathieu Duponchelle <<a href="mailto:mathieu@centricular.com">mathieu@centricular.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">webrtcsink should be able to handle pre-encoded H264, please file an<br>
issue if you have a minimal test case for reproducing your issue :)<br>
<br>
On Sun, 2023-11-19 at 03:10 +0100, Vincent Deconinck via gstreamer-<br>
devel wrote:<br>
> Hi,<br>
> <br>
> I'm still stuck with the inability to stream h264 video to<br>
> webrtcsink, but I've done a bit of research.<br>
> <br>
> The issue is similar to this one albeit in slightly different<br>
> context:<br>
> <a href="https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/411" rel="noreferrer" target="_blank">https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/411</a><br>
> "livekitwebrtcsink: failure to negotiate h264"<br>
> Starting from gstreamer's most obvious error log "There is no codec<br>
> present that can handle the stream's type.", we get to webrtcsink's<br>
> error "Error running discovery: No caps found for stream video_0"<br>
> triggered by start_stream_discovery_if_needed (in webrtcsink\<a href="http://imp.rs" rel="noreferrer" target="_blank">imp.rs</a>)<br>
> Increasing the log level, this error is preceeded by 4 times the<br>
> following warning:<br>
> net\webrtc\src\webrtcsink\imp.rs:3226:gstrswebrtc::webrtcsink::imp::B<br>
> aseWebRTCSink::lookup_caps::{{closure}}:<wsink> Codec discovery<br>
> pipeline failed: Linking encoding elements<br>
> The message "Codec discovery pipeline failed" is logged from<br>
> lookup_caps(), and if I understand this code correctly, there are two<br>
> cases:<br>
> - either "Stream is already encoded with [a supported] codec", and it<br>
> works out of the box without trying to look up caps (that's what<br>
> happens when input is vp8)<br>
> - or the incoming stream uses another codec (h264 or mpeg2video in my<br>
> tests), and the code tries to enumerate the caps, which fails.<br>
> Does this make sense ?<br>
> <br>
> I'm willing to help (I have zero Rust experience but always eager to<br>
> learn) and I was able to rebuild the plugin from the sources, but I<br>
> don't know how to tell gstreamer to use my home-brewed webrtcsink<br>
> instead of the one in the gstreamer distribution. <br>
> Is it statically linked in the gstreamer build ?<br>
> <br>
> Any help would be greatly appreciated.<br>
> <br>
> KR,<br>
> <br>
> Vincent<br>
> <br>
> <br>
> On Fri, Nov 17, 2023 at 1:13 AM Vincent Deconinck<br>
> <<a href="mailto:vdeconinck@gmail.com" target="_blank">vdeconinck@gmail.com</a>> wrote:<br>
> > Hi,<br>
> > <br>
> > Thanks for all the insightful answers. The log suggestion and the<br>
> > audio frame timing issue triggered the idea of a few more tests.<br>
> > <br>
> > Here are the tests I did today:<br>
> > 1. (set logging with GST_DEBUG=5). Ran the gstreamer server and the<br>
> > browser with "choppy audio". The log is 350+MB and file writing<br>
> > clearly impacts the playback (audio choppiness is increased and<br>
> > video becomes choppy too). AFAICT however, the log shows no ERROR<br>
> > until the end of the video ("pause task, reason: Flushing"). The<br>
> > zipped log is available on <a href="https://we.tl/t-n3kLKluEXE" rel="noreferrer" target="_blank">https://we.tl/t-n3kLKluEXE</a><br>
> > 2. (still logging with GST_DEBUG=5) Changed the pipeline to only<br>
> > use the audio from the webm trailer video file, and used a<br>
> > videotestsrc as the video source => audio is still very choppy<br>
> > 3. (still logging with GST_DEBUG=5) Extracted the audio to a plain<br>
> > uncompressed wav file (obtained with "ffmpeg -i sintel_trailer-<br>
> > 480p.webm sintel_trailer-480p.wav") and used this as the audio<br>
> > source and the videotestsrc as the video source => audio is still<br>
> > very choppy<br>
> > 4. (no logging from here on) Same test: WAV file as the audio<br>
> > source and the videotestsrc as the video source => audio is perfect<br>
> > !<br>
> > 5. Back to using the webm file as the audio source and the<br>
> > videotestsrc as the video source => audio is choppy<br>
> > 6. Converted the source file (vp8+vorbis) to mpeg4 (h264+aac) with<br>
> > "ffmpeg -i sintel_trailer-480p.webm sintel_trailer-480p.mp4" and<br>
> > used this as the audio source and the videotestsrc as the video<br>
> > source => audio is "almost" perfect (I can still hear a "drop" in<br>
> > the second drum at 00:16, which is not present when playing the mp4<br>
> > file locally with VLC).<br>
> > 7. Used the mp4 as source for both video and audio => Fails with<br>
> > "Error received from element wsink: There is no codec present that<br>
> > can handle the stream's type.". Seems h264 video is not recognized<br>
> > ?<br>
> > 8. Converted the source file (vp8+vorbis) to a ts (mpeg2video+ac3)<br>
> > with "ffmpeg -i sintel_trailer-480p.webm -acodec ac3 -vcodec<br>
> > mpeg2video sintel_trailer-480p.ts" and used it for both video and<br>
> > audio => Fails with "There is no codec present that can handle the<br>
> > stream's type". Seems mpeg2video is also not recognized ?<br>
> > 9. Baked an alternate webm file using opus instead of vorbis with<br>
> > "ffmpeg -i sintel_trailer-480p.webm -strict -2 -acodec opus -vcodec<br>
> > copy sintel_trailer-480p_opus.webm" => audio/video is perfect !<br>
> > <br>
> > OK. What did I learn ?<br>
> > - a lack of resources (e.g. heavy logging) causes choppiness. My PC<br>
> > is quite good though (core i9 3.6GHz 32GB w/ GeForce RTX 2060) but<br>
> > maybe logging chokes gsteamer.<br>
> > Regarding audio codecs :<br>
> > - Vorbis causes atrocious choppiness.<br>
> > - AAC is almost OK<br>
> > - Wav and Opus are perfect<br>
> > Regarding video codecs:<br>
> > - It seems this pipeline only accepts vp8 as input<br>
> > <br>
> > Questions: <br>
> > My source files being either mpeg4 (with aac or ac3 audio) or even<br>
> > MXF (and conversion beforehand not being an option),<br>
> > - How can I convert the videos on the fly ? <br>
> > - Isn't vconvert meant to perform the conversion if required ?<br>
> > <br>
> > Sorry again for the newbie questions...<br>
> > <br>
> > Kind regards,<br>
> > <br>
> > Vincent<br>
> > <br>
> > On Thu, Nov 16, 2023 at 7:07 PM cfd new <<a href="mailto:newcfd@yahoo.com" target="_blank">newcfd@yahoo.com</a>> wrote:<br>
> > >  <br>
> > > Thank you so much for your detailed mail. Very nice!<br>
> > > <br>
> > >     Joe<br>
> > > <br>
> > >  <br>
> > >  <br>
> > >  <br>
> > >  On Thursday, November 16, 2023, 01:00:44 p.m. EST, cfd new via<br>
> > > gstreamer-devel <<a href="mailto:gstreamer-devel@lists.freedesktop.org" target="_blank">gstreamer-devel@lists.freedesktop.org</a>> wrote: <br>
> > >  <br>
> > > <br>
> > >  <br>
> > > <br>
> > >  <br>
> > >  <br>
> > > Hi, Philipp, <br>
> > > <br>
> > >    very interested in your code. I got the following message when<br>
> > > I stream a live video to youtube. Maybe it is related to your<br>
> > > case.<br>
> > > <br>
> > >    Joe<br>
> > > 0:03:35.140304346 21323 0x7f1fa004c240 WARN          <br>
> > > audioresample<br>
> > > gstaudioresample.c:732:gst_audio_resample_check_discont:<audiores<br>
> > > ample1> encountered timestamp discontinuity of 639 samples =<br>
> > > 0:00:00.039937500<br>
> > > 0:03:35.141001930 21323 0x7f1fa004c240 WARN          <br>
> > > audioresample<br>
> > > gstaudioresample.c:732:gst_audio_resample_check_discont:<audiores<br>
> > > ample1> encountered timestamp discontinuity of 639 samples =<br>
> > > 0:00:00.039937500<br>
> > > 0:03:35.141314636 21323 0x7f1fa004c240 WARN          <br>
> > > audioresample<br>
> > > gstaudioresample.c:732:gst_audio_resample_check_discont:<audiores<br>
> > > ample1> encountered timestamp discontinuity of 639 samples =<br>
> > > 0:00:00.039937500<br>
> > > <br>
> > >  <br>
> > >  <br>
> > >  <br>
> > >  On Thursday, November 16, 2023, 06:35:55 a.m. EST, Philipp B via<br>
> > > gstreamer-devel <<a href="mailto:gstreamer-devel@lists.freedesktop.org" target="_blank">gstreamer-devel@lists.freedesktop.org</a>> wrote: <br>
> > >  <br>
> > > <br>
> > >  <br>
> > > <br>
> > >  <br>
> > > Hi,<br>
> > > <br>
> > > [dislaimer: I didnt work with gstreamer for some time, my<br>
> > > terminology<br>
> > > might be a bit rusty]<br>
> > > <br>
> > > I also had audio issues when streaming video files over webrtc,<br>
> > > and<br>
> > > judging by your video, it could be the same issue you face.<br>
> > > <br>
> > > For me it turned out to be small rounding errors in the audio<br>
> > > frame<br>
> > > timestamps. Due to the realtime nature, browsers playing webrtc<br>
> > > audio<br>
> > > are not aiming for a perfect smooth playback, but rather for<br>
> > > perfect<br>
> > > realtime. Small deviations in timestamps instantly lead to the<br>
> > > browser<br>
> > > inserting small pieces of silence, or dropping a few ms of audio.<br>
> > > <br>
> > > The most obvious effect was the volume being way lower than it<br>
> > > should<br>
> > > be. This was caused by the player/browser constantly fading<br>
> > > segments<br>
> > > in and out, to overlap them with the next one, or with silence.<br>
> > > Also,<br>
> > > I had similar distortion artifacts than you have.<br>
> > > <br>
> > > To be clear, my issue seemed to be related to transmission of<br>
> > > non-live, pre-encoded video only. WebRTC is made for live<br>
> > > transmissions, where audio frame timestamps are directly related<br>
> > > to<br>
> > > the wall clock time at which a segment has been recorded. In<br>
> > > contrast,<br>
> > > a non-live video file typically has a stream of audio segments,<br>
> > > which<br>
> > > are expected to be played back without gaps, even when there are<br>
> > > small<br>
> > > gaps according to the time stamps.<br>
> > > <br>
> > > What happens if you increase the audio frame size? In my case,<br>
> > > this<br>
> > > was improving the situation dramatically, but not fully fixing<br>
> > > it.<br>
> > > <br>
> > > In the end, I got this solved by "smoothing" audio time stamps. I<br>
> > > wrote my own gstreamer element, that kept an estimation of the<br>
> > > next<br>
> > > frames timestamp, based on the last frame. In case, there is a<br>
> > > small<br>
> > > deviation (e.g. below 5 ms), the frames timestamp will be changed<br>
> > > to<br>
> > > that of the estimation. I can provide the code of that element in<br>
> > > case<br>
> > > your interested.<br>
> > > <br>
> > > Philipp<br>
> > > <br>
> > > Am Mi., 15. Nov. 2023 um 23:39 Uhr schrieb Vincent Deconinck via<br>
> > > gstreamer-devel <<a href="mailto:gstreamer-devel@lists.freedesktop.org" target="_blank">gstreamer-devel@lists.freedesktop.org</a>>:<br>
> > > <br>
> > > > <br>
> > > > Hi,<br>
> > > > <br>
> > > > I made some progress in my quest to stream video files to a<br>
> > > > browser using webrtcssink, but audio is not OK. I built the<br>
> > > > following pipeline:<br>
> > > > +--------------------------------------------------------------<br>
> > > > ---------------+<br>
> > > > | uridecodebin.audio ->- audioconvert ->- audioresample ->-<br>
> > > > webrtcssink.audio |<br>
> > > > | uridecodebin.video ----->----- videoconvert ------>------<br>
> > > > webrtcssink.video |<br>
> > > > +--------------------------------------------------------------<br>
> > > > ---------------+<br>
> > > > <br>
> > > > The webrtcsink pads are statically linked, and the uridecodebin<br>
> > > > pads are dynamically linked upon "pad_added" signal (as in<br>
> > > > <a href="https://gstreamer.freedesktop.org/documentation/tutorials/basic/dynamic-pipelines.html" rel="noreferrer" target="_blank">https://gstreamer.freedesktop.org/documentation/tutorials/basic/dynamic-pipelines.html</a><br>
> > > > ).<br>
> > > > <br>
> > > > Problem: The video looks OK in the browser, but the audio is<br>
> > > > choppy. A quick and dirty (sorry) video tells a thousand words:<br>
> > > > <a href="https://youtu.be/1EbPHLZvVLc?t=27" rel="noreferrer" target="_blank">https://youtu.be/1EbPHLZvVLc?t=27</a><br>
> > > > <br>
> > > > (using signalling server, JS API and gstreamer built 2 days ago<br>
> > > > from git HEAD)<br>
> > > > <br>
> > > > I was first using the http URI to the source video but I also<br>
> > > > tried using a local copy of the file, to no avail.<br>
> > > > <br>
> > > > Any idea what could be wrong ? Or an idea how I could track<br>
> > > > down that issue ?<br>
> > > > <br>
> > > > Kind regards,<br>
> > > > <br>
> > > > Vincent<br>
> > >  <br>
> > >  <br>
> > >  <br>
> > >  <br>
</blockquote></div></div></div>