我正在尝试通过 WAN 传输多播流。
我知道 NAT 不允许这样做。为此,我尝试使用一台带有两个以太网接口的 Raspberry:一个是内部接口,另一个是通过 USB 端口连接的。WANeth0
端口和eth1
LAN 端口也是如此。
我在 Raspberry Pi 上使用 FFMPEG,命令如下:
sudo ffmpeg -i http://192.168.0.61:8001/test -c copy -f mpegts "udp://224.0.0.1:1234?ttl=13"
输出如下:
ffmpeg version 3.2.16-1+deb9u1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 6.3.0 (Raspbian 6.3.0-18+rpi1+deb9u1) 20170516
configuration: --prefix=/usr --extra-version=1+deb9u1 --toolchain=hardened --libdir=/usr/lib/arm-linux-gnueabihf --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 34.101 / 55. 34.101
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.101 / 57. 56.101
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
[h264 @ 0x141dd90] SPS unavailable in decode_picture_timing
[h264 @ 0x141dd90] non-existing PPS 0 referenced
[h264 @ 0x141dd90] SPS unavailable in decode_picture_timing
[h264 @ 0x141dd90] non-existing PPS 0 referenced
[h264 @ 0x141dd90] decode_slice_header error
[h264 @ 0x141dd90] no frame!
[h264 @ 0x141dd90] SPS unavailable in decode_picture_timing
[h264 @ 0x141dd90] non-existing PPS 0 referenced
[h264 @ 0x141dd90] SPS unavailable in decode_picture_timing
[h264 @ 0x141dd90] non-existing PPS 0 referenced
[h264 @ 0x141dd90] decode_slice_header error
[h264 @ 0x141dd90] no frame!
[h264 @ 0x141dd90] SPS unavailable in decode_picture_timing
[h264 @ 0x141dd90] non-existing PPS 0 referenced
[h264 @ 0x141dd90] SPS unavailable in decode_picture_timing
[h264 @ 0x141dd90] non-existing PPS 0 referenced
[h264 @ 0x141dd90] decode_slice_header error
[h264 @ 0x141dd90] no frame!
[h264 @ 0x141dd90] SPS unavailable in decode_picture_timing
[h264 @ 0x141dd90] non-existing PPS 0 referenced
[h264 @ 0x141dd90] SPS unavailable in decode_picture_timing
[h264 @ 0x141dd90] non-existing PPS 0 referenced
[h264 @ 0x141dd90] decode_slice_header error
[h264 @ 0x141dd90] no frame!
[h264 @ 0x141dd90] SPS unavailable in decode_picture_timing
[h264 @ 0x141dd90] non-existing PPS 0 referenced
[h264 @ 0x141dd90] SPS unavailable in decode_picture_timing
[h264 @ 0x141dd90] non-existing PPS 0 referenced
[h264 @ 0x141dd90] decode_slice_header error
[h264 @ 0x141dd90] no frame!
[h264 @ 0x141dd90] SPS unavailable in decode_picture_timing
[h264 @ 0x141dd90] non-existing PPS 0 referenced
[h264 @ 0x141dd90] SPS unavailable in decode_picture_timing
[h264 @ 0x141dd90] non-existing PPS 0 referenced
[h264 @ 0x141dd90] decode_slice_header error
[h264 @ 0x141dd90] no frame!
[h264 @ 0x141dd90] SPS unavailable in decode_picture_timing
[h264 @ 0x141dd90] non-existing PPS 0 referenced
[h264 @ 0x141dd90] SPS unavailable in decode_picture_timing
[h264 @ 0x141dd90] non-existing PPS 0 referenced
[h264 @ 0x141dd90] decode_slice_header error
[h264 @ 0x141dd90] no frame!
[h264 @ 0x141dd90] SPS unavailable in decode_picture_timing
[h264 @ 0x141dd90] non-existing PPS 0 referenced
[h264 @ 0x141dd90] SPS unavailable in decode_picture_timing
[h264 @ 0x141dd90] non-existing PPS 0 referenced
[h264 @ 0x141dd90] decode_slice_header error
[h264 @ 0x141dd90] no frame!
[h264 @ 0x141dd90] SPS unavailable in decode_picture_timing
[h264 @ 0x141dd90] non-existing PPS 0 referenced
[h264 @ 0x141dd90] SPS unavailable in decode_picture_timing
[h264 @ 0x141dd90] non-existing PPS 0 referenced
[h264 @ 0x141dd90] decode_slice_header error
[h264 @ 0x141dd90] no frame!
[h264 @ 0x141dd90] SPS unavailable in decode_picture_timing
[h264 @ 0x141dd90] non-existing PPS 0 referenced
[h264 @ 0x141dd90] SPS unavailable in decode_picture_timing
[h264 @ 0x141dd90] non-existing PPS 0 referenced
[h264 @ 0x141dd90] decode_slice_header error
[h264 @ 0x141dd90] no frame!
[mp3 @ 0x1420c10] Header missing
[mp3 @ 0x1438950] Header missing
[mp3 @ 0x14394e0] Header missing
[mpegts @ 0x141a570] Could not find codec parameters for stream 6 (Unknown: none ([5][0][0][0] / 0x0005)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 0x141a570] Could not find codec parameters for stream 7 (Unknown: none ([11][0][0][0] / 0x000B)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 0x141a570] Could not find codec parameters for stream 8 (Unknown: none ([12][0][0][0] / 0x000C)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, mpegts, from 'http://192.168.0.61:8001/1:0:19:547:A3:217C:EEEE0000:0:0:0:':
Duration: N/A, start: 100956.016789, bitrate: N/A
Program 1351
Stream #0:0[0xc9]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, top first), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 50 tbr, 90k tbn, 50 tbc
Stream #0:1[0x12c](ita): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 192 kb/s
Stream #0:2[0x12d](oth): Audio: ac3 ([6][0][0][0] / 0x0006), 48000 Hz, stereo, fltp, 384 kb/s
Stream #0:3[0x191](oth): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, mono, s16p, 64 kb/s
Stream #0:4[0x1f5](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 128 kb/s
Stream #0:5[0x259](ita,ita,eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006), 492x250
Stream #0:6[0x7d2]: Unknown: none ([5][0][0][0] / 0x0005)
Stream #0:7[0xbba]: Unknown: none ([11][0][0][0] / 0x000B)
Stream #0:8[0xc1d]: Unknown: none ([12][0][0][0] / 0x000C)
Program 1352
Program 1353
Program 1360
Program 1361
Program 1362
Program 1363
Program 1364
Program 1365
Program 1366
Program 1368
Output #0, mpegts, to 'udp://224.0.0.1:1234?ttl=13':
Metadata:
encoder : Lavf57.56.101
Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, top first), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 50 tbr, 90k tbn, 90k tbc
Stream #0:1(ita): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, 192 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 295 fps=0.0 q=-1.0 Lsize= 4840kB time=00:00:07.96 bitrate=4978.4kbits/s speed=11.8x
video:4285kB audio:175kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 8.534529%
我使用以下命令进行检查:
sudo tcpdump -i eth0 dst port 1234
15:20:14.227868 IP 192.168.1.251.42236 > all-systems.mcast.net.1234: UDP, length 1472
15:20:14.227977 IP 192.168.1.251.42236 > all-systems.mcast.net.1234: UDP, length 1472
15:20:14.228077 IP 192.168.1.251.42236 > all-systems.mcast.net.1234: UDP, length 1472
15:20:14.228174 IP 192.168.1.251.42236 > all-systems.mcast.net.1234: UDP, length 1472
15:20:14.228281 IP 192.168.1.251.42236 > all-systems.mcast.net.1234: UDP, length 1472
15:20:14.228372 IP 192.168.1.251.42236 > all-systems.mcast.net.1234: UDP, length 1472
15:20:14.228456 IP 192.168.1.251.42236 > all-systems.mcast.net.1234: UDP, length 1472
15:20:14.228538 IP 192.168.1.251.42236 > all-systems.mcast.net.1234: UDP, length 1472
15:20:14.228617 IP 192.168.1.251.42236 > all-systems.mcast.net.1234: UDP, length 1472
15:20:14.228692 IP 192.168.1.251.42236 > all-systems.mcast.net.1234: UDP, length 288
数据包实际上是通过它传输的,eth0
但是我无法使用 VLC 观看视频。
这可能是什么原因造成的?
答案1
在您的日志中我们可以看到
Input #0, mpegts, from 'http://192.168.0.61:8001/1:0:19:547:A3:217C:EEEE0000:0:0:0:':
它看起来像一个 IP 和特定的网络接口。我想你问的是你是否可以手动设置输出网络接口,你可以。我建议看看文档。
该链接将带您进入 FFmpeg 文档,并应跳至 UDP 部分。如果没有,CTRL + F
请输入interface
。这是感兴趣的主要行/命令。
localaddr=addr
Local IP address of a network interface used for sending packets or joining multicast groups.
你可以看看这个问题再举一个例子。