ffmpeg # macOS 添加drawtext支持
程序员文章站
2022-06-30 10:48:33
...
brew install freetype
brew install fontconfig
brew install fribidi
查看安装之后,可以用brew info查看安装信息。比如:
localhost:FFmpeg Private$ brew info freetype
freetype: stable 2.10.0 (bottled)
Software library to render fonts
https://www.freetype.org/
/usr/local/Cellar/freetype/2.10.0 (61 files, 2.3MB) *
Poured from bottle on 2019-03-30 at 22:43:32
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/freetype.rb
==> Dependencies
Required: libpng ✔
==> Analytics
install: 190,060 (30 days), 402,661 (90 days), 1,470,828 (365 days)
install_on_request: 9,541 (30 days), 17,319 (90 days), 67,023 (365 days)
build_error: 0 (30 days)
可以看到freetype的作用是: Software library to render fonts, 版本是: stable 2.10.0
然后编译时加入:
--enable-libfreetype \
--enable-libfontconfig \
--enable-libfribidi \
后续就可以利用:
-vf drawtext=fontcolor=white:fontsize=40:text='Hello World':x=0:y=100
来添加文字,默认文字是: "/Library/Fonts/Microsoft/Verdana.ttf",等价于:
-vf drawtext=fontcolor=white:fontsize=40:text='Hello World':x=0:y=100:fontfile='/Library/Fonts/Microsoft/Verdana.ttf'
可以用fontfile来指定特定字体,字体存放在"/Library/Fonts/Microsoft/"中:
localhost:FFmpeg Private$ ls /Library/Fonts/Microsoft/
Abadi MT Condensed Extra Bold Kaiti.ttf
Abadi MT Condensed Light Kino
Andale Mono Lucida Blackletter
Arial Black Lucida Bright
Arial Bold Italic.ttf Lucida Calligraphy
Arial Bold.ttf Lucida Console.ttf
Arial Italic.ttf Lucida Fax
Arial Narrow Lucida Handwriting
Arial Rounded Bold Lucida Sans
Arial.ttf Lucida Sans Typewriter
Baskerville Old Face Lucida Sans Unicode.ttf
Batang.ttf MS Gothic.ttf
Bauhaus 93 MS Mincho.ttf
Bell MT MS PGothic.ttf
Bernard MT Condensed MS PMincho.ttf
Book Antiqua MS Reference Sans Serif.ttf
Bookman Old Style MS Reference Specialty.ttf
Bookshelf Symbol 7.ttf MT Extra
Braggadocio Marlett.ttf
Britannic Bold Matura Script Capitals
Brush Script.ttf Meiryo Bold Italic.ttf
Calibri Bold Italic.ttf Meiryo Bold.ttf
Calibri Bold.ttf Meiryo Italic.ttf
Calibri Italic.ttf Meiryo.ttf
Calibri.ttf Microsoft Yahei.ttf
Calisto MT MingLiU-ExtB.ttf
Cambria Bold Italic.ttf MingLiU.ttf
Cambria Bold.ttf MingLiU_HKSCS-ExtB.ttf
Cambria Italic.ttf Mistral
Cambria Math.ttf Modern No. 20
Cambria.ttf Monotype Corsiva
Candara Bold Italic.ttf Monotype Sorts
Candara Bold.ttf News Gothic MT
Candara Italic.ttf Onyx
Candara.ttf PMingLiU-ExtB.ttf
Century PMingLiU.ttf
Century Gothic Palatino Linotype Bold Italic.ttf
Century Schoolbook Palatino Linotype Bold.ttf
Colonna Palatino Linotype Italic.ttf
Comic Sans MS Palatino Linotype.ttf
Consolas Bold Italic.ttf Perpetua Bold Italic.ttf
Consolas Bold.ttf Perpetua Bold.ttf
Consolas Italic.ttf Perpetua Italic.ttf
Consolas.ttf Perpetua Titling MT
Constantia Bold Italic.ttf Perpetua.ttf
Constantia Bold.ttf Playbill
Constantia Italic.ttf Rockwell
Constantia.ttf Rockwell Extra Bold
Cooper Black STHUPO.TTF
Copperplate Gothic Bold STLITI.ttf
Copperplate Gothic Light STXINGKA.ttf
Corbel Bold Italic.ttf STXINWEI.ttf
Corbel Bold.ttf STZHONGS.ttf
Corbel Italic.ttf SimHei.ttf
Corbel.ttf SimSun-ExtB.ttf
Curlz MT SimSun.ttf
Desdemona Stencil
Edwardian Script ITC Tahoma
Engravers MT TaiLeb.ttf
Eurostile Times New Roman Bold Italic.ttf
Fangsong.ttf Times New Roman Bold.ttf
Footlight Light Times New Roman Italic.ttf
Franklin Gothic Book Italic.ttf Times New Roman.ttf
Franklin Gothic Book.ttf Trebuchet MS
Franklin Gothic Medium Italic.ttf Tw Cen MT Bold Italic.ttf
Franklin Gothic Medium.ttf Tw Cen MT Bold.ttf
Gabriola.ttf Tw Cen MT Italic.ttf
Garamond Tw Cen MT.ttf
Georgia Verdana Bold Italic.ttf
Gill Sans MT Bold Italic.ttf Verdana Bold.ttf
Gill Sans MT Bold.ttf Verdana Italic.ttf
Gill Sans MT Italic.ttf Verdana.ttf
Gill Sans MT.ttf Wide Latin
Gill Sans Ultra Bold Wingdings 2.ttf
Gloucester MT Extra Condensed Wingdings 3.ttf
Goudy Old Style Wingdings.ttf
Gulim.ttf himalaya.ttf
Haettenschweiler mingliu_hkscs.ttf
Harrington monbaiti.ttf
Impact msyi.ttf
Imprint MT Shadow taile.ttf