Using a muxer corrupts input from ALSA

I'm trying to make a simple GStreamer program to mux together video from a v4l2 camera and ALSA audio. However, I'm having a lot of problems with the muxer. Here's the command I'm using:

$ gst-launch -e matroskamux name="muxer" ! filesink location=test.mkv v4l2src ! 
video/x-raw-yuv, framerate=10/1, format=(fourcc)YUY2, width=640, height=480 !
videorate ! ffmpegcolorspace ! x264enc ! muxer. alsasrc ! audioconvert ! 
lamemp3enc target=1 bitrate=64 cbr=true ! muxer.

The created file has flawless video, but the console outputs messages like this:

WARNING: from element /GstPipeline:pipeline0/GstAlsaSrc:alsasrc0: Can't record audio 
fast enough
Additional debug info:
gstbaseaudiosrc.c(840): gst_base_audio_src_create (): /GstPipeline:pipeline0/GstAlsaSrc:alsasrc0:
Dropped 10584 samples. This is most likely because downstream can't keep up and is consuming samples too slowly.

and the video is silent. Replacing "alsasrc" with "audiotestsrc" makes a file with the same perfect video and the test tone with no errors. If I use "videotestsrc" instead of "v4l2src" and try to record with alsasrc again, I can see the test video and no errors are given, but the sound is corrupted; it plays in pieces, jumping around at random and often remaining silent. These problems happen if I use avimux instead of Matroska, as well. There's nothing wrong with alsasrc because I can record audio just fine with

 gst-launch -e alsasrc ! audioconvert ! lamemp3enc target=1 bitrate=64 cbr=true !
 filesink location=audio.mp3

I've tried adding a queue after the alsasrc, but it didn't help. An audiorate didn't either. What can I do to fix this pipeline?


没关系,我通过用pulsesrc替换alsasrc来修复它。

链接地址: http://www.djcxy.com/p/43938.html

上一篇: 使用GStreamer的音频屏幕录像如何提高性能?

下一篇: 使用复用器会破坏来自ALSA的输入