如何使用FFmpeg设置从Icecast到YouTube Live的连续流?

时间:2018-10-07 17:17:21

标签: ffmpeg youtube stream live icecast

当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

0 个答案:

没有答案