Video encoder causes crash when using WebRTC and gstreamer

I’m using the webrtc library provided for the Jestson Nano and passing video frame data from gstreamer to the rtc::AdaptedVideoTrackSource::onFrame. This will work but crash after a few times of re-connecting the peer and restarting the video stream. I’m using the CreateNvVideoEncoderFactory when creating the peer connection factory. This crash does not occur if I use the BuiltinVideoEncoderFactory. The following is the stack trace of the crash

Thread 73 "EncoderQueue" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f99b24000 (LWP 17612)]
0x00000000008b7038 in rtc::CopyOnWriteBuffer::SetSize(unsigned long) ()
Current language:  auto
The current source language is "auto; currently c".
Reading in symbols for pthread_create.c...done.
Reading in symbols for ../sysdeps/unix/sysv/linux/aarch64/clone.S...done.
#0  0x00000000008b7038 in rtc::CopyOnWriteBuffer::SetSize(unsigned long) ()
#1  0x0000000000c3ffac in webrtc::NvVideoEncoder::InitEncode(webrtc::VideoCodec const*, int, unsigned long) ()
#2  0x0000000000da67b8 in webrtc::VideoStreamEncoder::ReconfigureEncoder() ()
#3  0x0000000000da7da0 in webrtc::VideoStreamEncoder::MaybeEncodeVideoFrame(webrtc::VideoFrame const&, long) ()
#4  0x0000000000dabe68 in webrtc::webrtc_new_closure_impl::ClosureTask<webrtc::VideoStreamEncoder::OnFrame(webrtc::VideoFrame const&)::$_8>::Run() ()
#5  0x0000000000a14dac in webrtc::(anonymous namespace)::TaskQueueLibevent::OnWakeup(int, short, void*) ()
#6  0x0000000000a16404 in event_base_loop ()
#7  0x0000000000a14c84 in webrtc::(anonymous namespace)::TaskQueueLibevent::ThreadMain(void*) ()
#8  0x00000000008be584 in rtc::PlatformThread::StartThread(void*) ()
#9  0x0000007fb6180088 in start_thread (arg=0x7f6e4e838f) at pthread_create.c:463
        pd = 0x7f6e4e838f
        unwind_buf = 
              {cancel_jmp_buf = {{jmp_buf = {548039442432, 547311485912, 547311485838, 547311485839, 25, 4096, 547311485912, 548516003840, 548039442432, 547810135880, 548039440384, 5799331034265429954, 0, 5799331033721610142, 0, 0, 0, 0, 0, 0, 0, 0}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimized out>
#10 0x0000007fb5e7effc in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78

I am still learning gstreamer and webrtc, so any help is appreciated.

Please share your release version:

cat /etc/nv_tegra_release

And do you use the package we provided on the release page:
Jetson Linux | NVIDIA Developer
NVIDIA Hardware Acceleration in the WebRTC Framework

Hi @DaneLLL, thanks for the response.
The output of cat /etc/nv_tegra_release is

# R32 (release), REVISION: 6.1, GCID: 27863751, BOARD: t210ref, EABI: aarch64, DATE: Mon Jul 26 19:20:30 UTC 2021

I am using this webrtc package: Jetson Download Center | NVIDIA Developer
Could this be the culprit?
I shall give the package provided on the release page a try

Hi @DaneLLL, using the correct version of the library has solved the issue. Thanks for the help

1 Like