如何使用 FFmpeg 进行 Facebook 直播?

如何使用 FFmpeg 进行 Facebook 直播?

我在 Windows 上安装了 ffmpeg,我想将 MP4 文件流式传输到 Facebook 直播。视频带有音轨。

我正在运行以下命令:

ffmpeg 
-re -i video.mp4 
-acodec libmp3lame 
-b:a 128k 
-pix_fmt yuv420p 
-profile:v baseline 
-bufsize 6000k 
-maxrate 1500k 
-deinterlace 
-vcodec libx264 
-preset veryfast 
-g 30 
-r 30 
-f flv 
-flvflags no_duration_filesize 
"rtmps://live-api-s.facebook.com:443/rtmp/mykey"

此命令恰好运行 14 帧然后停止。

在此处输入图片描述

然后,我收到以下错误:转换失败。

在此处输入图片描述

我尝试流式传输到 AWS IVS。但我遇到了完全相同的错误。

有人知道我的命令出了什么问题吗?

    ffmpeg version N-104454-gd92fdc7144-20211101 Copyright (c) 2000-2021 the FFmpeg developers
      built with gcc 10-win32 (GCC) 20210610
      configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --enable-libvmaf --enable-vulkan --disable-libxcb --disable-xlib --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --disable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libglslang --enable-libgme --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --disable-libdrm --disable-vaapi --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-ldexeflags= --extra-libs=-lgomp --extra-version=20211101
      libavutil      57.  7.100 / 57.  7.100
      libavcodec     59. 12.100 / 59. 12.100
      libavformat    59.  8.100 / 59.  8.100
      libavdevice    59.  0.101 / 59.  0.101
      libavfilter     8. 16.100 /  8. 16.100
      libswscale      6.  1.100 /  6.  1.100
      libswresample   4.  0.100 /  4.  0.100
      libpostproc    56.  0.100 / 56.  0.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        creation_time   : 1970-01-01T00:00:00.000000Z
        encoder         : Lavf53.24.2
      Duration: 00:01:02.32, start: 0.000000, bitrate: 1347 kb/s
      Stream #0:0[0x1](und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 959 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
        Metadata:
          creation_time   : 1970-01-01T00:00:00.000000Z
          handler_name    : VideoHandler
          vendor_id       : [0][0][0][0]
      Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 383 kb/s (default)
        Metadata:
          creation_time   : 1970-01-01T00:00:00.000000Z
          handler_name    : SoundHandler
          vendor_id       : [0][0][0][0]
    Stream mapping:
      Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
      Stream #0:1 -> #0:1 (aac (native) -> aac (native))
    Press [q] to stop, [?] for help
    [libx264 @ 00000169128feb40] using SAR=1/1
    [libx264 @ 00000169128feb40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
    [libx264 @ 00000169128feb40] profile Constrained Baseline, level 3.1, 4:2:0, 8-bit
    [libx264 @ 00000169128feb40] 264 - core 164 - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 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=0 weightp=0 keyint=30 keyint_min=3 scenecut=40 intra_refresh=0 rc_lookahead=10 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=1500 vbv_bufsize=6000 crf_max=0.0 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
    Output #0, flv, to 'rtmps://live-api-s.facebook.com:443/rtmp/************************':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        encoder         : Lavf59.8.100
      Stream #0:0(und): Video: h264 ([7][0][0][0] / 0x0007), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 30 fps, 1k tbn (default)
        Metadata:
          creation_time   : 1970-01-01T00:00:00.000000Z
          handler_name    : VideoHandler
          vendor_id       : [0][0][0][0]
          encoder         : Lavc59.12.100 libx264
        Side data:
          cpb: bitrate max/min/avg: 1500000/0/0 buffer size: 6000000 vbv_delay: N/A
      Stream #0:1(und): Audio: aac (LC) ([10][0][0][0] / 0x000A), 48000 Hz, 5.1, fltp, 128 kb/s (default)
        Metadata:
          creation_time   : 1970-01-01T00:00:00.000000Z
          handler_name    : SoundHandler
          vendor_id       : [0][0][0][0]
          encoder         : Lavc59.12.100 aac
    [tls @ 0000016914101a80] Writing encrypted data to socket failedate= 979.0kbits/s speed=0.00793x
    av_interleaved_write_frame(): I/O error
        Last message repeated 1 times
    Error writing trailer of rtmps://live-api-s.facebook.com:443/rtmp/************************: I/O error
    frame=   23 fps=0.2 q=29.0 Lsize=     122kB time=00:00:01.08 bitrate= 918.0kbits/s speed=0.00899x
    video:122kB audio:18kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
    [tls @ 0000016914101a80] Writing encrypted data to socket failed
        Last message repeated 1 times
    [tls @ 0000016914101a80] Failed to send close message
    [libx264 @ 00000169128feb40] frame I:1     Avg QP:22.97  size:108248
    [libx264 @ 00000169128feb40] frame P:22    Avg QP:25.42  size:  5677
    [libx264 @ 00000169128feb40] mb I  I16..4:  8.8%  0.0% 91.2%
    [libx264 @ 00000169128feb40] mb P  I16..4:  1.2%  0.0%  0.7%  P16..4: 29.7%  8.8%  2.8%  0.0%  0.0%    skip:56.8%
    [libx264 @ 00000169128feb40] coded y,uvDC,uvAC intra: 71.5% 79.5% 44.0% inter: 6.1% 6.6% 0.2%
    [libx264 @ 00000169128feb40] i16 v,h,dc,p: 27% 33% 21% 19%
    [libx264 @ 00000169128feb40] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 15% 13%  9%  7%  8%  6% 13%  6%
    [libx264 @ 00000169128feb40] i8c dc,h,v,p: 45% 24% 20% 11%
    [libx264 @ 00000169128feb40] kb/s:2072.44
    [aac @ 0000016914101300] Qavg: 1207.145
    Conversion failed!

相关内容