gpt4 book ai didi

ffmpeg - FFmpeg 音频和视频不同步的 RTP 流式传输

转载 作者:行者123 更新时间:2023-12-04 23:15:14 25 4
gpt4 key购买 nike

我正在使用以下命令流式传输网络摄像头/音频:

ffmpeg.exe -f dshow -framerate 30 -i video="xxx" -c:v libx264 -an -f rtp rtp://localhost:50041 -f dshow -i audio="xxx" -c:a aac -vn -f rtp rtp://localhost:50043

这将输出以下 sdp 信息:
    v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
t=0 0
a=tool:libavformat 57.65.100
m=video 50041 RTP/AVP 96
c=IN IP6 ::1
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1
m=audio 50043 RTP/AVP 97
c=IN IP6 ::1
b=AS:128
a=rtpmap:97 MPEG4-GENERIC/44100/2
a=fmtp:97 profile-level-id=1;mode=AAC-
hbr;sizelength=13;indexlength=3;indexdeltalength=3; config=121056E500

我使用以下命令读取流:
ffmpeg.exe -protocol_whitelist file,udp,rtp -i D:\test.sdp -c:v libx264 -c:a aac d:\out.mp4

在生成的文件中,音频稍微领先于视频。我读过 RTCP 在 RTP 端口 + 1 上运行,并且包含同步信息。我在 SDP 文件中没有看到任何 RTCP 信息。

我需要指定一些东西来包括 RTCP 吗?

如果这不是问题,我还能做些什么来同步音频和视频?

最佳答案

不确定 RTCP 是否是您的问题,但我会首先尝试使用一个 directshow 输入并将其拆分为两个输出,如下所示:

ffmpeg.exe -f dshow -framerate 30 -i video="XX":audio="YY" -an -vcodec libx264 -f rtp rtp://localhost:50041 -acodec aac -vn -f rtp rtp://localhost:50043

ffmpeg DirectShow documentation提到使用多个输入时的同步问题。如果您想保持输入分开,它还提到尝试“-copy_ts”标志来解决同步问题。

关于ffmpeg - FFmpeg 音频和视频不同步的 RTP 流式传输,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45885453/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com