ffmpeg 可以使用 FLV 输出到 RTMP 源,但不能使用 WEBM

ffmpeg 可以使用 FLV 输出到 RTMP 源,但不能使用 WEBM

当我运行它时,它运行正常(使用 flv 输出):

ffmpeg -re -stream_loop -1 -i game.webm -c:v libx264 -preset veryfast -b:v 6000k -maxrate 6000k -bufsize 6000k -pix_fmt yuv420p -f flv rtmp://1.1.1.1/live

但是当我运行这个时,我收到下面列出的错误:

ffmpeg -re -stream_loop -1 -i game.webm -c:v libx264 -c:a libvorbis -preset veryfast -b:v 6000k -maxrate 6000k -bufsize 6000k -pix_fmt yuv420p -f webm rtmp://1.1.1.1/live

错误:

ffmpeg version 4.4-1ubuntu0~20.04.sav0 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
  configuration: --prefix=/usr --extra-version='1ubuntu0~20.04.sav0' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libdav1d --enable-libzimg --enable-crystalhd --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
Input #0, matroska,webm, from 'game.webm':
  Metadata:
    COMPATIBLE_BRANDS: isomiso2avc1mp41
    MAJOR_BRAND     : isom
    MINOR_VERSION   : 512
    ENCODER         : Lavf58.76.100
  Duration: 00:05:00.17, start: -0.007000, bitrate: 4980 kb/s
  Stream #0:0(eng): Video: vp9 (Profile 0), yuv420p(tv, progressive), 1920x1080, SAR 1:1 DAR 16:9, 30 fps, 30 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      HANDLER_NAME    : ?Mainconcept Video Media Handler
      VENDOR_ID       : [0][0][0][0]
      ENCODER         : Lavc58.134.100 libvpx-vp9
      DURATION        : 00:05:00.173000000
  Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
    Metadata:
      HANDLER_NAME    : #Mainconcept MP4 Sound Media Handler
      VENDOR_ID       : [0][0][0][0]
      ENCODER         : Lavc58.134.100 libopus
      DURATION        : 00:05:00.018000000
Stream mapping:
  Stream #0:0 -> #0:0 (vp9 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (opus (native) -> vorbis (libvorbis))
Press [q] to stop, [?] for help
[libx264 @ 0x55d029e621c0] using SAR=1/1
[libx264 @ 0x55d029e621c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x55d029e621c0] profile High, level 4.0, 4:2:0, 8-bit
[libx264 @ 0x55d029e621c0] 264 - core 161 r3039 544c61f - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=6 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=1 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=10 rc=cbr mbtree=1 bitrate=6000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=6000 vbv_bufsize=6000 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
[webm @ 0x55d029e60180] Only VP8 or VP9 or AV1 video and Vorbis or Opus audio and WebVTT subtitles are supported for WebM.
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 --
[libvorbis @ 0x55d029e8c0c0] 33 frames left in the queue on closing
Conversion failed!

我不明白,因为输入文件本身是 webm,所以我不确定为什么将 webm 作为 webm 进行流式传输会出现问题。我还指定了 -c:a libvorbis。

答案1

RTMP 是 Adob​​e 开发的一种消息传递协议,专门用于传输和接收 FLV 封装数据。

答案2

您无法将 H.264 视频放入 WEBM 容器中 - 它不受支持。仅支持 VP8、VP9 或 AV1 编解码器。

如果您想使用 H.264,请使用受支持的容器,例如 mp4 或 mkv。如果您想使用 WEBM,请使用受支持的视频编解码器之一。

ffmpeg -re -stream_loop -1 -i game.webm -c:v libvpc-vp9 -c:a libvorbis  -b:v 6000k -maxrate 6000k -bufsize 6000k -pix_fmt yuv420p -f webm rtmp://1.1.1.1/live

相关内容