## ffmpeg_install() { echo"ffmpeg checking" | lolcat ffmpeg -version | lolcat if [ $? == 0 ]; then echo -e "${yellow}ffmpeg$font${green}Installed$font" else echo"wegt installing..." | lolcat yum -y install wget echo"ffmpeg installing" | lolcat wget --no-check-certificate https://ffmpeg.org/releases/ffmpeg-5.1.2.tar.xz tar -xJf ffmpeg-5.1.2.tar.xz && cd ffmpeg-5.1.2 ./configure --prefix=/usr/local/ffmpeg && make && make install echo"export PATH=/usr/local/ffmpeg/bin:$PATH" echo"export LD_LIBRARY_PATH=/usr/local/ffmpeg/lib:$LD_LIBRARY_PATH" fi }
live_start() { echo"rtmp URL please:" | lolcat echo -e "$red Leave it blank will lead to default URL $font" read -r rtmp url=${rtmp:-"rtmp://live-push.bilivideo.com/live-bvc/?streamname=live_431290720_11083557&key=2c62b2a3a826c488d49663d6d1e1e3db&schedule=rtmp&pflag=1"} echo -e "$green The rtmp URL is: $font" echo$rmtp | lolcat echo"########################" | lolcat echo"The video path you want to do cycle live:" | lolcat echo -e "$red Leave it blank will load current path by default !!$font" read -r v_path V_PATH=${v_path:-"."} echo -e "$green video PATH is: $V_PATH$font" echo"########################" lolcat echo"Need logo right corner of your screen live(May need better CPU to supprt)?(yes/no):" | lolcat echo -e "$red Leave it blank will not have logo by default !!$font" read -r YN mark=${YN:-"no"} if [ $mark = "yes" ]; then echo"The logo file path (v.jpg/v.png/v.bmp):" | lolcat read -r image whiletrue; do for video in $(find $V_PATH -type f -name "*.mp4" | shuf -n1); do ffmpeg -re -i "$video" -i "$image" -filter_complex overlay=W-w-5:5 -c:v libx264 -c:a aac -b:a 192k -strict -2 -f flv $rtmp done done else echo"Starting live with no logo..." | lolcat whiletrue; do for video in $(find $V_PATH -type f -name "*.mp4" | shuf -n1); do ffmpeg -re -i "$video" -c:v copy -c:a aac -b:a 192k -strict -2 -f flv $rtmp done done fi }
live_stop() { screen -S live -X quit killall ffmpeg }
start() { echo -e "$red Please enter$font$green ffmpeg|start|stop$font" read -r $1 if [ $1 == "start" ]; then live_start elif [ $1 == "stop" ];then live_stop elif [ $1 == "ffmpeg"];then ffmpeg_install else exit 0 fi } # echo"Please make sure you have lolcat installed !!!" | lolcat start