使用Gstreamer-1.0编码G722遇SIGSEGV错误,求解决方案
Let's break down your problem step by step and fix this SIGSEGV issue, plus explore better encoder options for G722 on your iMX6ULL/Yocto Morty setup.
1. Fix Your Pipeline First (This Is Likely Causing the Crash)
Your original command includes decodebin right after alsasrc—that's a critical mistake! alsasrc outputs raw PCM audio, not a compressed format that needs decoding. Throwing decodebin at raw audio confuses the pipeline, which is almost certainly triggering the SIGSEGV.
Replace your send command with this cleaned-up version:
gst-launch-1.0 -v alsasrc device="hw:0" ! audioconvert ! audioresample ! avenc_g722 ! fakesink
Even better, G722 natively expects 16kHz sampling rate, mono audio (it's designed for 7kHz bandwidth speech). Forcing these parameters upfront reduces unnecessary conversion and can boost stability:
gst-launch-1.0 -v alsasrc device="hw:0" ! audio/x-raw, rate=16000, channels=1 ! audioconvert ! audioresample ! avenc_g722 ! fakesink
2. Address the ALSA Xrun Warning
The Broken pipe xrun error suggests your ALSA device is underrunning. You can mitigate this by adding a larger buffer to alsasrc to give more headroom for audio processing on the iMX6ULL:
gst-launch-1.0 -v alsasrc device="hw:0" buffer-time=200000 ! audio/x-raw, rate=16000, channels=1 ! audioconvert ! audioresample ! avenc_g722 ! fakesink
The buffer-time=200000 sets a 200ms buffer, which should reduce underrun issues.
3. Alternative G722 Encoders (More Stable Than avenc_g722 on Older Platforms)
Yes, avenc_g722 (from gst-libav) has had stability bugs on ARM platforms like the iMX6ULL, especially in the older versions bundled with Yocto Morty. Try these more reliable alternatives:
Option 1: g722enc (GStreamer's Official Encoder)
This encoder is part of gst-plugins-good—check if your Yocto image includes this plugin (it should by default, but if not, add gst-plugins-good to your build recipe). It's maintained directly by the GStreamer team and tends to be more stable on embedded ARM:
gst-launch-1.0 -v alsasrc device="hw:0" ! audio/x-raw, rate=16000, channels=1 ! audioconvert ! audioresample ! g722enc ! fakesink
Option 2: Updated avenc_g722 (If You Can Patch/Upgrade)
You mentioned thinking ffenc_g722 was only for GStreamer 0.10—you're right about that, but for GStreamer 1.x, FFmpeg's G722 encoder is wrapped in avenc_g722 via the gst-libav plugin. If you can't switch to g722enc, try updating gst-libav or applying ARM-specific patches to the FFmpeg version in your Yocto build to fix the crash.
4. Debugging the SIGSEGV Further
If you still hit crashes after fixing the pipeline, use GDB to get a meaningful stack trace (your initial GDB output only showed the poll() call, which isn't helpful):
- Run
gdb gst-launch-1.0 - Inside GDB, start your pipeline with:
run -v alsasrc device="hw:0" ! audio/x-raw, rate=16000, channels=1 ! audioconvert ! audioresample ! avenc_g722 ! fakesink - When the crash happens, run
btto print the full backtrace. This will show exactly which function (inavenc_g722, ALSA, or another plugin) is causing the segmentation fault, making it easier to report or fix the bug.
内容的提问来源于stack exchange,提问作者user8257918

