Как настроить непрерывный поток от Icecast до YouTube Live с помощью FFmpeg? - PullRequest
0 голосов
/ 07 октября 2018

Когда серверы Icecast выключаются, FFmpeg пытается восстановить соединение, но только с одной попытки.Вот ошибка, которую я получаю, и мой сценарий.

[http @ 0x556612e43f80] Stream ends prematurely at 4040716, should be 1844674407370955161597x
[http @ 0x556612e43f80] Will reconnect at 4040716 error=Input/output error.
[tcp @ 0x7fe10400b7a0] Connection to tcp://185.195.26.99:8000 failed: Connection refused
[http @ 0x556612e43f80] Failed to reconnect at 0.
185.195.26.99:8000/radio: Input/output error1:40.96 bitrate=2878.3kbits/s speed=0.997x

После того, как этот поток продолжается, и YouTube не прерывает живой перевод, но он становится пустым.

#!/bin/bash

image=../pic/1.jpg #path to image
source=http://***.**.**.**:8000/radio #radio stream as source
youtube_url=rtmp://a.rtmp.youtube.com/live2 #rtmp://a.rtmp.youtube.com/live2
youtube_key=****-****-*****-****
resolution=1920x1080 #stream resolution

###########################################################

stream=FFREPORT=file=../log/stream-%t.log:level=32 ffmpeg \
        -thread_queue_size 1024 \
        -reconnect 1 -reconnect_at_eof 1 -reconnect_streamed 1 -reconnect_delay_max 3600 -i $source \
        -re -loop 1 -i $image \
        -acodec aac -b:a 128k -ar 44100 -strict experimental \
        -vcodec libx264 -preset ultrafast -tune stillimage -r 30 -g 60 -b:v 4500k -minrate 4000k -maxrate 4500k -bufsize 6000k \
        -s $resolution \
        -f flv \
        $youtube_url/$youtube_key\

until $stream ; do
        echo "Restarting stream ..."
        sleep 2
done
...