亚洲篇
中国
先画个五角星
- 在100x100的画布P1中,先画一个三角形M
ffplay -f lavfi -i color=ffffff00:100x100[white];[white]geq=r='if(gt(X*tan(72*PI/180),Y),r(X,Y),255)':g='if(gt(X*tan(72*PI/180),Y),g(X,Y),255)':b='if(gt(X*tan(72*PI/180),Y),b(X,Y),0)'
- 此三角形M水平镜像后得到M1, M1与M水平方向并列排布,得到200x100的画布P2,内部为等腰三角形,三角形包含了向上方向的三角形
ffplay -f lavfi -i color=ffffff00:100x100[white];[white]geq=r='if(gt(X*tan(72*PI/180),Y),r(X,Y),255)':g='if(gt(X*tan(72*PI/180),Y),g(X,Y),255)':b='if(gt(X*tan(72*PI/180),Y),b(X,Y),0)'[triangle];[triangle]split=2[T1][T2];[T2]hflip[T22];[T22][T1]hstack=2
- 针对200x100的画布P2,底部再填充200x100的白色,变为 200x200的画布P3,此时等腰三角形在画布上半部,注意使用colorkey filter将背景白色抠图为透明色
ffplay -f lavfi -i color=ffffff00:100x100[white];[white]geq=r='if(gt(X*tan(72*PI/180),Y),r(X,Y),255)':g='if(gt(X*tan(72*PI/180),Y),g(X,Y),255)':b='if(gt(X*tan(72*PI/180),Y),b(X,Y),0)'[triangle];[triangle]split=2[T1][T2];[T2]hflip[T22];[T22][T1]hstack=2[UP];[UP]pad=iw:ih*2:0:0:ffffff00[T];[T]colorkey=white
- 画布P3,一分为五,分布旋转0/72/144/216/288度,得到五个方向的三角形,overly排布后即可.
ffplay -f lavfi -i color=ffffff00:100x100[white];[white]geq=r='if(gt(X*tan(72*PI/180),Y),r(X,Y),255)':g='if(gt(X*tan(72*PI/180),Y),g(X,Y),255)':b='if(gt(X*tan(72*PI/180),Y),b(X,Y),0)'[triangle];[triangle]split=2[T1][T2];[T2]hflip[T22];[T22][T1]hstack=2[UP];[UP]pad=iw:ih*2:0:0:ffffff00[T];[T]colorkey=white[RAW];[RAW]split=5[T1][T2][T3][T4][T5];[T2]rotate=a=(72*PI/180):c=ffffff00[R2];[T3]rotate=a=(144*PI/180):c=ffffff00[R3];[T4]rotate=a=(216*PI/180):c=ffffff00[R4];[T5]rotate=a=(288*PI/180):c=ffffff00[R5];[R2][R3]overlay[U1];[R4][R5]overlay[U2];[U1][U2]overlay[V1];[V1][T1]overlay
- 由于三角形的边缘的颜色,旋转之后会导致一些边缘出现在五角星内部,故要除去此边缘,
ffplay -f lavfi -i color=ffffff00:100x100[white];[white]geq=r='if(gt(X*tan(72*PI/180),Y),r(X,Y),255)':g='if(gt(X*tan(72*PI/180),Y),g(X,Y),255)':b='if(gt(X*tan(72*PI/180),Y),b(X,Y),0)'[triangle];[triangle]split=2[T1][T2];[T2]hflip[T22];[T22][T1]hstack=2[UP];[UP]pad=iw:ih*2:0:0:ffffff00[T];[T]colorkey=white[RAW];[RAW]split=5[T1][T2][T3][T4][T5];[T2]rotate=a=(72*PI/180):c=ffffff00[R2];[T3]rotate=a=(144*PI/180):c=ffffff00[R3];[T4]rotate=a=(216*PI/180):c=ffffff00[R4];[T5]rotate=a=(288*PI/180):c=ffffff00[R5];[R2][R3]overlay[U1];[R4][R5]overlay[U2];[U1][U2]overlay[V1];[V1][T1]overlay[star];[star]geq=r='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),r(X,Y),255)':g='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),g(X,Y),255)':b='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),b(X,Y),0)'
画图命令为:ffmpeg -f lavfi -i color=ffffff00:100x100[white];[white]geq=r='if(gt(X*tan(72*PI/180),Y),r(X,Y),255)':g='if(gt(X*tan(72*PI/180),Y),g(X,Y),255)':b='if(gt(X*tan(72*PI/180),Y),b(X,Y),0)'[triangle];[triangle]split=2[T1][T2];[T2]hflip[T22];[T22][T1]hstack=2[UP];[UP]pad=iw:ih*2:0:0:ffffff00[T];[T]colorkey=white[RAW];[RAW]split=5[T1][T2][T3][T4][T5];[T2]rotate=a=(72*PI/180):c=ffffff00[R2];[T3]rotate=a=(144*PI/180):c=ffffff00[R3];[T4]rotate=a=(216*PI/180):c=ffffff00[R4];[T5]rotate=a=(288*PI/180):c=ffffff00[R5];[R2][R3]overlay[U1];[R4][R5]overlay[U2];[U1][U2]overlay[V1];[V1][T1]overlay[star];[star]geq=r='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),r(X,Y),255)':g='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),g(X,Y),255)':b='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),b(X,Y),0) -frames:v 1 -y five_pointed_star.png
OK,再来看下维基百科上中国国旗的绘画方法
其中红色色号为 #ee1c25, 黄色色号为 #ffff00,其中的尺寸特征
- 宽高为3000x2000,
- 大五角星的外圆半径为300,叠加坐标为(200, 200),小五角星的外圆半径为100,叠加坐标分别为(900, 100), (1100, 300) (1100, 600),(900, 800)
- 四颗小五角星的旋转角度分别为逆时针 90+arctan(3/5), 90+arctan(1/7), 90+arctan(7/2), 90+arctan(5/4)
- OK, 开始绘画
- 绘制透明的大五角星
ffmpeg -f lavfi -i color=white:300x300[white];[white]geq=r='if(gt(X*tan(72*PI/180),Y),r(X,Y),255)':g='if(gt(X*tan(72*PI/180),Y),g(X,Y),255)':b='if(gt(X*tan(72*PI/180),Y),b(X,Y),0)'[triangle];[triangle]split=2[T1][T2];[T2]hflip[T22];[T22][T1]hstack=2[UP];[UP]pad=iw:ih*2:0:0:white[T];[T]colorkey=white[RAW];[RAW]split=5[T1][T2][T3][T4][T5];[T2]rotate=a=(72*PI/180):c=white[R2];[T3]rotate=a=(144*PI/180):c=white[R3];[T4]rotate=a=(216*PI/180):c=white[R4];[T5]rotate=a=(288*PI/180):c=white[R5];[R2][R3]overlay[U1];[R4][R5]overlay[U2];[U1][U2]overlay[V1];[V1][T1]overlay[star];[star]geq=r='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),r(X,Y),255)':g='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),g(X,Y),255)':b='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),b(X,Y),0)'[s1];[s1]colorkey=white:0.35 -frames:v 1 -y big_star.png
- 绘制小的五角星,无须透明
ffmpeg -f lavfi -i color=white:100x100[white];[white]geq=r='if(gt(X*tan(72*PI/180),Y),r(X,Y),255)':g='if(gt(X*tan(72*PI/180),Y),g(X,Y),255)':b='if(gt(X*tan(72*PI/180),Y),b(X,Y),0)'[triangle];[triangle]split=2[T1][T2];[T2]hflip[T22];[T22][T1]hstack=2[UP];[UP]pad=iw:ih*2:0:0:white[T];[T]colorkey=white[RAW];[RAW]split=5[T1][T2][T3][T4][T5];[T2]rotate=a=(72*PI/180):c=white[R2];[T3]rotate=a=(144*PI/180):c=white[R3];[T4]rotate=a=(216*PI/180):c=white[R4];[T5]rotate=a=(288*PI/180):c=white[R5];[R2][R3]overlay[U1];[R4][R5]overlay[U2];[U1][U2]overlay[V1];[V1][T1]overlay[star];[star]geq=r='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),r(X,Y),255)':g='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),g(X,Y),255)':b='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),b(X,Y),0) -frames:v 1 -y small_star.png
分别对小五角星旋转处理对应的角度,并透明化背景得到1,2, 3,4 小五角星ffmpeg -i small_star.png -vf rotate=a=(3*PI/2-atan(3/5)):fillcolor=white[s1];[s1]colorkey=white:0.35 -frames:v 1 -y small_star_1.png
ffmpeg -i small_star.png -vf rotate=a=(3*PI/2-atan(1/7)):fillcolor=white[s1];[s1]colorkey=white:0.35 -frames:v 1 -y small_star_2.png
ffmpeg -i small_star.png -vf rotate=a=(-atan(7/2)):fillcolor=white[s1];[s1]colorkey=white:0.35 -frames:v 1 -y small_star_3.png
ffmpeg -i small_star.png -vf rotate=a=(-atan(5/4)):fillcolor=white[s1];[s1]colorkey=white:0.35 -frames:v 1 -y small_star_4.png
OK,至此完成了准备工作,接下来创建背景图像,并将大五角星和四颗小五角星分别overlay叠加到红色背景的指定位置即可ffmpeg -i big_star.png -i small_star_1.png -i small_star_2.png -i small_star_3.png -i small_star_4.png -filter_complex color=ee1c25:3000x2000[bg];[bg][0:v]overlay=200:200[bg1];[bg1][1:v]overlay=900:100[bg2];[bg2][2:v]overlay=1100:300[bg3];[bg3][3:v]overlay=1100:600[bg4];[bg4][4:v]overlay=900:800 -frames:v 1 -y China_Flag.png
大功告成,China_Flag.png 如下图所示
朝鲜
参考中国国旗章节,先画一个半径为155的白底红色五角星ffmpeg -f lavfi -i color=white:155x155[white];[white]geq=r='if(gt(X*tan(72*PI/180),Y),r(X,Y),255)':g='if(gt(X*tan(72*PI/180),Y),g(X,Y),0)':b='if(gt(X*tan(72*PI/180),Y),b(X,Y),0)'[triangle];[triangle]split=2[T1][T2];[T2]hflip[T22];[T22][T1]hstack=2[UP];[UP]pad=iw:ih*2:0:0:ffffff00[T];[T]colorkey=white[RAW];[RAW]split=5[T1][T2][T3][T4][T5];[T2]rotate=a=(72*PI/180):c=ffffff00[R2];[T3]rotate=a=(144*PI/180):c=ffffff00[R3];[T4]rotate=a=(216*PI/180):c=ffffff00[R4];[T5]rotate=a=(288*PI/180):c=ffffff00[R5];[R2][R3]overlay[U1];[R4][R5]overlay[U2];[U1][U2]overlay[V1];[V1][T1]overlay[star];[star]geq=r='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),r(X,Y),255)':g='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),g(X,Y),0)':b='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),b(X,Y),0)' -frames:v 1 -y star.png
再画对应的背景图案ffmpeg -f lavfi -i color=red:1440x440[red];color=blue:1440x120[blue];[blue]split=2[b1][b2];color=white:1440x20[w0];[w0]split=2[w1][w2];[red]geq=r='if(gt((X-W/3)*(X-W/3)+(Y-H/2)*(Y-H/2),W*W/81),r(X,Y),255)':g='if(gt((X-W/3)*(X-W/3)+(Y-H/2)*(Y-H/2),W*W/81),g(X,Y),255)':b='if(gt((X-W/3)*(X-W/3)+(Y-H/2)*(Y-H/2),W*W/81),b(X,Y),255)'[r1];[b1][w1][r1][w2][b2]vstack=5 -frames:v 1 -y bg.png
再将五角星透明化,并和背景图案overlay叠加,可得朝鲜国旗ffmpeg -i star.png -i bg.png -filter_complex [0:v]colorkey=white:0.3[star2];[1:v][star2]overlay=W*325/1440:H*205/720 -frames:v 1 -y north_Korea_flag.png
维基百科草图与north_Korea_flag.png 如下:
由于此命令过长,无法将五角星等命令放置于一条命令中,可能我当前ffmpeg的版本无法解析过长的filter命令,故此国旗的制作方法拆成了三条命令
韩国
维基百科草图如下
其中白色为 #FFFFFF, 红色为 #CD2E3A, 蓝色为#0047A0, 黑色为#000000
基本思路为先在水平位置上绘制 乾卦(左上角)和坤卦(右下角),以及中心圆,随后顺时针旋转 atan(2/3)度即可
再水平方向上画出离卦(左下角)和坎卦(右上角),随后逆时针旋转atan(2/3),
最后二者叠加即可
先做乾坤离坎四卦和中心圆(未旋转)ffmpeg -f lavfi -i color=black:20x120[black];[black]split=3[b1][b2][b3];color=white:10x120[white];[white]split=2[w1][w2];[b1][w1][b2][w2][b3]hstack=5 -frames:v 1 -y Qian.png
ffmpeg -i Qian.png -vf color=white:80x10[white_strip];[0:v][white_strip]overlay=0:(11*H/24) -frames:v 1 -y Kun.png
ffmpeg -i Qian.png -vf color=white:20x10[white_strip];[0:v][white_strip]overlay=(3*W/8):(11*H/24) -frames:v 1 -y Li.png
ffmpeg -i Kun.png -vf color=black:20x10[black_strip];[0:v][black_strip]overlay=(3*W/8):(11*H/24) -frames:v 1 -y Kai.png
ffmpeg -f lavfi -i color=white:720x480[bg];[bg]geq=r='if(lt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),H*H/16),if(lt(Y,H/2),0xcd,0),r(X,Y))':g='if(lt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),H*H/16),if(lt(Y,H/2),0x2e,0x47),g(X,Y))':b='if(lt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),H*H/16),if(lt(Y,H/2),0x3a,0xa0),b(X,Y))'[c1];[c1]geq=r='if(lt((X-5*W/12)*(X-5*W/12)+(Y-H/2)*(Y-H/2),H*H/64),0xcd,r(X,Y))':g='if(lt((X-5*W/12)*(X-5*W/12)+(Y-H/2)*(Y-H/2),H*H/64),0x2e,g(X,Y))':b='if(lt((X-5*W/12)*(X-5*W/12)+(Y-H/2)*(Y-H/2),H*H/64),0x3a,b(X,Y))'[c2];[c2]geq=r='if(lt((X-7*W/12)*(X-7*W/12)+(Y-H/2)*(Y-H/2),H*H/64),0,r(X,Y))':g='if(lt((X-7*W/12)*(X-7*W/12)+(Y-H/2)*(Y-H/2),H*H/64),0x47,g(X,Y))':b='if(lt((X-7*W/12)*(X-7*W/12)+(Y-H/2)*(Y-H/2),H*H/64),0xa0,b(X,Y))' -frames:v 1 -y circle.png
之后将中心圆与乾坤卦叠加,并顺时针旋转atan(2/3)度ffmpeg -i circle.png -i Qian.png -i Kun.png -filter_complex [0:v][1:v]overlay=(10*W/72):(3*H/8)[bg1];[bg1][2:v]overlay=(54*W/72):(3*H/8)[bg2];[bg2]rotate=a=atan(2/3):fillcolor=white -frames:v 1 -y base_1.png
之后将离坎卦叠加到一起并逆时针旋转atan(2/3)度,并透明后ffmpeg -i Li.png -i Kai.png -filter_complex color=white:720x480[bg];[bg][0:v]overlay=(10*W/72):(3*H/8)[bg1];[bg1][1:v]overlay=(54*W/72):(3*H/8)[bg2];[bg2]rotate=a=(2*PI-atan(2/3)):fillcolor=white[bg3];[bg3]colorkey=white:0.35 -frames:v 1 -y base_2.png
最后将base_1.png与base_2.png叠加到一块即可ffmpeg -i base_1.png -i base_2.png -filter_complex [0:v][1:v]overlay -frames:v 1 -y South_Korea_Flag.png
最终South_Korea_Flag.png的效果如下:
蒙古~待补充
日本
预览ffplay -f lavfi -i color=white:900x600[white];[white]geq=g='if(lte((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),(H*3/10)*(H*3/10)),0,255)':b='if(lte((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),(H*3/10)*(H*3/10)),0,255)'
生成ffmpeg -f lavfi -i color=white:900x600[white];[white]geq=g='if(lte((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),(H*3/10)*(H*3/10)),0,255)':b='if(lte((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),(H*3/10)*(H*3/10)),0,255)' -frames:v 1 Japan_flag.jpg
仅供技术交流,不代表任何意识形态
说明日本国旗宽高比为3:2,中心圆的直径为高的3/5
越南
参考中国国旗的五角星一节,先画一个外圆半径为 600 的五角星(只需改color filter内部的宽高参数即可)ffplay -f lavfi -i color=ffffff00:600x600[white];[white]geq=r='if(gt(X*tan(72*PI/180),Y),r(X,Y),255)':g='if(gt(X*tan(72*PI/180),Y),g(X,Y),255)':b='if(gt(X*tan(72*PI/180),Y),b(X,Y),0)'[triangle];[triangle]split=2[T1][T2];[T2]hflip[T22];[T22][T1]hstack=2[UP];[UP]pad=iw:ih*2:0:0:ffffff00[T];[T]colorkey=white[RAW];[RAW]split=5[T1][T2][T3][T4][T5];[T2]rotate=a=(72*PI/180):c=ffffff00[R2];[T3]rotate=a=(144*PI/180):c=ffffff00[R3];[T4]rotate=a=(216*PI/180):c=ffffff00[R4];[T5]rotate=a=(288*PI/180):c=ffffff00[R5];[R2][R3]overlay[U1];[R4][R5]overlay[U2];[U1][U2]overlay[V1];[V1][T1]overlay[star];[star]geq=r='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),r(X,Y),255)':g='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),g(X,Y),255)':b='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),b(X,Y),0)'
将此五角星的非五角星的位置透明化后,与一3000x2000的矩形叠加即可ffplay -f lavfi -i color=ffffff00:600x600[white];[white]geq=r='if(gt(X*tan(72*PI/180),Y),r(X,Y),255)':g='if(gt(X*tan(72*PI/180),Y),g(X,Y),255)':b='if(gt(X*tan(72*PI/180),Y),b(X,Y),0)'[triangle];[triangle]split=2[T1][T2];[T2]hflip[T22];[T22][T1]hstack=2[UP];[UP]pad=iw:ih*2:0:0:ffffff00[T];[T]colorkey=white[RAW];[RAW]split=5[T1][T2][T3][T4][T5];[T2]rotate=a=(72*PI/180):c=ffffff00[R2];[T3]rotate=a=(144*PI/180):c=ffffff00[R3];[T4]rotate=a=(216*PI/180):c=ffffff00[R4];[T5]rotate=a=(288*PI/180):c=ffffff00[R5];[R2][R3]overlay[U1];[R4][R5]overlay[U2];[U1][U2]overlay[V1];[V1][T1]overlay[star];[star]geq=r='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),r(X,Y),255)':g='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),g(X,Y),255)':b='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),b(X,Y),0)'[s2];[s2]colorkey=white:0.3[star2];color=DA251D:3000x2000[bg];[bg][star2]overlay=3*W/10:H/5
整体转换命令为ffmpeg -f lavfi -i color=ffffff00:600x600[white];[white]geq=r='if(gt(X*tan(72*PI/180),Y),r(X,Y),255)':g='if(gt(X*tan(72*PI/180),Y),g(X,Y),255)':b='if(gt(X*tan(72*PI/180),Y),b(X,Y),0)'[triangle];[triangle]split=2[T1][T2];[T2]hflip[T22];[T22][T1]hstack=2[UP];[UP]pad=iw:ih*2:0:0:ffffff00[T];[T]colorkey=white[RAW];[RAW]split=5[T1][T2][T3][T4][T5];[T2]rotate=a=(72*PI/180):c=ffffff00[R2];[T3]rotate=a=(144*PI/180):c=ffffff00[R3];[T4]rotate=a=(216*PI/180):c=ffffff00[R4];[T5]rotate=a=(288*PI/180):c=ffffff00[R5];[R2][R3]overlay[U1];[R4][R5]overlay[U2];[U1][U2]overlay[V1];[V1][T1]overlay[star];[star]geq=r='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),r(X,Y),255)':g='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),g(X,Y),255)':b='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),b(X,Y),0)'[s2];[s2]colorkey=white:0.3[star2];color=DA251D:3000x2000[bg];[bg][star2]overlay=3*W/10:H/5 -frames:v 1 -y Vietnam_Flag.png
维基百科的国旗草图与最终生成的Vietnam_Flag.png如下:
老挝
预览ffplay -f lavfi -i color=red:1500x250[red];[red]split=2[R1][R2];color=white:1500x500[white];[white]geq=r='if(lte((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),(H*2/5)*(H*2/5)),255,0)':g='if(lte((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),(H*2/5)*(H*2/5)),255,0)'[middle];[R1][middle][R2]vstack=3
生成ffmpeg -f lavfi -i color=red:1500x250[red];[red]split=2[R1][R2];color=white:1500x500[white];[white]geq=r='if(lte((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),(H*2/5)*(H*2/5)),255,0)':g='if(lte((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),(H*2/5)*(H*2/5)),255,0)'[middle];[R1][middle][R2]vstack=3 -frames:v 1 Laos.jpg
柬埔寨~待补充
缅甸
参考中国国旗一节,先绘制外圆半径为422的黑底白色的五角星ffplay -f lavfi -i color=black:442x442[black];[black]geq=r='if(gt(X*tan(72*PI/180),Y),r(X,Y),255)':g='if(gt(X*tan(72*PI/180),Y),g(X,Y),255)':b='if(gt(X*tan(72*PI/180),Y),b(X,Y),255)'[triangle];[triangle]split=2[T1][T2];[T2]hflip[T22];[T22][T1]hstack=2[UP];[UP]pad=iw:ih*2:0:0:black[T];[T]colorkey=black[RAW];[RAW]split=5[T1][T2][T3][T4][T5];[T2]rotate=a=(72*PI/180):c=black[R2];[T3]rotate=a=(144*PI/180):c=black[R3];[T4]rotate=a=(216*PI/180):c=black[R4];[T5]rotate=a=(288*PI/180):c=black[R5];[R2][R3]overlay[U1];[R4][R5]overlay[U2];[U1][U2]overlay[V1];[V1][T1]overlay[star];[star]geq=r='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),r(X,Y),255)':g='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),g(X,Y),255)':b='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),b(X,Y),255)'
再绘制三个条纹的颜色,并与透明化后的五角星叠加,注意叠加的相对位置ffplay -f lavfi -i color=black:442x442[black];[black]geq=r='if(gt(X*tan(72*PI/180),Y),r(X,Y),255)':g='if(gt(X*tan(72*PI/180),Y),g(X,Y),255)':b='if(gt(X*tan(72*PI/180),Y),b(X,Y),255)'[triangle];[triangle]split=2[T1][T2];[T2]hflip[T22];[T22][T1]hstack=2[UP];[UP]pad=iw:ih*2:0:0:black[T];[T]colorkey=black[RAW];[RAW]split=5[T1][T2][T3][T4][T5];[T2]rotate=a=(72*PI/180):c=black[R2];[T3]rotate=a=(144*PI/180):c=black[R3];[T4]rotate=a=(216*PI/180):c=black[R4];[T5]rotate=a=(288*PI/180):c=black[R5];[R2][R3]overlay[U1];[R4][R5]overlay[U2];[U1][U2]overlay[V1];[V1][T1]overlay[star];[star]geq=r='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),r(X,Y),255)':g='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),g(X,Y),255)':b='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),b(X,Y),255)'[s2];[s2]colorkey=black:0.3[star2];color=FECB00:1800x400[Y];color=34B233:1800x400[G];color=EA2839:1800x400[R];[Y][G][R]vstack=3[bg];[bg][star2]overlay=458*W/1800:2002*H/12000
其生成命令为ffmpeg -f lavfi -i color=black:442x442[black];[black]geq=r='if(gt(X*tan(72*PI/180),Y),r(X,Y),255)':g='if(gt(X*tan(72*PI/180),Y),g(X,Y),255)':b='if(gt(X*tan(72*PI/180),Y),b(X,Y),255)'[triangle];[triangle]split=2[T1][T2];[T2]hflip[T22];[T22][T1]hstack=2[UP];[UP]pad=iw:ih*2:0:0:black[T];[T]colorkey=black[RAW];[RAW]split=5[T1][T2][T3][T4][T5];[T2]rotate=a=(72*PI/180):c=black[R2];[T3]rotate=a=(144*PI/180):c=black[R3];[T4]rotate=a=(216*PI/180):c=black[R4];[T5]rotate=a=(288*PI/180):c=black[R5];[R2][R3]overlay[U1];[R4][R5]overlay[U2];[U1][U2]overlay[V1];[V1][T1]overlay[star];[star]geq=r='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),r(X,Y),255)':g='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),g(X,Y),255)':b='if(gt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2),1468*H*H/(200*200)),b(X,Y),255)'[s2];[s2]colorkey=black:0.3[star2];color=FECB00:1800x400[Y];color=34B233:1800x400[G];color=EA2839:1800x400[R];[Y][G][R]vstack=3[bg];[bg][star2]overlay=458*W/1800:2002*H/12000 -frames:v 1 -y Myanmar_Flag.png
其维基百科的草图以及Myanmar_Flag.png如下:
注意由于浮点数的存在,五角星与背景的叠加位置只能做到相对准确
泰国
ffmpeg -f lavfi -i color=A51931:900x100[R1];color=F4F5F8:900x100[W1];color=2D2A4A:900x100[B1];[R1][W1][B1]vstack=3[up];[up]split=2[up1][up2];[up2]vflip[bottom];[up1][bottom]vstack -frames:v 1 -y Thailand_Flag.png
说明:实际转码出来发现 Thailand_Flag.png 中的颜色有色差,如要求的红色是 A51931,实际转码出来的是 A41730,目前还未找到解决的办法,可能与BT709这些转换矩阵有关
马来西亚
ffmpeg -f lavfi -i color=00803A:480x240[bt];[bt]geq=r='if(gt((X-27*W/48)*(X-27*W/48)+(Y-H/2)*(Y-H/2),H*H/9),r(X,Y),255)':g='if(gt((X-27*W/48)*(X-27*W/48)+(Y-H/2)*(Y-H/2),H*H/9),g(X,Y),255)':b='if(gt((X-27*W/48)*(X-27*W/48)+(Y-H/2)*(Y-H/2),H*H/9),b(X,Y),255)'[bt2];[bt2]geq=r='if(gt((X-30*W/48)*(X-30*W/48)+(Y-H/2)*(Y-H/2),H*H/9),r(X,Y),0)':g='if(gt((X-30*W/48)*(X-30*W/48)+(Y-H/2)*(Y-H/2),H*H/9),g(X,Y),128)':b='if(gt((X-30*W/48)*(X-30*W/48)+(Y-H/2)*(Y-H/2),H*H/9),b(X,Y),0x3A)'[fg];color=D21034:720x480[bg];[bg][fg]overlay=120:120 -frames:v 1 -y Maldives_Flag.png
先画内部的绿色矩形,然后特定圆内置为白色,再设置特定园内为绿色,随后再画外部的红色矩形,二者overlay叠加即可。
参考草图与生成的Maldives_Flag.png
欧洲篇
挪威~待补充
瑞典~待补充
芬兰~待补充
冰岛~待补充
丹麦~待补充
爱沙尼亚
预览ffplay -f lavfi -i color=0072CE:990x210[blue];color=black:990x210[black];color=white:990x210[white];[blue][black][white]vstack=3
生成ffmpeg -f lavfi -i color=0072CE:990x210[blue];color=black:990x210[black];color=white:990x210[white];[blue][black][white]vstack=3 -frames:v 1 Estonia_flag.jpg
说明
爱沙尼亚共和国国旗(英语:The National Flag of the Republic of Estonia,爱沙尼亚语:Eesti Vabariik Riigilipp),是爱沙尼亚共和国的国旗,呈长方形,长宽比为11∶7,旗面由自上而下的蓝、黑、白三色平行且面积相等的横长方形相连组成,在爱沙尼亚语中,国旗通常叫作“sinimustvalge”(意为“蓝色-黑色-白色”).Link:参考链接
拉脱维亚
预览ffplay -f lavfi -i color=9D2235:1000x200[crimson];[crimson]split=2[crimson1][crimson2];color=white:1000x100[white];[crimson1][white][crimson2]vstack=3
生成ffmpeg -f lavfi -i color=9D2235:1000x200[crimson];[crimson]split=2[crimson1][crimson2];color=white:1000x100[white];[crimson1][white][crimson2]vstack=3 -frames:v 1 Latvia_flag.jpg
说明拉脱维亚共和国国旗(英语:The National Flag of the Republic of Latvia,拉脱维亚语:Latvijas Republikas nacionālā karogs),是拉脱维亚共和国的国旗,呈长方形,长宽比为2∶1,旗面由三个自上而下的横长方形相连组成,颜色依次是深红、白色、深红,颜色分布比例为2∶1∶2,国旗上的深红色一般被称之为“拉脱维亚红”。
Link:参考链接
立陶宛
预览ffplay -f lavfi -i color=yellow:1000x200[yellow];color=green:1000x200[green];color=red:1000x200[red];[yellow][green][red]vstack=3
白俄罗斯~待补充
待补充
乌克兰
ffplay -f lavfi -i color=0057b7:900x300[blue];color=ffd700:900x300[yellow];[blue][yellow]vstack=2
Link:参考链接
摩尔多瓦~待补充
待补充
俄罗斯
预览ffplay -f lavfi -i color=white:900x200[white];color=0051BA:900x200[blue];color=D81E05:900x200[red];[white][blue][red]vstack=3
生成ffmpeg -f lavfi -i color=white:900x200[white];color=0051BA:900x200[blue];color=D81E05:900x200[red];[white][blue][red]vstack=3 -frames:v 1 Russian_flag.jpg
说明
俄罗斯联邦的国旗是横长方形的,其长和宽的比值大约为3:2 。国旗的表面由3个长方形并排组成的,主要以白色、蓝色和红色三种颜色为主。
Link:色号参考链接文章来源:https://www.toymoban.com/news/detail-798542.html
德国
ffplay -f lavfi -i color=0A0A0D:900x200[C1];color=C1121C:900x200[C2];color=EEC900:900x200[C3];[C1][C2][C3]vstack=3
Link:参考链接文章来源地址https://www.toymoban.com/news/detail-798542.html
到了这里,关于FFMPEG命令生成各国国旗的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!