Skip to content

Instantly share code, notes, and snippets.

@liu246542
Created November 3, 2019 14:11
Show Gist options
  • Save liu246542/4d05d25081998f1390c0f2a57c73207b to your computer and use it in GitHub Desktop.
Save liu246542/4d05d25081998f1390c0f2a57c73207b to your computer and use it in GitHub Desktop.
ThreeKingdom
chapters = { "群雄逐鹿" : ["桃园三结义", "十常侍乱政", "董卓霸京师", "孟德献刀", "三英战吕布", "连环计", "凤仪亭", "三让徐州", "孙策立业", "辕门射戟", "宛城之战", "白门楼 上", "白门楼 下", "煮酒论英雄", "袁曹起兵", "关羽约三事", "挂印封金", "千里走单骑", "古城相会", "孙策之死", "官渡之战上", "官渡之战下", "大破袁绍"],
"赤壁鏖战" : ["跃马檀溪", "刘备求贤", "回马荐诸葛", "三顾茅庐", "火烧博望坡", "携民渡江", "舌战群儒", "智激周瑜", "周瑜空设计", "群英会", "草船借箭", "苦肉计", "庞统献连环", "横槊赋诗", "诸葛祭风", "火烧赤壁", "智取南郡", "力夺四郡", "美人计", "甘露寺", "回荆州", "三气周瑜", "卧龙吊孝", "割须弃袍"],
"三足鼎立" : ["张松献图", "刘备入川", "凤雏落坡", "义释严颜", "夺占西川", "单刀赴会", "合肥会战", "立嗣之争", "定军山", "巧取汉中", "水淹七军", "走麦城", "曹操之死", "曹丕篡汉", "兴兵伐吴", "火烧连营", "安居平五路"],
"南征北战" : ["兵渡泸水", "绝路问津", "七擒孟获", "出师北伐", "收姜维", "司马复出", "空城退敌", "司马取印", "祁山斗智", "诸葛妆神", "六出祁山", "火熄上方谷", "秋风五丈原"],
"三分归一" : ["诈病赚曹爽", "吴宫干戈", "兵困铁笼山", "司马昭弑君", "九伐中原", "偷渡阴平", "三分归晋"]}
# drawtext=fontfile=lx.ttf: text='%{pts \:gmtime\:0\:%M\\\:%S}/43\:10': r=25: x=16: y=h-48: fontsize=30: fontcolor=white@0.8: box=1: boxcolor=black@1
# timebar = ['/43\\:10', '/42\\:02', '/40\\:18']
timebar = ['/43\\:10', '/41\\:02', '/40\\:18', '/40\\:15',
'/40\\:37', '/40\\:59', '/41\\:19', '/40\\:32',
'/40\\:37', '/40\\:47', '/40\\:59', '/39\\:22',
'/39\\:30', '/40\\:41', '/40\\:04', '/40\\:58',
'/40\\:38', '/40\\:37', '/40\\:23', '/40\\:39',
'/39\\:54', '/40\\:41', '/40\\:35', '/39\\:20',
'/40\\:35', '/39\\:04', '/39\\:05', '/40\\:40',
'/40\\:08', '/39\\:22', '/40\\:45', '/40\\:33',
'/40\\:05', '/40\\:29', '/40\\:27', '/40\\:24',
'/39\\:20', '/40\\:01', '/39\\:47', '/40\\:43',
'/38\\:57', '/40\\:19', '/38\\:41', '/40\\:08',
'/39\\:32', '/40\\:35', '/40\\:09', '/40\\:59',
'/38\\:14', '/39\\:46', '/40\\:42', '/37\\:15',
'/38\\:57', '/40\\:10', '/40\\:58', '/39\\:35',
'/38\\:25', '/40\\:44', '/40\\:28', '/40\\:38',
'/40\\:45', '/39\\:43', '/39\\:38', '/40\\:31',
'/40\\:35', '/40\\:21', '/40\\:17', '/40\\:17',
'/40\\:28', '/40\\:38', '/40\\:04', '/40\\:28',
'/40\\:22', '/40\\:48', '/40\\:33', '/40\\:32',
'/40\\:24', '/43\\:09', '/39\\:15', '/40\\:14',
'/40\\:24', '/37\\:37', '/39\\:37', '/37\\:54']
def test():
common = "ffmpeg.exe -i .\\三国演义.The.Romance.of.Three.Kingdoms.1994.E{0}.1080p.WEB-DL.AAC.H.264-OurTV.mp4 -s 1280x720 -vf {1} -c:v libx264 -b:v 3500k -preset slower -tune ssim -c:a aac -ac 2 -ar 16k -ab 96k D:/Live/mod/{0}.mp4"
for i in range(1, 85):
if i < 10: index = '0' + str(i)
else: index = str(i)
if i < 24:
commonx = "\"[in]drawtext=fontfile=lx.ttf:text='群':x=(160-tw)/2:y=(h/2-60):fontsize=60:fontcolor=White:shadowy=2[a];[a]drawtext=fontfile=lx.ttf:text='雄':x=(160-tw)/2:y=(h/2):fontsize=60:fontcolor=White:shadowy=2[a];[a]drawtext=fontfile=lx.ttf:text='逐':x=(160-tw)/2:y=(h/2+60):fontsize=60:fontcolor=White:shadowy=2[a];[a]drawtext=fontfile=lx.ttf:text='鹿':x=(160-tw)/2:y=(h/2+120):fontsize=60:fontcolor=White:shadowy=2[a];"
title = chapters['群雄逐鹿'][i-1]
elif i < 48:
commonx = "\"[in]drawtext=fontfile=lx.ttf:text='赤':x=(160-tw)/2:y=(h/2-60):fontsize=60:fontcolor=White:shadowy=2[a];[a]drawtext=fontfile=lx.ttf:text='壁':x=(160-tw)/2:y=(h/2):fontsize=60:fontcolor=White:shadowy=2[a];[a]drawtext=fontfile=lx.ttf:text='鏖':x=(160-tw)/2:y=(h/2+60):fontsize=60:fontcolor=White:shadowy=2[a];[a]drawtext=fontfile=lx.ttf:text='战':x=(160-tw)/2:y=(h/2+120):fontsize=60:fontcolor=White:shadowy=2[a];"
title = chapters['赤壁鏖战'][i-24]
elif i < 65:
commonx = "\"[in]drawtext=fontfile=lx.ttf:text='三':x=(160-tw)/2:y=(h/2-60):fontsize=60:fontcolor=White:shadowy=2[a];[a]drawtext=fontfile=lx.ttf:text='足':x=(160-tw)/2:y=(h/2):fontsize=60:fontcolor=White:shadowy=2[a];[a]drawtext=fontfile=lx.ttf:text='鼎':x=(160-tw)/2:y=(h/2+60):fontsize=60:fontcolor=White:shadowy=2[a];[a]drawtext=fontfile=lx.ttf:text='立':x=(160-tw)/2:y=(h/2+120):fontsize=60:fontcolor=White:shadowy=2[a];"
title = chapters['三足鼎立'][i-48]
elif i < 78:
commonx = "\"[in]drawtext=fontfile=lx.ttf:text='南':x=(160-tw)/2:y=(h/2-60):fontsize=60:fontcolor=White:shadowy=2[a];[a]drawtext=fontfile=lx.ttf:text='征':x=(160-tw)/2:y=(h/2):fontsize=60:fontcolor=White:shadowy=2[a];[a]drawtext=fontfile=lx.ttf:text='北':x=(160-tw)/2:y=(h/2+60):fontsize=60:fontcolor=White:shadowy=2[a];[a]drawtext=fontfile=lx.ttf:text='战':x=(160-tw)/2:y=(h/2+120):fontsize=60:fontcolor=White:shadowy=2[a];"
title = chapters['南征北战'][i-65]
elif i < 85:
commonx = "\"[in]drawtext=fontfile=lx.ttf:text='三':x=(160-tw)/2:y=(h/2-60):fontsize=60:fontcolor=White:shadowy=2[a];[a]drawtext=fontfile=lx.ttf:text='分':x=(160-tw)/2:y=(h/2):fontsize=60:fontcolor=White:shadowy=2[a];[a]drawtext=fontfile=lx.ttf:text='归':x=(160-tw)/2:y=(h/2+60):fontsize=60:fontcolor=White:shadowy=2[a];[a]drawtext=fontfile=lx.ttf:text='一':x=(160-tw)/2:y=(h/2+120):fontsize=60:fontcolor=White:shadowy=2[a];"
title = chapters['三分归一'][i-78]
commony = commonx + handleVF(title, i)
print(common.format(str(index), commony))
def handleVF(title, i):
if len(title) == 3:
return "[a]drawtext=fontfile=lx.ttf:text='{0}':x=1700+(160-tw)/2:y=(h/2):fontsize=60:fontcolor=White:shadowy=2[a];[a]drawtext=fontfile=lx.ttf:text='{1}':x=1700+(160-tw)/2:y=(h/2+60):fontsize=60:fontcolor=White:shadowy=2[a];[a]drawtext=fontfile=lx.ttf:text='{2}':x=1700+(160-tw)/2:y=(h/2+110):fontsize=60:fontcolor=White:shadowy=2[a];[a]ass=./ass/{3}.ass[a];[a]drawtext=fontfile=lx.ttf: text='%{{pts \\:gmtime\\:0\\:%M\\\\\\:%S}}{4}': r=25: x=16: y=h-48: fontsize=30: fontcolor=white@0.8: box=1: boxcolor=black@1[out]\"".format(title[0], title[1], title[2], str(i), timebar[i-1])
elif len(title) == 4:
return "[a]drawtext=fontfile=lx.ttf:text='{0}':x=1700+(160-tw)/2:y=(h/2-60):fontsize=60:fontcolor=White:shadowy=2[a];[a]drawtext=fontfile=lx.ttf:text='{1}':x=1700+(160-tw)/2:y=(h/2):fontsize=60:fontcolor=White:shadowy=2[a];[a]drawtext=fontfile=lx.ttf:text='{2}':x=1700+(160-tw)/2:y=(h/2+60):fontsize=60:fontcolor=White:shadowy=2[a];[a]drawtext=fontfile=lx.ttf:text='{3}':x=1700+(160-tw)/2:y=(h/2+120):fontsize=60:fontcolor=White:shadowy=2[a];[a]ass=./ass/{4}.ass[a];[a]drawtext=fontfile=lx.ttf: text='%{{pts \\:gmtime\\:0\\:%M\\\\\\:%S}}{5}': r=25: x=16: y=h-48: fontsize=30: fontcolor=white@0.8: box=1: boxcolor=black@1[out]\"".format(title[0], title[1], title[2], title[3], str(i), timebar[i-1])
else:
return "[a]drawtext=fontfile=lx.ttf:text='{0}':x=1700+(160-tw)/2:y=(h/2-60):fontsize=60:fontcolor=White:shadowy=2[a];[a]drawtext=fontfile=lx.ttf:text='{1}':x=1700+(160-tw)/2:y=(h/2):fontsize=60:fontcolor=White:shadowy=2[a];[a]drawtext=fontfile=lx.ttf:text='{2}':x=1700+(160-tw)/2:y=(h/2+60):fontsize=60:fontcolor=White:shadowy=2[a];[a]drawtext=fontfile=lx.ttf:text='{3}':x=1700+(160-tw)/2:y=(h/2+120):fontsize=60:fontcolor=White:shadowy=2[a];[a]drawtext=fontfile=lx.ttf:text='{4}':x=1700+(160-tw)/2:y=(h/2+180):fontsize=60:fontcolor=White:shadowy=2[a];[a]ass=./ass/{5}.ass[a];[a]drawtext=fontfile=lx.ttf: text='%{{pts \\:gmtime\\:0\\:%M\\\\\\:%S}}{6}': r=25: x=16: y=h-48: fontsize=30: fontcolor=white@0.8: box=1: boxcolor=black@1[out]\"".format(title[0], title[1], title[2], title[3], title[4], str(i), timebar[i-1])
test()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment