使用MoviePy进行音视频剪辑时,如果出现TextClip

Python 专栏收录该内容
¥99.90 ¥299.90
418篇文章

使用MoviePy进行音视频剪辑时,如果出现TextClip.list或search搜索字体报错UnicodeDecodeError:utf codec cannott decode byte问题,这通常是由于字体文件编码格式不支持所导致的。本篇文章将为您提供解决这一问题的方法和相应的Python源代码。

在使用MoviePy进行文字添加时,我们经常需要使用TextClip.list和search搜索字体来获取系统中可用的字体列表。但是,在某些情况下,当使用某些字体时会遇到UnicodeDecodeError错误。这个问题通常是由于字体文件编码格式不支持导致的。

以下是解决该问题的步骤:

  1. 找到所需字体文件

首先需要找到所需的字体文件,可以在Windows系统下打开“控制面板”->“外观和个性化”->“字体”,在MAC系统下打开“字体册”查看。找到后将字体文件复制到Python项目所在目录下。

  1. 安装fonttools

使用pip命令安装fonttools库,如果您已经安装过,则可以跳过此步骤。

pip install fonttools
  1. 解析字体文件

使用fonttools库解析字体文件,获取字体名称和编码格式。以下是相应的Python源代码:

from fontTools
使用Moviepy时执行TextClip 然后,我们使用encode()方法将字符串“world”转换为字节序列,并将其传递给search()方法进行匹配。使用Moviepy时执行TextClip.search方法时遇到TypeError错误:需要类字节对象而不是字符串。这可能是由于search方法的参数需要通过bytes()函数将字符串转换为字节序列才能进行匹配。解决该错误可以在调用search方法时使用bytes()函数将字符串转换为字节序列。如果使用过程中还有其他问题,请参考Moviepy官方文档或者查看相关的代码示例。 阅读详情

相关推荐

Moviepy模块之视频添加文本水印

Moviepy模块之视频添加文本水印。

业余Python爱好者 2464

MoviePy音视频剪辑:解决UnicodeDecodeError异常问题

通过对MoviePy库的源代码进行修改,我们可以解决使用TextClip.list和search方法时可能出现的UnicodeDecodeError异常。在修改后的源代码中,我们使用了适当的解码方式来处理具有特殊字符的字体名称,从而避免了编码错误。该异常的原因是在搜索字体时,MoviePy尝试解码具有特殊字符的字体名称,但解码过程中出现了编码错误。这是一个简单的示例,演示了如何使用修复后的MoviePy库创建文本剪辑。保存对源代码文件的修改,并重新运行使用MoviePy库的代码以测试修复后的版本。

CyberLynxO的博客 276

moviepy音视频剪辑:视频基类VideoClip子类DataVideoClip、UpdatedVideoClip、ImageClip、ColorClip、TextClip及使用案例

一、概述 在《moviepy音视频剪辑:moviepy中的剪辑相关类及关系》介绍了剪辑相关类及关系,其中VideoClip有多个直接子类和间接子类。 本文中将介绍的DataVideoClip、UpdatedVideoClip、ImageClip、ColorClip、TextClip都是VideoClip的子类,其中DataVideoClip、UpdatedVideoClip在前面文中未进行介绍,之所以将这几个类在此一并介绍,是因为这几个类都在VideoClip类相同的模块文件VideoClip.py中。 二

老猿Python 2171

Aix升级和安装ssh配置过程

Aix升级和安装ssh配置过程Aix升级和安装ssh配置过程配置前背景配置步骤 Aix升级和安装ssh配置过程 部门IBM小型机的Aix操作系统需要进行ssh补丁修复,修复其实就是ssh版本你的升级,对升级的过程和中途遇到的问题做了记录如下。 配置前背景 操作系统: gdboss2/>uname -u //操作系统的Aix5.3 IBM,020693E5P gdboss2/&gt...

阿阿阿唱的博客 2995

博图Advanced实战:VB脚本实现HMI画面智能弹出(附完整代码解析)

