2013-03-29 73 views
5

ffmpeg streamingGuide,它寫道:爲什麼無法接收.avi視頻文件的rtp流媒體?

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]在從卡米爾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) 
+0

已經有幾年了,這些答案已經幫助了其他人。如果其中一個答案也適用於您,請接受它。 –

+0

尊敬的user1914692,您爲什麼不接受答案?其中一個答案甚至贏得了「好回答」徽章。你有足夠的活動和徽章來了解SO的工作原理。 –

回答

14

而不是ffplay rtp://127.0.0.1:1235,請使用ffplay -i foo.sdp

通過粘貼到它從下面的線SDP: ffmpeg的輸出的文本創建本地文件foo.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: // ...以及。

+1

我使用了foo.sdp ffmpeg終端的輸入是:ffmpeg -re -i out.avi -f mulaw -f rtp rtp://127.0.0.1:1235 ffplay的終端是:ffplay -i foo.sdp ffplay終端顯示很多錯誤,沒有圖像。 – user1914692

+0

[sdp @ 00000000003759c0]無法找到流0的編解碼參數(視頻:h2 64,無):未指定的大小 考慮增加「分析」和「探測大小」選項的值 C:\ rtp.sdp:可能沒有找到編解碼器參數 nan:0.000 fd = 0 aq = 0KB vq = 0KB sq = 0B f = 0/0 –

+1

lmgtfy:http://stackoverflow.com/a/11659459/2097284 –

3

ffplay rtp://127.0.0.1:1234將開始監聽UDP端口1234入局RTP流量。

只有一個應用程序可以在任何給定時間監聽主機上的任何給定端口。

錯誤「綁定失敗:地址已在使用中」表示另一應用程序正在偵聽端口1234。 可能你還在運行測試腳本?

要麼停止阻塞端口的應用程序,要麼使用不同的端口。

+0

嗯,如果'SO_REUSEADDR'和/或'SO_REUSEPORT'設置爲true,完全可以將兩個不同的進程綁定到相同的IP地址和TCP端口。 – Fraser

+1

是的,但它很可能不會做你想做的事情。當使用'SO_REUSEPORT'時,收到的包將不會*出現在* all *聽衆處,但僅在一個位置(哪一個由操作系統決定,例如使用循環算法)。這對構建一個負載均衡器很酷,但對於其他一些事情(我想不出任何) –