我在使用gstreamer方面是个新手。我想要将我的C920网络摄像头的视频和音频流式传输到另一台电脑,但我一直没有正确地进行组合。
使用以下命令,我现在可以从我的C920摄像头向另一台PC流式传输h264视频:
gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-h264,width=1280,height=720,framerate=30/1 ! h264parse ! rtph264pay pt=127 config-interval=4 ! udpsink host=172.19.3.103
并使用以下方式查看:
gst-launch-1.0 udpsrc port=1234 ! application/x-rtp, payload=127 ! rtph264depay ! avdec_h264 ! xvimagesink sync=false
我也可以从C920中获取音频,并与测试图像一起记录到文件中:
gst-launch videotestsrc ! videorate ! video/x-raw-yuv,framerate=5/1 ! queue ! theoraenc ! queue ! mux. pulsesrc device="alsa_input.usb-046d_HD_Pro_Webcam_C920_F1894590-02-C920.analog-stereo" ! audio/x-raw-int,rate=48000,channels=2,depth=16 ! queue ! audioconvert ! queue ! vorbisenc ! queue ! mux. oggmux name=mux ! filesink location=stream.ogv
但我试图让类似于下面的代码正常工作。这个不起作用,可能是我做的非常糟糕的组合!
gst-launch v4l2src device=/dev/video1 ! video/x-h264,width=1280,height=720,framerate=30/1 ! queue ! mux. pulsesrc device="alsa_input.usb-046d_HD_Pro_Webcam_C920_F1894590-02-C920.analog-stereo" ! audio/x-raw-int,rate=48000,channels=2,depth=16 ! queue ! audioconvert ! queue ! x264enc ! queue ! udpsink host=127.0.0.1 port=1234
gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-h264,width=1280,height=720,framerate=30/1 ! h264parse ! muxout. pulsesrc device="alsa_input.pci-0000_00_1b.0.analog-stereo" ! queue ! audioconvert ! voaacenc bitrate=65536 ! aacparse ! muxout. mpegtsmux name=muxout ! queue ! tcpserversink host=192.168.2.13 port=5000'
我的意思是,它确实将视频和音频混合,并通过网络播放。但是几个小时后,音频会消失,直到我重新启动(我猜是内存问题?)。 - skipxh264parse
之间加入一个x264enc
,这样你才能真正地进行编码。你需要重新启动流媒体服务器或接收器吗?这可能是一个内存问题。你应该允许它丢包或者在接收器的 sink 上设置一个延迟max-lateness
,以忽略那些太晚到达的数据包,而不是不断增加缓冲区。 - Benjamin Trenth264parse
放在video/x-h264,width=1280,height=720,framerate=30/1 ! x264enc ! h264parse
这样吗? 因为如果我这样做,会出现“无法将v4l2src0链接到x264enc0”的错误。 至于重启电脑的问题,我现在使用cvlc tcp://172.19.3.106:5000'
作为客户端。 - skipxsync
或async
,但如果有,请尝试将这些属性都设置为false
。 VLC应该可以正常工作,但可能存在一些编解码器不兼容的问题。 - Benjamin Trent