ffmpeg通过组播udp推ts流

  本地E盘有文件roundDeskS02E01.mp4,通过udp推ts流到组播地址如下:

E:\BaiduNetdiskDownload>ffmpeg -i roundDeskS02E01.mp4 -f mpegts udp://224.0.0.1:9922
ffmpeg version git-2020-03-06-cfd9a65 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20200122
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 42.100 / 56. 42.100
  libavcodec     58. 73.102 / 58. 73.102
  libavformat    58. 39.101 / 58. 39.101
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 77.100 /  7. 77.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'roundDeskS02E01.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.20.100
  Duration: 00:39:54.27, start: 0.000000, bitrate: 815 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1080x606, 744 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 64 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> mpeg2video (native))
  Stream #0:1 -> #0:1 (aac (native) -> mp2 (native))
Press [q] to stop, [?] for help
Output #0, mpegts, to 'udp://224.0.0.1:9922':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.39.101
    Stream #0:0(und): Video: mpeg2video (Main), yuv420p, 1080x606, q=2-31, 200 kb/s, 25 fps, 90k tbn, 25 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc58.73.102 mpeg2video
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
    Stream #0:1(und): Audio: mp2, 44100 Hz, stereo, s16, 384 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      encoder         : Lavc58.73.102 mp2
frame=59853 fps=226 q=31.0 Lsize=  314948kB time=00:39:54.25 bitrate=1077.6kbits/s speed=9.03x
video:178174kB audio:112232kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 8.451020%

 

  也可以把本地流换成网络上的rtmp流:

E:\BaiduNetdiskDownload>ffmpeg -i rtmp://58.200.131.2:1935/livetv/hunantv -f mpegts udp://224.0.0.1:9922
ffmpeg version git-2020-03-06-cfd9a65 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20200122
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 42.100 / 56. 42.100
  libavcodec     58. 73.102 / 58. 73.102
  libavformat    58. 39.101 / 58. 39.101
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 77.100 /  7. 77.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, flv, from 'rtmp://58.200.131.2:1935/livetv/hunantv':
  Metadata:
    Server          : NGINX RTMP (github.com/arut/nginx-rtmp-module)
    displayWidth    : 1024
    displayHeight   : 576
    fps             : 25
    profile         :
    level           :
  Duration: 00:00:00.00, start: 550870.323000, bitrate: N/A
    Stream #0:0: Data: none
    Stream #0:1: Video: h264 (Main), yuv420p(progressive), 1024x576 [SAR 1:1 DAR 16:9], 1999 kb/s, 25 fps, 25 tbr, 1k tbn, 50 tbc
    Stream #0:2: Audio: aac (LC), 48000 Hz, stereo, fltp, 139 kb/s
Stream mapping:
  Stream #0:1 -> #0:0 (h264 (native) -> mpeg2video (native))
  Stream #0:2 -> #0:1 (aac (native) -> mp2 (native))
Press [q] to stop, [?] for help
Output #0, mpegts, to 'udp://224.0.0.1:9922':
  Metadata:
    Server          : NGINX RTMP (github.com/arut/nginx-rtmp-module)
    displayWidth    : 1024
    displayHeight   : 576
    fps             : 25
    profile         :
    level           :
    encoder         : Lavf58.39.101
    Stream #0:0: Video: mpeg2video (Main), yuv420p, 1024x576 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 25 fps, 90k tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.73.102 mpeg2video
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
    Stream #0:1: Audio: mp2, 48000 Hz, stereo, s16, 384 kb/s
    Metadata:
      encoder         : Lavc58.73.102 mp2
frame= 1007 fps= 25 q=31.0 size=    5361kB time=00:00:40.40 bitrate=1086.9kbits/s speed=1.01x

 

  本地文件很快就会推完,如果想要循环推流的话,需要加参数 -stream_loop:

E:\BaiduNetdiskDownload>ffmpeg -stream_loop -1 -i roundDeskS02E01.mp4 -f mpegts udp://224.0.0.1:9922
ffmpeg version git-2020-03-06-cfd9a65 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20200122
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 42.100 / 56. 42.100
  libavcodec     58. 73.102 / 58. 73.102
  libavformat    58. 39.101 / 58. 39.101
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 77.100 /  7. 77.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'roundDeskS02E01.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.20.100
  Duration: 00:39:54.27, start: 0.000000, bitrate: 815 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1080x606, 744 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 64 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> mpeg2video (native))
  Stream #0:1 -> #0:1 (aac (native) -> mp2 (native))
Press [q] to stop, [?] for help
Output #0, mpegts, to 'udp://224.0.0.1:9922':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.39.101
    Stream #0:0(und): Video: mpeg2video (Main), yuv420p, 1080x606, q=2-31, 200 kb/s, 25 fps, 90k tbn, 25 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc58.73.102 mpeg2video
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
    Stream #0:1(und): Audio: mp2, 44100 Hz, stereo, s16, 384 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      encoder         : Lavc58.73.102 mp2
frame= 2895 fps=378 q=24.8 size=   18024kB time=00:01:55.97 bitrate=1273.2kbits/s speed=15.1x

 

  网络上的流推到224.0.0.1没有问题,本地文件可能会报错,改用127.0.0.1的地址即可。  

posted on 2020-07-21 10:43  不想下火车的人  阅读(3579)  评论(0编辑  收藏  举报

导航