本文详细介绍了在西门子博图Advanced平台中利用VB脚本实现HMI画面智能弹出的实战方法。通过动态计算坐标、分辨率自适应方案和完整代码解析,帮助工程师解决不同显示环境下的定位难题,提升工业自动化界面的交互体验。

weixin_29041767的博客 347

liquibase扩展支持达梦数据库

近期项目中需要支持国产数据库,需要liquibase底层支持达梦数据库,记录下操作的详细步骤以便分享。 1.liquibase支持的数据库很多如MySQL, PostgreSQL, Oracle, Sql Server, DB2。但是达梦数据库并不支持,所以需要新建DMDatabase类来适配达梦数据库。达梦语法和Oracle很像所以只需要复制liquibase-core下的Oracle Database做些修改就可了。以下为需要修改的地方 public class DMDatabase extends A

qq_43677719的博客 5476

C#创建COM组件,QT调用COM组件简单测试(VS2008+QT4.6.4)

一. C#创建组件: 1. VS2008新建一个项目,选择Visual C#, Class library 修改Properties下面的AssemblyInfo.cs文件,ComVisible属性设置为True,即:[assembly: ComVisible(true)] 2. 右击项目,选择“属性”, 选择“生成”选项卡,把“为COM互操作注册”勾选上 选择“签名”选项卡,把“

3520

【AI Agent教程】各种Agent开发框架都是如何实现ReAct思想的?深入源码学习一下

驱动大模型有很多种方式,例如纯Prompt方式、思维链方式、ReAct方式等。ReAct 方式是 AI Agent 最常用的实现思路之一,它强调在执行任务时结合推理(Reasoning)和行动(Acting)两个方面,使得Agent能够在复杂和动态的环境中更有效地工作。

同学小张的博客 6403

27、自闭症儿童治疗与玩具设计研究

本研究探讨了自闭症儿童的治疗方法与玩具设计之间的关联,分析了游戏疗法、音乐疗法和职业疗法等在治疗中的应用,并介绍了多种针对自闭症儿童的治疗玩具案例。通过用户研究和多学科合作,提出了以Pro-Ability为核心的设计理念,开发了结合音乐疗法和精细运动训练的智能玩具套件。研究总结了当前成果与局限性,并展望了未来发展方向,旨在为自闭症儿童提供更有效的康复支持。

keras9composer的博客 214

SAP_SD模块深度解析SAP信用检查中的“未清数量”取值逻辑

确认数量 vs 订单数量:如果系统配置了可用性检查(ATP),并且订单只确认了部分数量,信用检查通常只占用已确认数量的额度(具体取决于信用组的配置)。在SAP中,未清订单数量的计算并非简单读取订单行项目的目标数量(VBAK-KWMENG),而是基于**计划行(Schedule Lines)**层级来汇总的。状态的转换点:当交货单创建(VL01N)并保存时,这部分数量对应订单的“未清订单数量”减少,“未清交货数量”增加。业务人员眼中的未清数量很简单:“我卖了100个,发了30个,未清就是70个”。

我小时候很黑的博客 319

Geogebra中级篇016—矩阵(Matrices)

在GeoGebra中,矩阵是一种强大的工具,广泛应用于线性代数、几何变换和数据处理等领域。通过矩阵,我们可以轻松实现复杂的计算和图形变换,如旋转、平移和缩放等操作。不仅如此,GeoGebra的矩阵功能还支持多种运算,如加法、乘法、求逆等,使得用户能够高效地处理线性方程组和向量空间问题。在本文中,我们将深入探讨GeoGebra中的矩阵功能,详细介绍如何创建矩阵、执行常见的矩阵运算,并通过实例展示这些操作在数学和工程应用中的实际价值。这篇文章将为你提供关于GeoGebra矩阵操作的全面指南。

八荒启-交互动画的博客 2590

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

上一篇: 使用Python查看数据集中指定层级的列索引内容
下一篇: Python实现自动化购买茅台
普通网友
博客等级 码龄4年 641粉丝 1373原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

code_welike

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值