private void LoadFrame(int frame) { double pos = (double)frame / totalFrame * video.Metadata.Duration.TotalSeconds; var options = new MediaToolkit.Options.ConversionOptions { Seek = TimeSpan.FromSeconds(pos) }; if (image != null) { image.Dispose(); System.IO.File.Delete("temp.jpg"); } try { var outputFile = new MediaToolkit.Model.MediaFile { Filename = "temp.jpg" }; engine.GetThumbnail(video, outputFile, options); LoadImage("temp.jpg"); toolStripStatusLabel3.Text = frame.ToString() + "/" + maxFrame.ToString(); curFrame = frame; int percent = (int)(100 * (double)frame / maxFrame); trackBar3.Value = percent; label6.Text = percent.ToString() + "%"; } catch (Exception) { // TODO: } }
public void laconversion2(string titulo) { if (cancelado == false) { this.Invoke((MethodInvoker) delegate { this.pictureBox2.Visible = false; }); var inputfile = new MediaToolkit.Model.MediaFile { Filename = Path.Combine(direccion, titulo.Replace(".mp3", ".mp4")) }; var outputfile = new MediaToolkit.Model.MediaFile { Filename = Path.Combine(direccion, titulo) }; MediaToolkit.Options.ConversionOptions prro = new MediaToolkit.Options.ConversionOptions(); prro.VideoFps = 0; prro.CustomHeight = 0; prro.CustomWidth = 0; prro.VideoAspectRatio = MediaToolkit.Options.VideoAspectRatio.R3_2; using (var engine = new MediaToolkit.Engine()) { engine.CustomCommand("-threads 1"); engine.GetMetadata(inputfile); engine.Convert(inputfile, outputfile); } File.Delete(Path.Combine(direccion, titulo.Replace(".mp3", ".mp4"))); // var aaa = new NReco.VideoConverter.FFMpegConverter(); // aaa.ConvertMedia(Path.Combine(direccion, RemoveIllegalPathCharacters(videox.Title) ) + ".mp3", Path.Combine(direccion, RemoveIllegalPathCharacters(videox.Title) ) + ".mp33", "mp3"); // File.Delete(Path.Combine(direccion, RemoveIllegalPathCharacters(videox.Title) ) + ".mp3"); // File.Move(Path.Combine(direccion, RemoveIllegalPathCharacters(videox.Title)) + ".mp33", Path.Combine(direccion, RemoveIllegalPathCharacters(videox.Title)) + ".mp3"); // File.Delete(Path.Combine(direccion, RemoveIllegalPathCharacters(videox.Title)) + ".mp33"); this.Invoke((MethodInvoker) delegate { this.pictureBox2.Visible = true; this.pictureBox2.Location = new Point(37, 114); this.pictureBox3.Visible = true; this.pictureBox3.Location = new Point(7, 114); }); } }
public static void Remux( string targetName, string sourceName, string tempName ) { Directory.CreateDirectory( Path.GetDirectoryName( targetName ) ); Console.WriteLine( "Remuxing to " + targetName + "..." ); var inputFile = new MediaToolkit.Model.MediaFile( sourceName ); var outputFile = new MediaToolkit.Model.MediaFile( tempName ); using ( var engine = new MediaToolkit.Engine( "ffmpeg.exe" ) ) { MediaToolkit.Options.ConversionOptions options = new MediaToolkit.Options.ConversionOptions(); options.AdditionalOptions = "-codec copy -bsf:a aac_adtstoasc"; engine.Convert( inputFile, outputFile, options ); } Util.MoveFileOverwrite( tempName, targetName ); Console.WriteLine( "Created " + targetName + "!" ); }