GSTreamer 通过 RTP 进行音频/视频同步

问题描述 投票:0回答:1

我正在尝试从一台 PC 录制麦克风并将其通过 RTP 发送到本地网络上的笔记本电脑,并从另一台 PC 录制视频并将其发送到同一台笔记本电脑,同样通过 RTP。这部分相当简单,我有:

发送视频:

gst-launch-1.0 -v v4l2src ! videoconvert ! x264enc ! rtph264pay ! udpsink host=192.168.0.14 port=5000

发送音频:

gst-launch-1.0 -v alsasrc ! audioconvert ! audioresample ! audio/x-raw,channels=1 ! audioresample ! audio/x-raw,rate=48000 ! rtpL24pay ! udpsink host=192.168.0.14 port=5001

笔记本电脑上的接收器是我苦苦挣扎的地方。我想要的是获取音频和视频流,同步它们并生成输出 mp4(或任何其他格式)视频文件。我现在有的是:

gst-launch-1.0 -e -v udpsrc port=5000 caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264" ! rtpjitterbuffer drop-on-latency=true latency=200 ! rtph264depay ! h264parse ! queue ! mux. udpsrc port=5001 caps="application/x-rtp, media=(string)audio, clock-rate=(int)48000, encoding-name=(string)L24" ! rtpjitterbuffer  drop-on-latency=true latency=200 ! rtpL24depay ! audioconvert ! audioresample ! lamemp3enc ! queue ! mux. mp4mux name=mux ! filesink location=output.mp4

这会产生单个输出文件,但视频和音频不同步。我读到我需要使用相同的 rtpjitterbuffer 元素,但是当我尝试提供 rtpjitterbuffer 名称并再次使用它时,我要么得到 jitter0 元素不存在,要么我无法连接它。

gst-launch-1.0 -e -v udpsrc port=5000 caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264" ! rtpjitterbuffer name=jitter0 drop-on-latency=true latency=40 ! rtph264depay ! h264parse ! queue ! mux. udpsrc port=5001 caps="application/x-rtp, media=(string)audio, clock-rate=(int)48000, encoding-name=(string)L24" ! rtpjitterbuffer name=jitter0 ! rtpL24depay ! audioconvert ! audioresample ! lamemp3enc ! queue ! mux. mp4mux name=mux ! filesink location=output.mp4

你能帮我解决这个问题吗?

我尝试使用相同的 rtpjitter 元素,但我不知道该怎么做,我也不知道这是否可行。

synchronization gstreamer rtp alsa v4l2
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.