用gstreamer将同步视频和音频录制到容器文件中。

时间:2022-04-20 04:51:31

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:

我使用一个TI DM365 EVM录制视频和音频。我需要对这两个流进行编码,并将它们保存在一个容器文件中,比如.avi或.mp4。我正在使用以下gstreamer管道:

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

gst-launch v4l2src always-copy=FALSE num-buffer =-1 do-timestamp=TRUE !'视频/ x-raw-yuv、格式=(fourcc)NV12宽度= 1280,身高= 720,帧速率= 30/1 ' !队列!TIVidenc1 codecName=h264enc engineName=codecServer byteStream=false genTimeStamps=true !队列!mux。alsasrc数字缓冲=-1类型的查找=TRUE do-timestamp=TRUE !音频/ x-raw-int、宽度= 16 !队列!TIAudenc1 codecName=aaclcenc engineName=codecServer genTimeStamps=true name=aenc !队列!mux。avimux name = mux != vidaudtest filesink位置。avi同步= 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.

结果是我得到了一个.avi文件,但是当我使用Totem电影播放器在PC上播放文件时,视频播放的太快,而音频播放的速度是正常的。例如,在5分钟的文件中,视频在40秒内完成。

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?

有人看到过这种行为吗?任何想法或解决方案?

1 个解决方案

#1


0  

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' ! ...

#1


0  

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' ! ...