ffmpeg udp live stream发布到rtmp

时间:2015-02-20 12:05:35

标签: nginx ffmpeg udp rtmp mpeg2-ts

我需要制作这个链: JVC HM650 - UDP - > localhost - > ffmpeg(复制流) - > nginx-rtmp

在输入时我有来自摄像头的UDP流(udp:// @:35501),我需要它发布到rtmp服务器(带有rtmp模块的nginx)。除了一切都有效 - 我可以在VLC上播放输入,我可以从FMLE流到nginx等。除此之外,这是我第一次使用ffmpeg并且我无法使用它。所以:

这是我最好的:

C:\ffmpeg\bin>ffmpeg -re -i udp://@:35501 -f flv "rtmp://192.168.1.17/live/live" -loglevel debug
ffmpeg version N-69972-g6c91afe Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.9.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnu
tls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-
libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-l
ibrtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --
enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --ena
ble-libxvid --enable-lzma --enable-decklink --enable-zlib
  libavutil      54. 19.100 / 54. 19.100
  libavcodec     56. 25.100 / 56. 25.100
  libavformat    56. 23.100 / 56. 23.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 11.100 /  5. 11.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Splitting the commandline.
Reading option '-re' ... matched as option 're' (read input at native frame rate) with argument '1'.
Reading option '-i' ... matched as input file with argument 'udp://@:35501'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'flv'.
Reading option 'rtmp://192.168.1.17/live/live' ... matched as output file.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input file udp://@:35501.
Applying option re (read input at native frame rate) with argument 1.
Successfully parsed a group of options.
Opening an input file: udp://@:35501.
[udp @ 0000000002c30760] end receive buffer size reported is 65536
[AVIOContext @ 0000000002c513c0] Statistics: 0 bytes read, 0 seeks
udp://@:35501: Immediate exit requested
Received signal 2: terminating.

C:\ffmpeg\bin>

ffmpeg配置有什么问题?

SOLUTION:

ffmpeg正在侦听错误版本的UDP协议:

即使在系统内部的网卡上禁用了IPv6,也可以使用@允许 ffmpeg 侦听UDPv6。

使用127.0.0.1告诉 ffmpeg 使用干净的UDP。

谢谢,@ thomas让我有不同的想法!

1 个答案:

答案 0 :(得分:1)

看来你的ffmpeg命令是对的,它对我有用。有关这里的信息,输出结果是配置良好的udp连接:

...
Opening an input file: udp://@:35501.
[udp @ 0x2058c80] end receive buffer size reported is 131072
[flv @ 0x20631a0] Format flv probed with size=2048 and score=100
[flv @ 0x20631a0] Before avformat_find_stream_info() pos: 13 bytes read:2099 seeks:0
[flv @ 0x20631a0] max_analyze_duration 5000000 reached at 5016000 microseconds
rfps: 29.916667 0.015099
rfps: 30.000000 0.000067
    Last message repeated 1 times
rfps: 60.000000 0.000267
    Last message repeated 1 times
rfps: 120.000000 0.001067
    Last message repeated 1 times
rfps: 240.000000 0.004267
rfps: 29.970030 0.002007
rfps: 59.940060 0.008027
[flv @ 0x20631a0] After avformat_find_stream_info() pos: 12110 bytes read:12110 seeks:0 frames:154
Input #0, flv, from 'udp://@:35501':
  Metadata:
    AspectRatioX    : 1
    AspectRatioY    : 1
    metadatacreator : GStreamer FLV muxer
    creationdate    : Mon Feb 23 6:51:54 2015
  Duration: N/A, start: 0.002000, bitrate: N/A
    Stream #0:0, 154, 1/1000: Video: h264 (High), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 1/60, 30.30 fps, 30 tbr, 1k tbn, 60 tbc
Successfully opened the file.
Parsing a group of options: output file rtmp://192.168.0.20/live/live.
Applying option f (force format) with argument flv.
Successfully parsed a group of options.
Opening an output file: rtmp://192.168.0.20/live/live.
...

这意味着您的传入流配置不正确。您确定您的相机正在流式传输到正确的协议(udp),地址(ffmpeg主机的IP)和端口(35501)吗? 也许如果你没有,我在这里找到你的相机手册:http://pro.jvc.com/pro/attributes/CAMERA/manual/GY-HM650U_V2.pdf(直播第166页)

我希望它会有所帮助!