如何将MJPEG流传输到RTMP服务器?

时间:2018-10-24 05:21:01

标签: ffmpeg rtmp live-streaming mjpeg

我有一个MJPEG流,我正在尝试使用ffmpeg作为输入并将其以已定义的帧率传输到rtmp服务器。

我已经作为命令尝试过此操作

ffmpeg -f mjpeg -r 60 -i http://localhost:3030/ -f flv -vcodec flv rtmp://localhost/live/test

当ffmpeg看起来好像在发送东西...

ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 9.1.0 (clang-902.0.39.2)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
Input #0, mjpeg, from 'http://localhost:3030/':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1920x1080 [SAR 1:1 DAR 16:9], 60 tbr, 1200k tbn, 60 tbc
[tcp @ 0x7f95f9401ec0] Connection to tcp://localhost:1935 failed (Connection refused), trying next address
Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg (native) -> flv1 (flv))
Press [q] to stop, [?] for help
[swscaler @ 0x7f95fa033e00] deprecated pixel format used, make sure you did set range correctly
Output #0, flv, to 'rtmp://localhost/live/test':
  Metadata:
    encoder         : Lavf58.12.100
    Stream #0:0: Video: flv1 (flv) ([2][0][0][0] / 0x0002), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 60 fps, 1k tbn, 60 tbc
    Metadata:
      encoder         : Lavc58.18.100 flv
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
frame=   20 fps=3.2 q=31.0 size=     194kB time=00:00:00.31 bitrate=4999.6kbits/s speed=0.0512x

我无法通过VLC预览流。足够奇怪的是,如果我让VLC尝试加载网址(rtmp:// localhost / live / test)然后关闭ffmpeg,VLC实际上将显示视频流几帧,然后再次停止。

非常感谢您帮助实现此目标。

0 个答案:

没有答案