private static void Process_Exited(object sender, EventArgs e) { ProcessPuls P = (ProcessPuls)sender; InfoLog.InfoPrintf("转码任务完成:" + P.StartInfo.Arguments, InfoLog.InfoClass.载必要提示); if (MMPU.转码后自动删除文件) { MMPU.文件删除委托(P.OriginalVideoFilename, "转码完成自动,删除原始文件"); } }
/// <summary> /// 调用ffmpeg修复阿B的傻逼时间轴,顺便封装成MP4 /// </summary> /// <param name="Filename">转码文件</param> public static void 转码(string Filename) { if (MMPU.转码功能使能) { try { ProcessPuls process = new ProcessPuls(); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { process.StartInfo.FileName = "./libffmpeg/ffmpeg.exe"; } else { process.StartInfo.FileName = "ffmpeg"; } process.StartInfo.Arguments = "-i " + Filename + " -vcodec copy -acodec copy " + Filename.Replace(".flv", "") + ".mp4"; process.StartInfo.UseShellExecute = false; process.StartInfo.CreateNoWindow = true; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardInput = true; process.StartInfo.RedirectStandardError = true; process.EnableRaisingEvents = true; process.ErrorDataReceived += new DataReceivedEventHandler(Output); // 捕捉ffmpeg.exe的信息 DateTime beginTime = DateTime.Now; process.Start(); process.BeginErrorReadLine(); // 开始异步读取 process.Exited += Process_Exited; GC.Collect(); } catch (Exception) { } } else { GC.Collect(); } }