【问题标题】:Why rtp streaming of a .avi video file fails to be received?为什么无法接收 .avi 视频文件的 rtp 流?
【发布时间】:2013-03-20 17:30:21
【问题描述】:

ffmpeg streamingGuide 中,它写道:

ffmpeg -re -f lavfi -i aevalsrc="sin(400*2*PI*t)" -ar 8000 -f mulaw -f rtp rtp://127.0.0.1:1234 &
ffplay rtp://127.0.0.1:1234

我想用真实的视频文件来代替人工信号。 然后我在终端A写下:

ffmpeg -re -i outputFile.avi -f mulaw -f rtp rtp://127.0.0.1:1234

它似乎正在工作: 帧信息正在计数。下面是最后A航站楼的信息:

frame=  309 fps= 29 q=31.0 Lsize=     931kB time=00:00:10.30 bitrate= 740.8kbits/s     video:922kB audio:0kB subtitle:0 global headers:0kB muxing overhead 1.030813%

当终端 A 的帧仍在计数(未完成)时,我在终端 B 键入以下内容:

ffplay rtp://127.0.0.1:1234

但它不起作用: 错误信息是:

[udp @ 0x7fb370001500] bind failed: Address already in useB f=0/0   
rtp://127.0.0.1:1234: Input/output error

为什么?

[更新 1] 按照 Camille Goudeseune 的指示 我使用了 foo.sdp
ffmpeg 终端的输入是:

ffmpeg -re -i out.avi -f mulaw -f rtp rtp://127.0.0.1:1235

ffplay的终端是:

ffplay -i foo.sdp

ffplay终端显示很多错误,没有图片。

  libpostproc    52.  2.100 / 52.  2.100
[sdp @ 0x7fafdc0008c0] Undefined type (30)    0KB sq=    0B f=0/0   
[sdp @ 0x7fafdc0008c0] nal size exceeds length: 25453 86 0B f=0/0   
[sdp @ 0x7fafdc0008c0] Consumed more bytes than we got! (-25367)
[sdp @ 0x7fafdc0008c0] nal size exceeds length: 25453 86
[sdp @ 0x7fafdc0008c0] Consumed more bytes than we got! (-25367)
[sdp @ 0x7fafdc0008c0] Unhandled type (27) (See RFC for implementation details
[sdp @ 0x7fafdc0008c0] Undefined type (31)    0KB sq=    0B f=0/0   
[sdp @ 0x7fafdc0008c0] Unhandled type (27) (See RFC for implementation details
[sdp @ 0x7fafdc0008c0] nal size exceeds length: 62414 6130B f=0/0   
[sdp @ 0x7fafdc0008c0] Consumed more bytes than we got! (-61801)
[sdp @ 0x7fafdc0008c0] nal size exceeds length: 62414 613
[sdp @ 0x7fafdc0008c0] Consumed more bytes than we got! (-61801)
[h264 @ 0x7fafdc003020] non-existing PPS referencedq=    0B f=0/0   
[h264 @ 0x7fafdc003020] non-existing PPS 0 referenced
[h264 @ 0x7fafdc003020] decode_slice_header error
[h264 @ 0x7fafdc003020] Invalid mix of idr and non-idr slices
[sdp @ 0x7fafdc0008c0] Undefined type (31)    0KB sq=    0B f=0/0   
[sdp @ 0x7fafdc0008c0] Unhandled type (29) (See RFC for implementation details
[sdp @ 0x7fafdc0008c0] Unhandled type (26) (See RFC for implementation details
[sdp @ 0x7fafdc0008c0] Unhandled type (27) (See RFC for implementation details
    Last message repeated 2 times  0KB vq=    0KB sq=    0B f=0/0   
[sdp @ 0x7fafdc0008c0] Undefined type (31)
[sdp @ 0x7fafdc0008c0] Unhandled type (26) (See RFC for implementation details
[sdp @ 0x7fafdc0008c0] Unhandled type (25) (See RFC for implementation details
[h264 @ 0x7fafdc003020] insane cropping not completely supported, this could look slightly wrong ... (left: 2, top: 2)
[h264 @ 0x7fafdc003020] illegal aspect ratio
[h264 @ 0x7fafdc003020] missing picture in access unit with size 84589
[h264 @ 0x7fafdc003020] Partitioned H.264 support is incomplete
[h264 @ 0x7fafdc003020] insane cropping not completely supported, this could look slightly wrong ... (left: 2, top: 2)
[h264 @ 0x7fafdc003020] illegal aspect ratio
[h264 @ 0x7fafdc003020] insane cropping not completely supported, this could look slightly wrong ... (left: 2, top: 2)
[h264 @ 0x7fafdc003020] illegal aspect ratio
[h264 @ 0x7fafdc003020] no frame!
[h264 @ 0x7fafdc003020] RTP: missed 2563 packetsB sq=    0B f=0/0   
[sdp @ 0x7fafdc0008c0] Undefined type (30)
    Last message repeated 1 times
[sdp @ 0x7fafdc0008c0] Undefined type (31)

【问题讨论】:

    标签: ffmpeg video-streaming rtp


    【解决方案1】:

    ffplay rtp://127.0.0.1:1234 将开始在 UDP 端口 1234 上侦听传入的 RTP 流量。

    在任何给定时间,只有一个应用程序可以监听主机上的任何给定端口。

    错误“绑定失败:地址已在使用”表明另一个应用程序已经在侦听端口 1234。 可能您仍在运行测试中的脚本?

    要么停止阻塞端口的应用程序,要么使用其他端口。

    【讨论】:

    • 嗯,如果 SO_REUSEADDRSO_REUSEPORT 设置为 true,则完全可以将两个不同的进程绑定到相同的 IP 地址和 TCP 端口。
    • 是的,但它很可能不会做你想做的事。当使用SO_REUSEPORT 时,收到的包不会出现在所有个监听器中,而只会出现在一个(哪个由操作系统决定,例如使用循环算法)。这对于构建负载平衡器来说很酷,但对于其他一些事情(我想不出任何)
    【解决方案2】:

    ffplay -i foo.sdp代替ffplay rtp://127.0.0.1:1235

    创建本地文件foo.sdp,将ffmpeg的文本输出粘贴到SDP:行之后,例如:

    v=0
    o=- 0 0 IN IP4 127.0.0.1
    s=No Name
    c=IN IP4 127.0.0.1
    t=0 0
    a=tool:libavformat 55.2.100
    m=video 1235 RTP/AVP 96
    a=rtpmap:96 H264/90000
    a=fmtp:96 packetization-mode=1
    

    .sdp 文件包含 rtp 地址,因此您也无需指定 rtp://...。

    【讨论】:

    • 我用的是 foo.sdp ffmpeg 终端的输入是: ffmpeg -re -i out.avi -f mulaw -f rtp rtp://127.0.0.1:1235 ffplay 的终端是: ffplay -i foo.sdp ffplay终端显示很多错误,没有图片。
    • [sdp @ 00000000003759c0] 找不到流 0 的编解码器参数(视频:h2 64,无):未指定大小考虑增加“分析时间”和“探测大小”选项的值 C:\rtp .sdp: 找不到编解码器参数 nan : 0.000 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0
    • 我有一些Protocol not on whitelist 'file'!,所以我添加了-protocol_whitelist file,udp,rtp
    猜你喜欢
    • 2012-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多