Last active
May 12, 2022 11:42
-
-
Save gMan1990/b4585ead146c92fe74d59a84cb3942fd to your computer and use it in GitHub Desktop.
ffmpeg ysl to a live
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cd "$(dirname "$0")" || exit 1 | |
DIR=$(pwd) | |
OUTFILE="-f flv rtmp://js.live-send.acg.tv/live-js/?streamname=*&key=*" | |
while :; do | |
#./ffmpeg -re -i "Bailey No Ordinary Cat.mp4" -c copy $OUTFILE | |
cd "$DIR/YSL" || exit 1 | |
for name1 in *; do | |
if [ -d "$DIR/YSL/$name1" ]; then | |
cd "$DIR/YSL/$name1" || exit 1 | |
for name2 in *; do | |
if [ -f "$DIR/YSL/$name1/$name2" ]; then | |
if [ -z "$mp3Fir" ] && [ "mp3" = "${name2##*.}" ]; then | |
mp3Fir=$name2 | |
if [ -n "$jpgFir" ]; then | |
break | |
fi | |
continue | |
fi | |
if [ -z "$jpgFir" ] && [ "jpg" = "${name2##*.}" ]; then | |
jpgFir=$name2 | |
if [ -n "$mp3Fir" ]; then | |
break | |
fi | |
continue | |
fi | |
fi | |
done | |
if [ -n "$mp3Fir" ]; then | |
cd "$DIR" || exit 1 | |
echo "$name1/$mp3Fir" > textfileYSL.txt | |
if [ -n "$jpgFir" ]; then | |
imgFile=YSL/$name1/$jpgFir | |
echo "$jpgFir" >> textfileYSL.txt | |
else | |
imgRandom=$(ls YSLImg | sort -R | head -n 1) | |
imgFile="YSLImg/$imgRandom" # 随机背景图存放文件夹 | |
echo "$imgRandom(RANDOM)" >> textfileYSL.txt | |
fi | |
truncate -s "$(( $(stat -c "%s" textfileYSL.txt) - 1 ))" textfileYSL.txt | |
# 暂定超3分钟的不循环(估计值) | |
sloop=$((4 * 1024 * 1024 / $(stat -c "%s" "YSL/$name1/$mp3Fir"))) | |
./ffmpeg -re -stream_loop "$((sloop > 10 ? 10 : sloop))" -i "YSL/$name1/$mp3Fir" -loop 1 -i "$imgFile" -c:v libx264 -c:a copy -shortest -vf "scale=iw: -2, drawtext=textfile=textfileYSL.txt: fontcolor=Black: x=w-tw: box=1: boxcolor=White" -threads 2 $OUTFILE | |
mp3Fir= | |
fi | |
jpgFir= | |
fi | |
done | |
done |
Author
gMan1990
commented
Aug 9, 2019
•
https://api.live.bilibili.com/xlive/web-room/v1/record/getList
name | required | type/example |
---|---|---|
room_id | y | 9863884 |
page | y | 1 |
page_size | y | 99 |
https://api.live.bilibili.com/xlive/web-room/v1/record/getLiveRecordUrl
name | required | type/example |
---|---|---|
rid | y | R1ex411c7Jk |
platform | y | html5 |
- Zeranoe FFmpeg Builds
- https://github.com/tomaszzmuda/Xabe.FFmpeg/releases/tag/executables
# split in files of given max duration, https://unix.stackexchange.com/questions/1670
ffmpeg -hide_banner -i input.mp4 -c copy -f segment -segment_time 0:00:50 -reset_timestamps 1 output-%d.mp4
# split in files of given max size, see GPAC-MP4Box
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment