public static void Concat(IList<string> files) { if(!ffmpegPresent() || !ffprobePresent()) return; try { CommandLineBuilder builder = null; using(ConcatSelector cs = new ConcatSelector()) { if(files != null) { int j = 0; for(int i = 0; i < files.Count && j < 3; i++) { if(!string.IsNullOrWhiteSpace(files[i])) { if(File.Exists(files[i]) && MediaInfo.Check(files[i], null, null)) { cs.SetSelection(i, files[i]); if(j++ == 0) cs.Lock1stLine(); } } } } if(cs.ShowDialog() != DialogResult.OK) return; builder = cs.Builder; // Choix du format de sortie using(FormatSelector fs = new FormatSelector( builder, cs.Mode == ConcatMode.Audio ? Common.GetVideoFormats(new MediaFormat[] { MediaFormat.DEFAULT }) : Common.GetAudioFormats(new MediaFormat[] { MediaFormat.DEFAULT }), new VideoEncoding[] { VideoEncoding.COPY, VideoEncoding.DEFAULT, VideoEncoding.NOVIDEO }, new AudioEncoding[] { AudioEncoding.COPY, AudioEncoding.DEFAULT, AudioEncoding.NOAUDIO }) ) { if(cs.Mode == ConcatMode.Video) fs.DisableAudio(); if(cs.Mode == ConcatMode.Audio) fs.DisableVideo(); if(fs.ShowDialog() != DialogResult.OK) return; } } SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Tout type de fichier media|*.*"; if(sfd.ShowDialog() != DialogResult.OK) return; string str = builder.Output(sfd.FileName); LogWindow lw = new LogWindow(); lw.Show(); using(Process p = new Process()) { ProcessStartInfo psi = new ProcessStartInfo(Common.ffmpeg, str); psi.UseShellExecute = false; psi.CreateNoWindow = true; psi.RedirectStandardError = true; p.StartInfo = psi; p.Start(); string line; while ((line = p.StandardError.ReadLine()) != null) { lw.Log(line); Application.DoEvents(); } p.WaitForExit(); } lw.Log("\r\n---------------------------------------------\r\nFin de l'opération\r\n---------------------------------------------"); lw.CanBeClosed = true; } catch(Exception ex) { MessageBox.Show(ex.Message); MessageBox.Show(ex.StackTrace); } }
public static void Concat(IList <string> files) { if (!ffmpegPresent() || !ffprobePresent()) { return; } try { CommandLineBuilder builder = null; using (ConcatSelector cs = new ConcatSelector()) { if (files != null) { int j = 0; for (int i = 0; i < files.Count && j < 3; i++) { if (!string.IsNullOrWhiteSpace(files[i])) { if (File.Exists(files[i]) && MediaInfo.Check(files[i], null, null)) { cs.SetSelection(i, files[i]); if (j++ == 0) { cs.Lock1stLine(); } } } } } if (cs.ShowDialog() != DialogResult.OK) { return; } builder = cs.Builder; // Choix du format de sortie using (FormatSelector fs = new FormatSelector( builder, cs.Mode == ConcatMode.Audio ? Common.GetVideoFormats(new MediaFormat[] { MediaFormat.DEFAULT }) : Common.GetAudioFormats(new MediaFormat[] { MediaFormat.DEFAULT }), new VideoEncoding[] { VideoEncoding.COPY, VideoEncoding.DEFAULT, VideoEncoding.NOVIDEO }, new AudioEncoding[] { AudioEncoding.COPY, AudioEncoding.DEFAULT, AudioEncoding.NOAUDIO }) ) { if (cs.Mode == ConcatMode.Video) { fs.DisableAudio(); } if (cs.Mode == ConcatMode.Audio) { fs.DisableVideo(); } if (fs.ShowDialog() != DialogResult.OK) { return; } } } SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Tout type de fichier media|*.*"; if (sfd.ShowDialog() != DialogResult.OK) { return; } string str = builder.Output(sfd.FileName); LogWindow lw = new LogWindow(); lw.Show(); using (Process p = new Process()) { ProcessStartInfo psi = new ProcessStartInfo(Common.ffmpeg, str); psi.UseShellExecute = false; psi.CreateNoWindow = true; psi.RedirectStandardError = true; p.StartInfo = psi; p.Start(); string line; while ((line = p.StandardError.ReadLine()) != null) { lw.Log(line); Application.DoEvents(); } p.WaitForExit(); } lw.Log("\r\n---------------------------------------------\r\nFin de l'opération\r\n---------------------------------------------"); lw.CanBeClosed = true; } catch (Exception ex) { MessageBox.Show(ex.Message); MessageBox.Show(ex.StackTrace); } }