示例#1
0
        private void ConversionWork(object opt)
        {
            ConversionOption conversionOption = opt as ConversionOption;
            string           invokeString     = conversionOption.GetInvokeString(filePath);

            if (File.Exists(conversionOption.OutputPath))
            {
                if (conversionOption.ConflictFileOption == OverwriteOption.OverWrite)
                {
                    File.Delete(conversionOption.OutputPath);
                }
            }

            int  retry  = 0;
            bool bRetry = false;

            do
            {
                bRetry = false;
                ProcessStartInfo sInfo = ConvertToProcessStartInfo(invokeString);
                using (FFmpegProcess = Process.Start(sInfo))
                {
                    if (FFmpegProcess == null)
                    {
                        throw new InvalidOperationException("Cannot start ffmpeg executable");
                    }
                    progress = 0.0f;
                    while (!(FFmpegProcess.HasExited && FFmpegProcess.StandardError.EndOfStream))
                    {
                        string line = FFmpegProcess.StandardError.ReadLine();
                        if (line != null && line.Contains("Video encoding failed"))
                        {
                            bRetry = true;
                            retry++;
                            //delete corrupted
                            File.Delete(conversionOption.OutputPath);
                        }
                        FFmpegProcess_Process_Output(line);
                    }

                    if (retry > 5)
                    {
                        break;
                    }
                }
            } while (bRetry);
            isWorkCompleted = true;
            progress        = 100.0f;
            dtComplete      = DateTime.Now;
            ConversionCompleteEventArgs convertCompleteEvent = new ConversionCompleteEventArgs(new TimeSpan(), new TimeSpan(), 0, 0.0, 0, 0.0);

            OnConversionCompleted?.Invoke(this, convertCompleteEvent);

            PrintDebug();
        }
示例#2
0
 public ConversionOption(ConversionOption conversionOption)
 {
     this.videoOption = conversionOption.videoOption.Clone() as VideoOption;
     this.audioOption = conversionOption.audioOption.Clone() as AudioOption;
     this.outputPath  = conversionOption.outputPath.Clone().ToString();
 }
示例#3
0
 public VideoConvertTask(int taskID, string file, string outputPath)
     : base(taskID, file)
 {
     conversionOption = new ConversionOption(GetMetaData(), outputPath);
 }
示例#4
0
 public void Start(ConversionOption opt)
 {
     conversionThread = new Thread(ConversionWork);
     conversionThread.Start(opt);
     dtStart = DateTime.Now;
 }
示例#5
0
 private void ConversionOption2Setting(ConversionOption opt)
 {
     this.numericUpDown_width.Value  = opt.VideoOption.Width;
     this.numericUpDown_height.Value = opt.VideoOption.Height;
 }