Record synchronized video and audio into container file with gstreamer

I am using a TI DM365 EVM to record video and audio. I need to encode these two streams and save them in a container file like .avi or .mp4. I am using the following gstreamer pipeline:

gst-launch v4l2src always-copy=FALSE num-buffers=-1 do-timestamp=TRUE ! 'video/x-raw-yuv,format=(fourcc)NV12,width=1280,height=720,framerate=30/1' ! queue ! TIVidenc1 codecName=h264enc engineName=codecServer byteStream=false genTimeStamps=true ! queue ! mux. alsasrc num-buffers=-1 typefind=TRUE do-timestamp=TRUE ! audio/x-raw-int,width=16 ! queue ! TIAudenc1 codecName=aaclcenc engineName=codecServer genTimeStamps=true name=aenc ! queue ! mux. avimux name=mux ! filesink location=vidaudtest.avi sync=true

The result is that I get an .avi file, but when I play the file back on a PC using Totem Movie Player, the video plays too quickly while the audio plays at regular speed. For example, in a 5 minute file, the video finishes playing in 40 seconds.

Also, while recording, I get several of these messages:

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

Has anyone else seen this behavior? Any ideas or solutions?


i guess the problem is that your device cannot deliver frames at the rate you requested. a possible solution is to "re-sample" your video-stream, by running it through a videorate element:

v4l2src ! 'video/x-raw-yuv,format=(fourcc)NV12,width=1280,height=720' ! videorate force-fps=30  ! ...

UPDATE : alternatively something like this could work as well:

... ! 'video/x-raw-yuv,format=(fourcc)NV12,width=1280,height=720' ! videorate ! 'video/x-raw-yuv,framerate=(fraction)30/1' ! ...
链接地址: http://www.djcxy.com/p/7638.html

上一篇: Gstreamer管道多个接收器到一个src

下一篇: 使用gstreamer将同步的视频和音频记录到容器文件中