### 批量生成 gif ```bash #!/bin/bash for file in $(find . -iname "*.mp4"); do echo `ffmpeg -ss 15 -t 3 -i $file -r 15 -vf fps=12,scale=100:-1 ${file/.mp4/.gif}` done echo 'OK' ``` ### 监听服务是否在运行 ```bash #!/bin/bash while true do ps -ef | grep "test" | grep -v "grep" if [ "$?" -eq 1 ] then echo "服务已经启动!" else echo "服务在运行!" fi sleep 60 done ``` ### 批量合并视频 ```bash #!/bin/bash dir=/video/to/path for file in $dir/*; do result=$(echo $file | grep "x") if [[ "$result" == "" ]];then echo $file; echo ${file/.mp4/x.mp4} ffmpeg -i $file -i ${file/.mp4/x.mp4} -acodec copy -vcodec copy ${file/.mp4/z.mp4} fi done ``` ### 批量截图视频 ```bash #!/bin/bash dir=/video/to/path for file in $dir/*; do echo $file ffmpeg -i $file -vf "scale=1000:1000/a" -y -f image2 -t 0.001 -ss 08.010 $file.jpg done ```