几秒钟后 ffmpeg 直播停止到 facebook

ffmpeg live stream stops to facebook after a few seconds

我正在尝试使用以下设置将直播流式传输到 Facebook:

{
    '-i' : 'rtmp://localhost/live/mystream',
    '-f' : 'flv rtmps://live-api-s.facebook.com:443/rtmp/#key',
    '-g' :'30' ,
    '-r' :'30',
    '-c:a': 'aac',
    '-strict': '-2',
    '-c:v': 'h264',
    '-b:v': '768k',
    '-b:a' : '256k',
    '-preset': 'ultrafast',
    '-tune': 'stillimage',
    '-pix_fmt': 'yuvj444p',
    '-profile:v': 'high',
    '-level': '4.1'
}

但流停止并显示此消息:

Output #0, flv, to 'rtmps://live-api-s.facebook.com:443/rtmp/#key':
  Metadata:
    encoder         : Lavf58.29.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, 29.97 fps, 1k tbn, 29.97 tbc
    Metadata:
      encoder         : Lavc58.54.100 flv
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: mp3 (libmp3lame) ([2][0][0][0] / 0x0002), 48000 Hz, stereo, fltp
    Metadata:
      encoder         : Lavc58.54.100 libmp3lame

frame=   38 fps=0.0 q=2.0 size=     266kB time=00:00:01.43 bitrate=1522.0kbits/s speed=2.85x
frame=   74 fps= 42 q=2.0 size=     478kB time=00:00:02.63 bitrate=1487.0kbits/s speed=1.51x
frame=  113 fps= 37 q=2.0 size=     694kB time=00:00:03.95 bitrate=1438.7kbits/s speed=1.29x
frame=  152 fps= 35 q=2.0 size=     911kB time=00:00:05.24 bitrate=1421.7kbits/s speed= 1.2x
frame=  191 fps= 34 q=2.0 size=    1127kB time=00:00:06.54 bitrate=1411.0kbits/s speed=1.16x
frame=  230 fps= 33 q=2.0 size=    1395kB time=00:00:07.84 bitrate=1457.9kbits/s speed=1.12x
frame=  265 fps= 35 q=1.6 size=    1606kB time=00:00:09.01 bitrate=1458.8kbits/s speed= 1.2x
frame=  269 fps= 32 q=2.0 size=    1612kB time=00:00:09.16 bitrate=1441.3kbits/s speed=1.11x
frame=  305 fps= 32 q=2.0 size=    1826kB time=00:00:10.50 bitrate=1424.1kbits/s speed=1.09x
frame=  344 fps= 32 q=2.0 size=    2043kB time=00:00:11.82 bitrate=1415.2kbits/s speed=1.08x
frame=  383 fps= 31 q=2.0 size=    2259kB time=00:00:13.12 bitrate=1410.5kbits/s speed=1.08x
frame=  422 fps= 31 q=2.0 size=    2527kB time=00:00:14.41 bitrate=1436.1kbits/s speed=1.07x
[tls @ 0x55fd1817f380] Error in the push function.
av_interleaved_write_frame(): Input/output error

    Last message repeated 1 times
[flv @ 0x55fd1817ce40] Failed to update header with correct duration.
[flv @ 0x55fd1817ce40] Failed to update header with correct filesize.
Error writing trailer of rtmps://live-api-s.facebook.com:443/rtmp/#key
: Input/output error
frame=  456 fps= 33 q=2.0 Lsize=    2683kB time=00:00:15.54 bitrate=1413.7kbits/s speed=1.13x

video:2427kB audio:243kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.487371%

[tls @ 0x55fd1817f380] The specified session has been invalidated for some reason.

3/5/2022 07:49:50 8101 [INFO] [rtmp play] Close stream. id=O983DKJ9 streamPath=/live/HOD streamId=1
3/5/2022 07:49:50 8101 [INFO] [rtmp disconnect] id=O983DKJ9
    Last message repeated 1 times
Conversion failed!

我也收到来自 Facebook 的消息:

Audio using unsupported codec
Please set the audio codec for the stream to a supported codec (AAC). If you continue without updating, viewers may experience lower audio quality or the stream may terminate.

我尝试了在 Whosebug 上可以找到的所有设置,但没有任何效果,尽管当我流式传输到 YouTube 时它工作正常,我做错了什么?谢谢

地点

'-f' : 'flv rtmps://live-api-s.facebook.com:443/rtmp/#key',

在数组的末尾。

所有输出选项必须在输出 URL 之前。