【问题标题】:RTP streaming with FFmpeg audio and video out of syncFFmpeg 音频和视频不同步的 RTP 流式传输
【发布时间】:2017-08-25 16:07:07
【问题描述】:

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

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 吗?

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

【问题讨论】:

    标签: ffmpeg video-streaming rtp


    【解决方案1】:

    不确定 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”标志来解决同步问题。

    【讨论】:

    • 哇,非常感谢,成功了!我已经阅读了 DirectShow 页面并尝试了所有其他建议,但我从未意识到可以将其作为一个输入读取并流式传输到两个输出。
    猜你喜欢
    • 2012-04-10
    • 2015-04-27
    • 2012-03-16
    • 2016-05-26
    • 2018-03-01
    • 2012-11-06
    • 2020-01-03
    • 1970-01-01
    • 2016-05-25
    相关资源
    最近更新 更多