使用 FFmpeg 和 ffplay 推拉流

推流

➜  Downloads ffmpeg -re -i Big\ Buck\ Bunny-YE7VzlLtp-4.mp4 -vcodec copy -f flv rtmp://uplive.v0.v5linux.com/live/lol
  ffmpeg version 3.2-tessus Copyright (c) 2000-2016 the FFmpeg developers
    built with Apple LLVM version 8.0.0 (clang-800.0.38)
    configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzmq --enable-version3 --disable-ffplay --disable-indev=qtkit --disable-indev=x11grab_xcb
  libavutil      55. 34.100 / 55. 34.100
  libavcodec     57. 64.100 / 57. 64.100
  libavformat    57. 56.100 / 57. 56.100
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Big Buck Bunny-YE7VzlLtp-4.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.56.100
  Duration: 00:09:56.57, start: 0.000000, bitrate: 1443 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1312 kb/s, 24 fps, 24 tbr, 90k tbn, 48 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Output #0, flv, to 'rtmp://test.v0.v5linux.com/live/lol':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.56.100
    Stream #0:0(und): Video: h264 (Main) ([7][0][0][0] / 0x0007), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 1312 kb/s, 24 fps, 24 tbr, 1k tbn, 90k tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: mp3 (libmp3lame) ([2][0][0][0] / 0x0002), 44100 Hz, stereo, fltp (default)
    Metadata:
      handler_name    : SoundHandler
      encoder         : Lavc57.64.100 libmp3lame
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (aac (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
frame=  502 fps= 24 q=-1.0 Lsize=    4094kB time=00:00:20.87 bitrate=1606.7kbits/s speed=   1x

拉流

➜  ~ ffplay rtmp://uplive.b0.v5linux.com/live/lol
ffplay version 3.2-tessus Copyright (c) 2003-2016 the FFmpeg developers
  built with Apple LLVM version 8.0.0 (clang-800.0.38)
  configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzmq --enable-version3 --enable-librtmp --enable-ffplay --enable-sdl2 --disable-ffmpeg --disable-ffprobe --disable-ffserver --disable-indev=qtkit --disable-indev=x11grab_xcb
  libavutil      55. 34.100 / 55. 34.100
  libavcodec     57. 64.100 / 57. 64.100
  libavformat    57. 56.100 / 57. 56.100
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
Metadata:  :  0.000 fd=   0 aq=    0KB vq=    0KB sq=    0B f=0/0
  width                 1280.00
  height                720.00
  videodatarate         1282.04
  framerate             24.00
  videocodecid          7.00
  audiodatarate         0.00
  audiosamplerate       44100.00
  audiosamplesize       16.00
  stereo                TRUE
  audiocodecid          2.00
  major_brand           isom
  minor_version         512
  compatible_brands     isomiso2avc1mp41
  encoder               Lavf57.56.100
  server                UPYUN/4.0.169(BMS)
  srs_primary           UPYUN/4.0release
  srs_authors           Chnvideo
  server_version        4.0.169
  srs_pid               1120781.00
  srs_id                429208.00
  srs_server_ip         183.158.35.6
[flv @ 0x7f852207de00] audio stream discovered after head already parsed
[flv @ 0x7f852207de00] video stream discovered after head already parsed
Input #0, flv, from 'rtmp://test.b0.v5linux.com/live/lol':B f=0/0
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.56.100
    server          : UPYUN/4.0.169(BMS)
    srs_primary     : UPYUN/4.0release
    srs_authors     : Chnvideo
    server_version  : 4.0.169
    srs_pid         : 1120781
    srs_id          : 429208
    srs_server_ip   : 183.158.35.6
  Duration: N/A, start: 0.014000, bitrate: N/A
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 128 kb/s
    Stream #0:1: Video: h264 (Main), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 24.42 fps, 24 tbr, 1k tbn, 48 tbc
阿文 wechat
欢迎您扫一扫上面的微信公众号,订阅我的博客!
坚持原创技术分享,您的支持将鼓励我继续创作!