我的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