ffmpeg無法接收組播流問題處理

振宇要低調發表於2015-10-14

  問題:ffmpeg無法對IP組播進行處理,表現如下

[root@os01 /]# ffprobe udp://225.0.0.2:9000
ffprobe version 2.7.1 Copyright (c) 2007-2015 the FFmpeg developers
  built with gcc 4.8.3 (GCC) 20140911 (Red Hat 4.8.3-9)
  configuration: --enable-gpl --enable-nonfree --enable-static --enable-pthreads
  libavutil      54. 27.100 / 54. 27.100
  libavcodec     56. 41.100 / 56. 41.100
  libavformat    56. 36.100 / 56. 36.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.101 /  5. 16.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
  libpostproc    53.  3.100 / 53.  3.100
(一直卡在這裡)

  

  而通過tcpdump抓包,是可以抓到組播流的

[root@os01 /]# tcpdump -ieno1 host 225.0.0.2 and port 9000
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eno1, link-type EN10MB (Ethernet), capture size 65535 bytes
09:03:35.745690 IP bogon.37266 > 225.0.0.2.cslistener: UDP, length 1316
09:03:35.759688 IP bogon.37266 > 225.0.0.2.cslistener: UDP, length 1316
09:03:35.763224 IP bogon.37266 > 225.0.0.2.cslistener: UDP, length 1316
09:03:35.766720 IP bogon.37266 > 225.0.0.2.cslistener: UDP, length 1316
09:03:35.770256 IP bogon.37266 > 225.0.0.2.cslistener: UDP, length 1316
09:03:35.773768 IP bogon.37266 > 225.0.0.2.cslistener: UDP, length 1316

 

  檢視route表如下

[root@os01 logs]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         bogon           0.0.0.0         UG    100    0        0 eno4
link-local      0.0.0.0         255.255.0.0     U     1003   0        0 eno2
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
172.28.1.0      0.0.0.0         255.255.255.0   U     100    0        0 eno3
172.28.33.0     0.0.0.0         255.255.255.0   U     100    0        0 eno1
172.28.34.0     0.0.0.0         255.255.255.0   U     0      0        0 eno2
192.168.0.0     0.0.0.0         255.255.255.0   U     100    0        0 eno4
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0

 

  故,分析得出,上述問題是由route表中未配置組播地址導致,解決辦法如下

[root@os01 logs]# route add -net 225.0.0.0 netmask 255.0.0.0 dev eno1
[root@os01 logs]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         bogon           0.0.0.0         UG    100    0        0 eno4
link-local      0.0.0.0         255.255.0.0     U     1003   0        0 eno2
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
172.28.1.0      0.0.0.0         255.255.255.0   U     100    0        0 eno3
172.28.33.0     0.0.0.0         255.255.255.0   U     100    0        0 eno1
172.28.34.0     0.0.0.0         255.255.255.0   U     0      0        0 eno2
192.168.0.0     0.0.0.0         255.255.255.0   U     100    0        0 eno4
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
225.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 eno1

 

  再次驗證ffmpeg:

[root@os01 logs]# ffprobe udp://225.0.0.2:9000
ffprobe version 2.7.1 Copyright (c) 2007-2015 the FFmpeg developers
  built with gcc 4.8.3 (GCC) 20140911 (Red Hat 4.8.3-9)
  configuration: --enable-gpl --enable-nonfree --enable-static --enable-pthreads
  libavutil      54. 27.100 / 54. 27.100
  libavcodec     56. 41.100 / 56. 41.100
  libavformat    56. 36.100 / 56. 36.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.101 /  5. 16.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
  libpostproc    53.  3.100 / 53.  3.100
[h264 @ 0x2ed1160] non-existing PPS 0 referenced
    Last message repeated 1 times
[h264 @ 0x2ed1160] decode_slice_header error
[h264 @ 0x2ed1160] no frame!
[h264 @ 0x2ed1160] non-existing PPS 0 referenced
    Last message repeated 1 times
[h264 @ 0x2ed1160] decode_slice_header error
[h264 @ 0x2ed1160] no frame!
[h264 @ 0x2ed1160] non-existing PPS 0 referenced
    Last message repeated 1 times

 

相關文章