我的Logitech C920网络摄像机提供以h264编码的视频流。我使用this "capture" tool来访问数据:使用Gstreamer在录制音频+视频时显示无声视频
这样我就可以观看现场视频:
/usr/local/bin/capture -d /dev/video0 -c 100000 -o | \
gst-launch-1.0 -e filesrc location=/dev/fd/0 \
! h264parse \
! decodebin\
! xvimagesink sync=false
...或者录制的视频流作为原料H264文件:
/usr/local/bin/capture -d /dev/video0 -c 100000 -o | \
gst-launch-0.10 -e filesrc location=/dev/fd/0 \
! h264parse \
! mp4mux \
! filesink location=/tmp/video.mp4
..但我不能为了我的生活而弄清楚如何在同一时间做到这一点。在录制时在屏幕上播放动态节目有时候会很有用,所以我想做这个工作。 花费时间和小时寻找一种方法来同时抓取和屏幕,但没有运气。与tee
s和queue
没有太大的关系。
猜猜这将会是ALSA音频(hw:2,0)进入的好处,但我可以用一种丑陋的黑客方式解决这个问题。现在,我得到这个即使HW:2,0是Audacitu或的arecord有效的输入,例如:
Recording open error on device 'hw:2,0': No such file or directory
Recording open error on device 'plughw:2,0': No such file or directory
因此,要回顾:很想把那些两个视频比特一起,奖金,如果音频会也工作。我觉得这是一个新手。
在此先感谢您提供的任何帮助。
编辑:非工作代码:
/usr/local/bin/capture -d /dev/video1 -c 100000 -o | \
gst-launch-1.0 -e filesrc location=/dev/fd/0 ! tee name=myvid ! h264parse ! decodebin \
! xvimagesink sync=false myvid. ! queue ! mux. alsasrc device=plughw:2,0 ! \
audio/x-raw,rate=44100,channels=1,depth=24 ! audioconvert ! queue ! mux. mp4mux \
name=mux ! filesink location=/tmp/out.mp4
...导致这个:
WARNING: erroneous pipeline: could not link queue1 to mux
编辑:尝试umlaeute的建议,得到了几乎是空的视频文件和视频直播一个冻结帧。在音频启用代码中修复两个小错误(双引号错别字,不将音频编码为与MP4兼容的任何东西)之后,使用/不使用音频没有任何差异,但在audioconvert
之后添加avenc_aac
也没有什么不同。错误输出:
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstAudioSrcClock
Redistribute latency...
ERROR: from element /GstPipeline:pipeline0/GstMP4Mux:mux: Could not multiplex stream.
Additional debug info:
gstqtmux.c(2530): gst_qt_mux_add_buffer(): /GstPipeline:pipeline0/GstMP4Mux:mux:
DTS method failed to re-order timestamps.
EOS on shutdown enabled -- waiting for EOS after Error
Waiting for EOS...
ERROR: from element /GstPipeline:pipeline0/GstFileSrc:filesrc0: Internal data flow error.
Additional debug info:
gstbasesrc.c(2809): gst_base_src_loop(): /GstPipeline:pipeline0/GstFileSrc:filesrc0:
streaming task paused, reason error (-5)
编辑: 好吧,umlaeute的更正后的代码工作完美,但只有当我使用的转换工具的v4l2src代替。而现在,这意味着抓住MJPEG流而不是H264流。我的鼻子没有皮肤,但我想我更喜欢更现代的工作流程。无论如何,这是实际的工作,输出MJPEG视频文件和实时“取景器”。不完美,但非常可行。感谢你的帮助!当涉及到(例如,使用mp4mux
)自动组合多个不同的流
gst-launch-1.0 -e v4l2src device=/dev/video1 ! videorate ! 'image/jpeg, width=1280, height=720, framerate=24/1' ! tee name=myvid \
! queue ! decodebin ! xvimagesink sync=false \
myvid. ! queue ! mux.video_0 \
alsasrc device="plughw:2,0" ! "audio/x-raw,rate=44100,channels=1,depth=24" ! audioconvert ! lamemp3enc ! queue ! mux.audio_0 \
avimux name=mux ! filesink location=/tmp/out.avi
'tee'应该可以正常工作,请张贴非工作管道 –
右,两个部分的对自己的正常工作。我不能做的是让他们一起工作。上面添加了非工作示例(我最好的镜头)。出于好奇, –
为什么你不使用v4l2src而不是捕获工具? – ensonic