繁体   English   中英

如何在gstreamer中录制音频和视频

[英]how to record audio and video in gstreamer

我是 gstreamer 的新手,我想同时录制音频和视频,并将其保存为 .mp4 格式,使用网络摄像头录制视频并使用 MIC 录制音频这是我的管道

gst-launch-1.0 -e v4l2src ! 排队! x264enc! h264解析! 排队! qtmux0. alsasrc ! '音频/x-raw,rate=44100,depth=24'! 音频转换! 音频重采样! 哇塞! 分析! qtmux! 文件接收器位置=test.mp4

当我执行它时,视频只录制了 10 秒,甚至没有录制音频,它给出了一些消息,例如

警告:来自元素 /GstPipeline:pipeline0/GstAlsaSrc:alsasrc0: 无法足够快地录制音频附加调试信息:gstaudiobasesrc.c(866): gst_audio_base_src_create (): /GstPipeline:pipeline0/GstAlsaSrc:alsasrc0: Dropped samples.4222 这很可能是因为下游无法跟上并且消耗样本太慢。

帮我解决这个问题 提前谢谢

尝试使用以下管道将音频和视频录制到一个文件中。

gst-launch-1.0 -e v4l2src device="/dev/video0" ! videoconvert ! queue ! x264enc tune=zerolatency ! mux. alsasrc device="hw:2" ! queue ! audioconvert ! audioresample ! voaacenc ! aacparse ! qtmux name=mux ! filesink location=test.mp4 sync=false

现在得到了管道,它可以完美地录制音频和视频

这里的管道

gst-launch-1.0 -e v4l2src ! '视频/x-raw,width=960,height=720,framerate=30/1'! 排队! x264enc 调谐=零延迟! 多路复用器。 alsasrc ! 音频/x-raw,width=16,depth=16,rate=44100,channel=1! 排队! 音频转换! 音频重采样! 哇塞! 分析! qtmux 名称=多路复用器! filesink location=test.mp4 sync=false

如果管道中有任何不正确的地方,请告诉我

我最终使用了那个(改编自网络的随机回复,抱歉我丢失了来源)

raspivid -t 0 --vflip --hflip -w 1920 -h 1080 -fps 30 --bitrate 14000000 --profile baseline -3d sbs --intra 30 --inline --flush --awb auto --exposure auto --sharpness 0 --contrast -15 --digitalgain 0.0 -o - | gst-launch-1.0 -ve fdsrc num-buffers=-1 ! video/x-h264,width=1920,height=1080,framerate=30/1 ! h264parse ! queue ! smux.video alsasrc device=hw:2,0 ! audio/x-raw,format=S32LE,rate=48000,channel=2 ! audioconvert ! avenc_aac ! aacparse ! queue ! smux.audio_0 splitmuxsink name=smux location=video.mp4 muxer=mpegtsmux

请注意,它用于捕获立体图像,您可以删除“-3d sds”并为单个凸轮调整宽度。 您还可以安全地删除仅对调试有用的 -ve 并将您的音频设备硬件更改为您的捕获卡的编号( $ arecord -l以找出您的卡的 ID)。

我更喜欢使用 qtmux,但由于缺少 raspivid 制作的 h264 流中的 PTS 信息而失败。 mpegtsmux 很高兴。

截至目前,生成的 mpeg 已损坏一半,所有玩家都无法读取(quicktime 失败,而 vlc 很高兴)。 使用 ffmpeg 重新编码: ffmpeg -vcodec mpeg4 -b:v 7561k -qscale:v 2 -acodec aac -ac 2 -async 1 -strict experimental ./video2.mp4 -threads 0 -i video.mp4修复了文件。

希望这对某人有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM