在显示字幕上,往往存在无法显示中文,只支持英文的原因,本文旨在展示对此种问题的有效解决方案,若有更优结果,恳求评论留言。
txt_clip = TextClip(txt=text, fontsize=20, color='red', font=r'字体')
字体 内容为字体
首先,需要查询电脑系统的字体
from moviepy.editor import TextClip
print(TextClip.list("font"))
结果如下
['AcadEref', 'AdobeArabic-Bold', 'AdobeArabic-BoldItalic', 'AdobeArabic-Italic', 'AdobeArabic-Regular', 'AdobeFanHeitiStd-Bold', 'AdobeGothicStd-Bold', 'AdobeHebrew-Bold', 'AdobeHebrew-BoldItalic', 'AdobeHebrew-Italic', 'AdobeHebrew-Regular', 'AdobeHeitiStd-Regular', 'AdobeMingStd-Light', 'AdobeMyungjoStd-Medium', 'AdobePiStd', 'AdobeSongStd-Light', 'AdobeThai-Bold', 'AdobeThai-BoldItalic', 'AdobeThai-Italic', 'AdobeThai-Regular', 'Agency-FB', 'Agency-FB-Bold', 'AIGDT', 'Algerian', 'AmdtSymbols', 'AMGDT', 'AMGDT_IV25', 'AMGDT_IV50', 'Arial', 'Arial-Black', 'Arial-Bold', 'Arial-Bold-Italic', 'Arial-Italic', 'Arial-Narrow', 'Arial-Narrow-Bold', 'Arial-Narrow-Bold-Italic', 'Arial-Narrow-Italic', 'Arial-Rounded-MT-Bold', 'Arial-Unicode-MS', 'Artifakt-Element-Black-Italic', 'Artifakt-Element-Bold', 'Artifakt-Element-Bold-Italic', 'Artifakt-Element-Book-Italic', 'Artifakt-Element-Hair-Italic', 'Artifakt-Element-Heavy-Italic', 'Artifakt-Element-Italic', 'Artifakt-Element-Light-Italic', 'Artifakt-Element-Medium-Italic', 'Artifakt-Element-Thin-Italic', 'ArtifaktElement-Black', 'ArtifaktElement-Book', 'ArtifaktElement-Hair', 'ArtifaktElement-Heavy', 'ArtifaktElement-Light', 'ArtifaktElement-Medium', 'ArtifaktElement-Regular', 'ArtifaktElement-Thin', 'Bahnschrift', 'Bank-Gothic-Light-BT', 'Bank-Gothic-Medium-BT', 'Baskerville-Old-Face', 'Bauhaus-93', 'Bell-MT', 'Bell-MT-Bold', 'Bell-MT-Italic', 'Berlin-Sans-FB', 'Berlin-Sans-FB-Bold', 'Berlin-Sans-FB-Demi-Bold', 'Bernard-MT-Condensed', 'Blackadder-ITC', 'Bodoni-MT', 'Bodoni-MT-Black', 'Bodoni-MT-Black-Italic', 'Bodoni-MT-Bold', 'Bodoni-MT-Bold-Italic', 'Bodoni-MT-Condensed', 'Bodoni-MT-Condensed-Bold', 'Bodoni-MT-Condensed-Bold-Italic', 'Bodoni-MT-Condensed-Italic', 'Bodoni-MT-Italic', 'Bodoni-MT-Poster-Compressed', 'Book-Antiqua', 'Book-Antiqua-Bold', 'Book-Antiqua-Bold-Italic', 'Book-Antiqua-Italic', 'Bookman-Old-Style', 'Bookman-Old-Style-Bold', 'Bookman-Old-Style-Bold-Italic', 'Bookman-Old-Style-Italic', 'Bookshelf-Symbol-7', 'Bradley-Hand-ITC', 'Britannic-Bold', 'Broadway', 'Brush-Script-MT-Italic', 'Calibri', 'Calibri-Bold', 'Calibri-Bold-Italic', 'Calibri-Italic', 'Calibri-Light', 'Calibri-Light-Italic', 'Californian-FB', 'Californian-FB-Bold', 'Californian-FB-Italic', 'Calisto-MT', 'Calisto-MT-Bold', 'Calisto-MT-Bold-Italic', 'Calisto-MT-Italic', 'Cambria-&-Cambria-Math', 'Cambria-Bold', 'Cambria-Bold-Italic', 'Cambria-Italic', 'Candara', 'Candara-Bold', 'Candara-Bold-Italic', 'Candara-Italic', 'Candara-Light', 'Candara-Light-Italic', 'Cascadia-Code-Regular', 'Cascadia-Mono-Regular', 'Castellar', 'Centaur', 'Century', 'Century-Gothic', 'Century-Gothic-Bold', 'Century-Gothic-Bold-Italic', 'Century-Gothic-Italic', 'Century-Schoolbook', 'Century-Schoolbook-Bold', 'Century-Schoolbook-Bold-Italic', 'Century-Schoolbook-Italic', 'Chiller', 'CityBlueprint', 'Colonna-MT', 'Comic-Sans-MS', 'Comic-Sans-MS-Bold', 'Comic-Sans-MS-Bold-Italic', 'Comic-Sans-MS-Italic', 'Commercial-Pi-BT', 'Commercial-Script-BT', 'Complex', 'Complex_IV25', 'Complex_IV50', 'Consolas', 'Consolas-Bold', 'Consolas-Bold-Italic', 'Consolas-Italic', 'Constantia', 'Constantia-Bold', 'Constantia-Bold-Italic', 'Constantia-Italic', 'Cooper-Black', 'Copperplate-Gothic-Bold', 'Copperplate-Gothic-Light', 'Corbel', 'Corbel-Bold', 'Corbel-Bold-Italic', 'Corbel-Italic', 'Corbel-Light', 'Corbel-Light-Italic', 'CountryBlueprint', 'Courier-New', 'Courier-New-Bold', 'Courier-New-Bold-Italic', 'Courier-New-Italic', 'CourierStd', 'CourierStd-Bold', 'CourierStd-BoldOblique', 'CourierStd-Oblique', 'Curlz-MT', 'DengXian', 'DengXian-Bold', 'DengXian-Light', 'Dubai-Bold', 'Dubai-Light', 'Dubai-Medium', 'Dubai-Regular', 'Dutch-801-Bold-BT', 'Dutch-801-Bold-Italic-BT', 'Dutch-801-Extra-Bold-BT', 'Dutch-801-Italic-BT', 'Dutch-801-Roman-BT', 'Ebrima', 'Ebrima-Bold', 'Edwardian-Script-ITC', 'Elephant', 'Elephant-Italic', 'Engravers-MT', 'Eras-Bold-ITC', 'Eras-Demi-ITC', 'Eras-Light-ITC', 'Eras-Medium-ITC', 'EuroRoman', 'EuroRoman-Oblique', 'FangSong', 'Felix-Titling', 'Footlight-MT-Light', 'Forte', 'Franklin-Gothic-Book', 'Franklin-Gothic-Book-Italic', 'Franklin-Gothic-Demi', 'Franklin-Gothic-Demi-Cond', 'Franklin-Gothic-Demi-Italic', 'Franklin-Gothic-Heavy', 'Franklin-Gothic-Heavy-Italic', 'Franklin-Gothic-Medium', 'Franklin-Gothic-Medium-Cond', 'Franklin-Gothic-Medium-Italic', 'Freestyle-Script', 'French-Script-MT', 'Gabriola', 'Gadugi', 'Gadugi-Bold', 'Garamond', 'Garamond-Bold', 'Garamond-Italic', 'GDT', 'GDT_IV25', 'GDT_IV50', 'GENISO', 'Georgia', 'Georgia-Bold', 'Georgia-Bold-Italic', 'Georgia-Italic', 'Gigi', 'Gil', 'Gill-Sans-MT', 'Gill-Sans-MT-Bold', 'Gill-Sans-MT-Bold-Italic', 'Gill-Sans-MT-Condensed', 'Gill-Sans-MT-Ext-Condensed-Bold', 'Gill-Sans-MT-Italic', 'Gill-Sans-Ultra-Bold', 'Gill-Sans-Ultra-Bold-Condensed', 'Gloucester-MT-Extra-Condensed', 'GOST-2.304-81-С.4-type-A', 'GOST-2.304-81-С.6-type-B', 'GOST-Common', 'GOST-Common-Italic', 'GOST-type-A-Tekla', 'GOST-type-A-Tekla-Bold', 'GOST-type-A-Tekla-Bold-Italic', 'GOST-type-A-Tekla-Italic', 'GOST-type-B-Tekla', 'GOST-type-B-Tekla-Bold', 'GOST-type-B-Tekla-Bold-Italic', 'GOST-type-B-Tekla-Italic', 'GothicE', 'GothicG', 'GothicI', 'Goudy-Old-Style', 'Goudy-Old-Style-Bold', 'Goudy-Old-Style-Italic', 'Goudy-Stout', 'GreekC', 'GreekC_IV25', 'GreekC_IV50', 'GreekS', 'GreekS_IV25', 'GreekS_IV50', 'Haettenschweiler', 'Harlow-Solid-Italic', 'Harrington', 'High-Tower-Text', 'High-Tower-Text-Italic', 'Holo-MDL2-Assets', 'HYSWLongFangSong', 'Impact', 'Imprint-MT-Shadow', 'Informal-Roman', 'Ink-Free', 'ISOCP', 'ISOCP2', 'ISOCP2_IV25', 'ISOCP2_IV50', 'ISOCP3', 'ISOCP3_IV25', 'ISOCP3_IV50', 'ISOCP_IV25', 'ISOCP_IV50', 'ISOCPEUR', 'ISOCPEUR-Italic', 'ISOCT', 'ISOCT2', 'ISOCT2_IV25', 'ISOCT2_IV50', 'ISOCT3', 'ISOCT3_IV25', 'ISOCT3_IV50', 'ISOCT_IV25', 'ISOCT_IV50', 'ISOCTEUR', 'ISOCTEUR-Italic', 'Italic', 'Italic_IV25', 'Italic_IV50', 'ItalicC', 'ItalicT', 'Javanese-Text', 'Jokerman', 'Juice-ITC', 'KaiTi', 'Kingsoft-Phonetic', 'KozGoPr6N-Medium', 'KozMinPr6N-Regular', 'Kristen-ITC', 'KS-Mincho-&-KS-P-Mincho', 'Kunstler-Script', 'Leelawadee', 'Leelawadee-Bold', 'Leelawadee-UI', 'Leelawadee-UI-Bold', 'Leelawadee-UI-Semilight', 'Lucida-Bright', 'Lucida-Bright-Demibold', 'Lucida-Bright-Demibold-Italic', 'Lucida-Bright-Italic', 'Lucida-Calligraphy-Italic', 'Lucida-Console', 'Lucida-Fax-Demibold', 'Lucida-Fax-Demibold-Italic', 'Lucida-Fax-Italic', 'Lucida-Fax-Regular', 'Lucida-Handwriting-Italic', 'Lucida-Sans-Demibold-Italic', 'Lucida-Sans-Demibold-Roman', 'Lucida-Sans-Italic', 'Lucida-Sans-Regular', 'Lucida-Sans-Typewriter-Bold', 'Lucida-Sans-Typewriter-Bold-Oblique', 'Lucida-Sans-Typewriter-Oblique', 'Lucida-Sans-Typewriter-Regular', 'Lucida-Sans-Unicode', 'Magneto-Bold', 'Maiandra-GD', 'Malgun-Gothic', 'Malgun-Gothic-Bold', 'Malgun-Gothic-SemiLight', 'Matura-MT-Script-Capitals', 'Microsoft-Himalaya', 'Microsoft-JhengHei-&-Microsoft-JhengHei-UI', 'Microsoft-JhengHei-Bold-&-Microsoft-JhengHei-UI-Bold', 'Microsoft-JhengHei-Light-&-Microsoft-JhengHei-UI-Light', 'Microsoft-New-Tai-Lue', 'Microsoft-New-Tai-Lue-Bold', 'Microsoft-PhagsPa', 'Microsoft-PhagsPa-Bold', 'Microsoft-Sans-Serif', 'Microsoft-Tai-Le', 'Microsoft-Tai-Le-Bold', 'Microsoft-Uighur', 'Microsoft-Uighur-Bold', 'Microsoft-YaHei-&-Microsoft-YaHei-UI', 'Microsoft-YaHei-Bold-&-Microsoft-YaHei-UI-Bold', 'Microsoft-YaHei-Light-&-Microsoft-YaHei-UI-Light', 'Microsoft-Yi-Baiti', 'MingLiU-ExtB-&-PMingLiU-ExtB-&-MingLiU_HKSCS-ExtB', 'MinionPro-Regular', 'Mistral', 'Modern-No.-20', 'Mongolian-Baiti', 'Monospace-821-Bold-BT', 'Monospace-821-Bold-Italic-BT', 'Monospace-821-BT', 'Monospace-821-Italic-BT', 'Monotxt', 'Monotxt_IV25', 'Monotxt_IV50', 'Monotype-Corsiva', 'MS-Gothic-&-MS-PGothic-&-MS-UI-Gothic', 'MS-Gothic-&-MS-UI-Gothic-&-MS-PGothic', 'MS-Outlook', 'MS-Reference-Sans-Serif', 'MS-Reference-Specialty', 'MT-Extra', 'MV-Boli', 'Myanmar-Text', 'Myanmar-Text-Bold', 'MyriadCAD', 'MyriadPro-Regular', 'Niagara-Engraved', 'Niagara-Solid', 'Nirmala-UI', 'Nirmala-UI-Bold', 'Nirmala-UI-Semilight', 'OCR-A-Extended', 'Old-English-Text-MT', 'OLFSimpleSansOC-Regular', 'Onyx', 'Palace-Script-MT', 'Palatino-Linotype', 'Palatino-Linotype-Bold', 'Palatino-Linotype-Bold-Italic', 'Palatino-Linotype-Italic', 'PanRoman', 'Papyrus', 'Parchment', 'Perpetua', 'Perpetua-Bold', 'Perpetua-Bold-Italic', 'Perpetua-Italic', 'Perpetua-Titling-MT-Bold', 'Perpetua-Titling-MT-Light', 'Playbill', 'Poor-Richard', 'Pristina', 'Proxy-1', 'Proxy-2', 'Proxy-3', 'Proxy-4', 'Proxy-5', 'Proxy-6', 'Proxy-7', 'Proxy-8', 'Proxy-9', 'Rage-Italic', 'Ravie', 'Revit_HEB_DWG', 'Revit_HEB_Key', 'Revit_HEB_SHX', 'Rockwell', 'Rockwell-Bold', 'Rockwell-Bold-Italic', 'Rockwell-Condensed', 'Rockwell-Condensed-Bold', 'Rockwell-Extra-Bold', 'Rockwell-Italic', 'RomanC', 'RomanD', 'RomanS', 'RomanS_IV25', 'RomanS_IV50', 'RomanT', 'Romantic', 'Romantic-Bold', 'Romantic-Italic', 'Sans-Serif-Collection', 'SansSerif', 'SansSerif-Bold', 'SansSerif-BoldOblique', 'SansSerif-Oblique', 'Script-MT-Bold', 'ScriptC', 'ScriptS', 'ScriptS_IV25', 'ScriptS_IV50', 'Segoe-Fluent-Icons', 'Segoe-MDL2-Assets', 'Segoe-Print', 'Segoe-Print-Bold', 'Segoe-Script', 'Segoe-Script-Bold', 'Segoe-UI', 'Segoe-UI-Black', 'Segoe-UI-Black-Italic', 'Segoe-UI-Bold', 'Segoe-UI-Bold-Italic', 'Segoe-UI-Emoji', 'Segoe-UI-Historic', 'Segoe-UI-Italic', 'Segoe-UI-Light', 'Segoe-UI-Light-Italic', 'Segoe-UI-Semibold', 'Segoe-UI-Semibold-Italic', 'Segoe-UI-Semilight', 'Segoe-UI-Semilight-Italic', 'Segoe-UI-Symbol', 'Segoe-UI-Variable', 'Showcard-Gothic', 'SimHei', 'Simplex', 'Simplex_IV25', 'Simplex_IV50', 'SimSun-&-NSimSun', 'SimSun-ExtB', 'Sitka-Text', 'Sitka-Text-Italic', 'Snap-ITC', 'SolidWorks-GDT', 'Stencil', 'Stylus-BT', 'SuperFrench', 'SWAstro', 'SWComp', 'SWGDT', 'SWGothe', 'SWGothg', 'SWGothi', 'SWGrekc', 'SWGreks', 'SWIsop1', 'SWIsop2', 'SWIsop3', 'SWIsot1', 'SWIsot2', 'SWIsot3', 'Swiss-721-Black-BT', 'Swiss-721-Black-Condensed-BT', 'Swiss-721-Black-Condensed-Italic-BT', 'Swiss-721-Black-Extended-BT', 'Swiss-721-Black-Italic-BT', 'Swiss-721-Black-Outline-BT', 'Swiss-721-Bold-BT', 'Swiss-721-Bold-Condensed-BT', 'Swiss-721-Bold-Condensed-Italic-BT', 'Swiss-721-Bold-Condensed-Outline-BT', 'Swiss-721-Bold-Extended-BT', 'Swiss-721-Bold-Italic-BT', 'Swiss-721-Bold-Outline-BT', 'Swiss-721-BT', 'Swiss-721-Condensed-BT', 'Swiss-721-Condensed-Italic-BT', 'Swiss-721-Extended-BT', 'Swiss-721-Italic-BT', 'Swiss-721-Light-BT', 'Swiss-721-Light-Condensed-BT', 'Swiss-721-Light-Condensed-Italic-BT', 'Swiss-721-Light-Extended-BT', 'Swiss-721-Light-Italic-BT', 'SWItal', 'SWItalc', 'SWItalt', 'SWLink', 'SWMap', 'SWMath', 'SWMeteo', 'SWMono', 'SWMusic', 'SWRomnc', 'SWRomnd', 'SWRomns', 'SWRomnt', 'SWScrpc', 'SWScrps', 'SWSimp', 'SWTxt', 'Syastro', 'Syastro_IV25', 'Syastro_IV50', 'Sylfaen', 'Symap', 'Symap_IV25', 'Symap_IV50', 'Symath', 'Symath_IV25', 'Symath_IV50', 'Symbol', 'Symeteo', 'Symeteo_IV25', 'Symeteo_IV50', 'Symusic', 'Symusic_IV25', 'Symusic_IV50', 'Tahoma', 'Tahoma-Bold', 'Technic', 'TechnicBold', 'TechnicLite', 'Tempus-Sans-ITC', 'Times-New-Roman', 'Times-New-Roman-Bold', 'Times-New-Roman-Bold-Italic', 'Times-New-Roman-Italic', 'Trebuchet-MS', 'Trebuchet-MS-Bold', 'Trebuchet-MS-Bold-Italic', 'Trebuchet-MS-Italic', 'Tw-Cen-MT', 'Tw-Cen-MT-Bold', 'Tw-Cen-MT-Bold-Italic', 'Tw-Cen-MT-Condensed', 'Tw-Cen-MT-Condensed-Bold', 'Tw-Cen-MT-Condensed-Extra-Bold', 'Tw-Cen-MT-Italic', 'Txt', 'Txt_IV25', 'Txt_IV50', 'Universal-Math-1-BT', 'Verdana', 'Verdana-Bold', 'Verdana-Bold-Italic', 'Verdana-Italic', 'Viner-Hand-ITC', 'Vineta-BT', 'Vivaldi-Italic', 'Vladimir-Script', 'Webdings', 'Wide-Latin', 'Wingdings', 'Wingdings-2', 'Wingdings-3', 'Yu-Gothic-Bold-&-Yu-Gothic-UI-Semibold-&-Yu-Gothic-UI-Bold', 'Yu-Gothic-Light-&-Yu-Gothic-UI-Light', 'Yu-Gothic-Medium-&-Yu-Gothic-UI-Regular', 'Yu-Gothic-Regular-&-Yu-Gothic-UI-Semilight', '华文中宋', '华文仿宋', '华文宋体', '华文彩云', '华文新魏', '华文楷体', '华文琥珀', '华文细黑', '华文行楷', '华文隶书', '幼圆', '方正姚体', '方正舒体', '隶书']
在此之间,复制一个中文字体,安插在r'字体'上,代替原先的英文字体。再次运行,即可满足要求,解决问题。