尽管 ffmpeg 似乎可以工作,但却无法在 youtube 上开始直播?

尽管 ffmpeg 似乎可以工作,但却无法在 youtube 上开始直播?

我是 ffpmeg 的新手,正在尝试通过 azuracast 进行 YouTube 电台直播。我在 Oracle Cloud 上创建了一个实例,并在那里安装了 azuracast。我可以收听我在 azuracast 中上传的歌曲,但是,每当我尝试使用我的公共页面进行直播时(参见下面的代码),代码似乎可以正常工作,但我从未在我的 YouTube 频道上看到直播。在流健康选项卡下,它始终显示当前未收到任何数据。

这是我开始直播的代码:

#! /bin/bash

VBR="1500k"
FPS="24"
QUAL="medium"

YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2"
KEY="....-....-....-....-...."

VIDEO_SOURCE="/home/ubuntu/lofi_background.jpg"
AUDIO_SOURCE="http://141.144.229.46/radio/8000/radio.mp3"

ffmpeg \
    -re -f lavfi -i "movie=filename=$VIDEO_SOURCE:loop=0, setpts=N/(FRAME_RATE*TB)" \
    -thread_queue_size 512 -i "$AUDIO_SOURCE" \
    -map 0:v:0 -map 1:a:0 \
    -map_metadata:g 1:g \
    -vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(($FPS * 2)) -b:v $VBR \
    -acodec libmp3lame -ar 44100 -threads 6 -qscale:v 3 -b:a 320000 -bufsize 512k \
    -f flv "$YOUTUBE_URL/$KEY"

运行上述代码后我看到的结果如下:

libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, lavfi, from 'movie=filename=/home/ubuntu/lofi_background.jpg:loop=0, setpts=N/(FRAME_RATE*TB)':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo, yuvj420p, 6720x4480 [SAR 1:1 DAR 3:2], 25 tbr, 25 tbn, 25 tbc
Input #1, mp3, from 'http://141.144.229.46/radio/8000/radio.mp3':
  Metadata:
    icy-br          : 128
    icy-description : Best house, jazz, easy listening, and hip-hop Lo-fi beats and samples...
    icy-name        : LoFi Meadow
    icy-pub         : 0
    StreamTitle     : dark matter - chasms
  Duration: N/A, start: 0.000000, bitrate: 128 kb/s
    Stream #1:0: Audio: mp3, 44100 Hz, stereo, fltp, 128 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
  Stream #1:0 -> #0:1 (mp3 (mp3float) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
[swscaler @ 0x55684fe17500] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0x55684fdd9980] -qscale is ignored, -crf is recommended.
[libx264 @ 0x55684fdd9980] VBV maxrate unspecified, assuming CBR
[libx264 @ 0x55684fdd9980] using SAR=1/1
[libx264 @ 0x55684fdd9980] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x55684fdd9980] profile High, level 6.0
[libx264 @ 0x55684fdd9980] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 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=2 keyint=48 keyint_min=4 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=cbr mbtree=1 bitrate=1500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=1500 vbv_bufsize=512 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
Output #0, flv, to 'rtmp://a.rtmp.youtube.com/live2/....-....-....-....-....':
  Metadata:
    icy-br          : 128
    icy-description : Best house, jazz, easy listening, and hip-hop Lo-fi beats and samples...
    icy-name        : LoFi Meadow
    icy-pub         : 0
    StreamTitle     : dark matter - chasms
    encoder         : Lavf58.29.100
    Stream #0:0: Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuv420p(progressive), 6720x4480 [SAR 1:1 DAR 3:2], q=-1--1, 1500 kb/s, 24 fps, 1k tbn, 24 tbc
    Metadata:
      encoder         : Lavc58.54.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/1500000 buffer size: 512000 vbv_delay: -1
    Stream #0:1: Audio: mp3 (libmp3lame) ([2][0][0][0] / 0x0002), 44100 Hz, stereo, fltp, 320 kb/s
    Metadata:
      encoder         : Lavc58.54.100 libmp3lame
frame=    1 fps=0.3 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x

所以我没有看到任何错误(虽然有一些警告,但我在谷歌上搜索了一下,它们可以忽略吗?)。我想这可能是由于防火墙造成的,于是我创建了一条新的出站规则,试图允许端口 1934、443。但是,仍然不起作用。

有人可以指导我吗?

提前致谢!

相关内容