问题描述
我想在视频中添加阿拉伯语注释或文本,我在 win 32 位中使用 ffmpeg 4.3.1 版,这里是我的 C# 代码:
private string AddVideo_Annotation(string text,int X,int Y)
{
try
{
string FFmpegPath = Utils.GetEXE_FFmpegPath();
string path = Utils.GetProgramPath();
//store outcome of process
var errors = new StringBuilder();
var output = new StringBuilder();
var hadErrors = false;
Process pdfprocess = new Process();
//pdfprocess.StartInfo.LoadUserProfile = true;
pdfprocess.StartInfo.RedirectStandardOutput = true;
pdfprocess.StartInfo.RedirectStandardError = true;
pdfprocess.StartInfo.UseShellExecute = false;
pdfprocess.StartInfo.FileName = FFmpegPath;
//text_shaping=1
pdfprocess.StartInfo.Arguments = "-i \""+filePath+ "\" -vf -enable-libfribidi drawtext=\"text_shaping=1:text=\'" + text+ "\':x=" + X+":y="+Y+ ":fontsize=24:fontcolor=Red\" -c:a copy \"" + path + "\\out.mp4\"";
//pdfprocess.StartInfo.WorkingDirectory = @"C:\Program Files\LibreOffice\program\";
pdfprocess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
pdfprocess.EnableRaisingEvents = true;
// capture normal output
pdfprocess.OutputDataReceived += (s,d) => {
output.Append(d.Data);
};
// Capture error output
pdfprocess.ErrorDataReceived += (s,d) => {
if (!hadErrors)
{
hadErrors = !String.IsNullOrEmpty(d.Data);
}
errors.Append(d.Data);
};
pdfprocess.Start();
pdfprocess.BeginErrorReadLine();
pdfprocess.BeginoutputReadLine();
try
{
while (pdfprocess.MainWindowHandle == IntPtr.Zero)
{
// discard cached information about the process
// because MainWindowHandle might be cached.
pdfprocess.Refresh();
Thread.Sleep(200);
}
}
catch { }
Thread.Sleep(2000);
pdfprocess.WaitForExit();
while ((Process.GetProcessesByName("ffmpeg").Length > 0))
{
Thread.Sleep(200);
}
string stderr = errors.ToString();
if (pdfprocess.ExitCode != 0)
{
//MessageBox.Show("error:" + stderr);
throw new Exception("FFmpeg.exe has exit wit code " + pdfprocess.ExitCode+"\n"+ stderr);
}
return path + "\\out"+new FileInfo( filePath).Extension;
}
catch(Exception ex)
{
TXT_AnnotationText.Text = ex.Message + "\n" + ex.StackTrace.ToString();
MessageBox.Show(ex.Message + "\n" + ex.StackTrace.ToString());
throw ex;
}
}
我收到此错误消息:
FFmpeg.exe 已退出机智代码 1
ffmpeg 版本 4.3.1 版权所有 (c) 2000-2020 FFmpeg 开发人员使用 gcc 10.2.1 (GCC) 20200726 配置构建:--enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable -gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable- libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable- libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable- libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libgsm --disable-w32threads --enable-libmfx --enable-ffnvcodec -- enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable -avisynth --enable-libopenmpt --enable-amf libavutil 56. 51.100 / 56. 51.100 libavcodec 58. 91.100 / 58. 91.100 libavformat 58. 45.100 / 58. 45.100 / 56. 51.100 libavcodec . . 85.100 libswscale 5. 7.100 / 5. 7.100 libswresample 3. 7.100 / 3. 7.100 libpostproc 55. 7.100 / 55. 7.100Input #0,mov,mp4,m4a,3gp,jp,2g ':元数据:major_brand:mp42 minor_version:0 compatible_brands:isommp42 creation_time:2020-12-02T01:57:02.000000Z 持续时间:00:01:37.70,开始:0.000000,#Stream0012,比特率:0 ): 视频: h264 (Main) (avc1 / 0x31637661),yuv420p(tv),1280x662 [SAR 1:1 DAR 640:331],124 kb/s,30 fps,30 tbr,36k (default)tbn元数据:creation_time:2020-12-02T01:57:03.000000Z handler_name:Mainconcept MP4 视频媒体处理程序编码器:AVC 编码[NULL @ 05d306c0] 无法找到合适的“drawtext=t”输出格式ext_shaping=1:text='ظٹظ„ظٹظٹظ„ ظٹظ„ظٹط¨ظ„':x=200:y=200:fontsize=24:fontcolor=Red'drawtext=text_shaping=1:text='„ظٹظفٹظظ„ ظٹط¨ظ„':x=200:y=200:fontsize=24:fontcolor=Red:参数无效
在 EasyWhatsappSender.UserControls.UControl_VideoAudioPreview_Annotation.AddVideo_Annotation(String text,Int32 X,Int32 Y) 在 C:\Users\FathBakri\Documents\Visual Studio 2017\Projects\MediaViewer\UserControls\UControl_VideoAudioPreview_Annotation239line:
当我使用 text_shaping=1 时会发生错误,如果我省略它并使用阿拉伯文本,它会显示在符号中并且不正确
如何修复它。感谢帮助
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)