Last active
August 30, 2020 20:29
-
-
Save sarkrui/261e3d9bc2808d4052f581e9a288f435 to your computer and use it in GitHub Desktop.
微信表情包制作相关
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")" | |
echo "拖拽文件" | |
read filepath | |
fullname=$(basename $filepath) | |
filename=${fullname%.*} | |
nullpath=${filepath%.*} | |
echo $filename | |
echo "要添加什么文字?" | |
read textSRT | |
genname=$(echo $nullpath | sed "s/$filename/$textSRT/g") | |
echo $genname | |
PS3='请输入你的选项:' | |
options=("乐喵体" "普惠体" "null" "Quit") | |
select opt in "${options[@]}" | |
do | |
case $opt in | |
"乐喵体") | |
echo "你选择了乐喵体" | |
fontOpt=/Users/p.xing/Library/Fonts/HYLeMiaoTiW.ttf | |
outputname=$genname"_SRT_Lemiao.gif" | |
break | |
;; | |
"普惠体") | |
echo "你选择了阿里巴巴普惠体" | |
fontOpt=/Users/p.xing/Library/Fonts/Alibaba-PuHuiTi-Medium.ttf | |
outputname=$genname"_SRT_Puhui.gif" | |
break | |
;; | |
"null") | |
echo "待补充..." | |
break | |
;; | |
"Quit") | |
echo "" | |
break | |
;; | |
*) echo "不规范的输入";; | |
esac | |
done | |
ffmpeg -y -i $filepath \ | |
-vf "drawtext=\ | |
fontfile=$fontOpt:\ | |
text=$textSRT:\ | |
x=(w-tw)/2:\ | |
y=(h-text_h*1.4):\ | |
bordercolor=white:\ | |
borderw=3:\ | |
fontsize=36:\ | |
fontcolor=black:\ | |
"\ | |
$outputname |
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")" | |
# 创建解压 GIF 的文件夹 | |
mkdir temp/ | |
# 120x120 尺寸的 PNG 文件夹 | |
mkdir 120PNG/ | |
# 提前创建 PNG 文件夹 | |
mkdir temp/temp_0{1..9} && mkdir temp/temp_{11..16} | |
# 安装微信表情包命名规则创建文件(夹) | |
for dir in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 | |
do | |
ffmpeg -i 240GIF/$dir.gif -vf scale=120:120 -vsync 0 temp/temp_$dir/temp_%d.png | |
# 复制第 5 张作为关键缩略图 | |
cp temp/temp_$dir/temp_5.png 120PNG/$dir.png | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ffmpeg -i INPUT_FILE -vf "scale=500:500:force_original_aspect_ratio=increase,crop=500:500" OUTPUT_FILE