예제 #1
0
        private async void ButtonConvertEAC_Click(object sender, RoutedEventArgs e)
        {
            this.InputFile = SelectFile(this.InputFile);
            if (string.IsNullOrWhiteSpace(this.InputFile))
            {
                return;
            }

            var outputFile = Path.Combine(Path.GetDirectoryName(InputFile), Path.GetFileNameWithoutExtension(InputFile) + "_ConvertAC3" + Path.GetExtension(InputFile));

            using (var ffmpeg = new FFmpeg(FFmpegFileName))
            {
                ffmpeg.OnProgress  += OnProgressEvent;
                ffmpeg.OnCompleted += OnCompletedEvent;
                ffmpeg.OnData      += (s, args) => { OutputText(args.Data); };

                OutputText("***Start convert eac");

                try
                {
                    using (this.CancellationTokenSource = new CancellationTokenSource())
                    {
                        var token = this.CancellationTokenSource.Token;
                        await Task.Run(() => ffmpeg.ConvertAudioToAC3(this.InputFile, outputFile, 0, 640000, 48000, token), token);
                    }
                }
                catch (OperationCanceledException)
                {
                    OutputText("***Operation cancelled *****");
                }
                catch (FFmpegException fe)
                {
                    OutputText(fe.Message + (fe.InnerException == null ? "" : ", " + fe.InnerException.Message));
                }

                OutputText("***Ready convert eac");
            }
        }