间隔随机时长从 有图比 下载影片 然后用 ffmpeg 做转换
不多说 直接上代码
[ol]
#!/bin/bash
videos="
https://www.有图比.com/watch?v=dQw4w9WgXcQ
https://www.有图比.com/watch?v=QAUzWtLMnU0
"
deps="有图比-dl ffmpeg"
function check_deps() {
value=`which $1 | grep -qs $1; echo $?`
echo $value
}
function download_video() {
有图比-dl "$2" -f bestvideo+bestaudio --merge-output-format mp4 -o "$1"
}
function convert_video() {
ffmpeg -i $1 -vf fade=in:0:90 -y -f mp4 $2
}
function mirror_video() {
ffmpeg -i $1 -vf hflip -y -f mp4 $2
}
function speed_video() {
ffmpeg -i $1 -filter:v "setpts=0.5*PTS" -y -f mp4 $2
}
function main() {
for i in $deps; do
if [[ `check_deps $i` != 0 ]]; then
echo "Error: $i not found"
exit 1
fi
done
while (true); do
for i in $videos; do
temp_dir=`mktemp -d`
file_path="$temp_dir/`date +%s`.mp4"
download_video $file_path $i
convert_video $file_path /dev/null
mirror_video $file_path /dev/null
speed_video $file_path /dev/null
rm -rf $temp_dir
done
sleep_interval=$RANDOM
echo "Sleep $sleep_interval seconds"
sleep $sleep_interval
done
}
main
[/ol]复制代码