public static void Run() { //set up ffmpeg command configuration with locations of default output folders, ffmpeg, and ffprobe. ResourceManagement.CommandConfiguration = CommandConfiguration.Create( @"c:\source\ffmpeg\bin\temp", @"c:\source\ffmpeg\bin\ffmpeg.exe", @"c:\source\ffmpeg\bin\ffprobe.exe"); //create a factory var factory = CommandFactory.Create(); //create a command adding a video and audio file var command = factory.CreateOutputCommand() .AddInput(Assets.Utilities.GetVideoFile()) .AddInput(Assets.Utilities.GetAudioFile()); //select the first two streams from the input command var splitVideo = command.Take(0) .Filter(Filterchain.FilterTo <VideoStream>(new Split(2))); var splitAudio = command.Take(1) .Filter(Filterchain.FilterTo <AudioStream>(new ASplit(2))); //map the first audio and video stream to the output command.Select(splitVideo.Take(0), splitAudio.Take(0)) .MapTo <Mp4>(@"c:\source\ffmpeg\bin\temp\foo.mp4", SettingsCollection.ForOutput(new OverwriteOutput())); command.Select(splitVideo.Take(1), splitAudio.Take(1)) .MapTo <Mp4>(@"c:\source\ffmpeg\bin\temp\bar.mp4", SettingsCollection.ForOutput(new OverwriteOutput())); //render the output factory.Render(); }
public static void Run() { //set up ffmpeg command configuration with locations of default output folders, ffmpeg, and ffprobe. ResourceManagement.CommandConfiguration = CommandConfiguration.Create( @"c:\source\ffmpeg\bin\temp", @"c:\source\ffmpeg\bin\ffmpeg.exe", @"c:\source\ffmpeg\bin\ffprobe.exe"); //create a factory var factory = CommandFactory.Create(); //set up the output and input settings var inputSettings = SettingsCollection.ForInput(new SeekPositionInput(1d)); var outputSettings = SettingsCollection.ForOutput( new BitRateVideo(3000), new DurationOutput(10d)); //create a command adding a two audio files var command = factory.CreateOutputCommand(); var output = command.WithInput <VideoStream>(Utilities.GetVideoFile(), inputSettings) .To <Mp4>(@"c:\source\ffmpeg\bin\temp\foo.mp4", outputSettings) .First(); //use the metadata helper calculation engine to determine a snapshot of what the output duration should be. var metadataInfo = MetadataHelpers.GetMetadataInfo(command, output.GetStreamIdentifier()); System.Console.ForegroundColor = ConsoleColor.DarkMagenta; Console.WriteLine("Metadata snapshot:"); Console.WriteLine(string.Format("Duration: {0}", metadataInfo.VideoStream.VideoMetadata.Duration)); Console.WriteLine(string.Format("Has Video: {0}", metadataInfo.HasVideo)); Console.WriteLine(string.Format("Has Audio: {0}", metadataInfo.HasAudio)); System.Console.ForegroundColor = ConsoleColor.White; }
public void RenderVideoWEffects() { #if DEBUG ResourceManagement.CommandConfiguration = CommandConfiguration.Create( "c:/source/ffmpeg/bin/temp", "c:/source/ffmpeg/bin/ffmpeg.exe", "c:/source/ffmpeg/bin/ffprobe.exe"); var outputSettings = SettingsCollection.ForOutput( new OverwriteOutput(), new CodecVideo(VideoCodecType.Libx264), new BitRateVideo(3000), new BitRateTolerance(3000), new FrameRate(30)); var factory = CommandFactory.Create(); factory.CreateOutputCommand() .WithInput <VideoStream>(Assets.Utilities.GetVideoFile()) .WithInput <VideoStream>(Assets.Utilities.GetVideoFile()) .Filter(new CrossfadeConcatenate(1)) .MapTo <Mp4>("c:/source/ffmpeg/bin/temp/output-test.mp4", outputSettings); factory.Render(); #endif }
public static void Run() { //set up ffmpeg command configuration with locations of default output folders, ffmpeg, and ffprobe. ResourceManagement.CommandConfiguration = CommandConfiguration.Create( @"c:\source\ffmpeg\bin\temp", @"c:\source\ffmpeg\bin\ffmpeg.exe", @"c:\source\ffmpeg\bin\ffprobe.exe"); //create a factory var factory = CommandFactory.Create(); //create a command adding a two audio and video files var command = factory.CreateOutputCommand() .AddInput(Assets.Utilities.GetVideoFile()) .AddInput(Assets.Utilities.GetVideoFile()) .AddInput(Assets.Utilities.GetAudioFile()) .AddInput(Assets.Utilities.GetAudioFile()); //select the first two video streams and run concat filter var videoConcat = command.Select(command.Take(0), command.Take(1)) .Filter(Filterchain.FilterTo <VideoStream>(new Filters.Concat())); //select the first two audio streams and run concat filter var audioConcat = command.Select(command.Take(2), command.Take(3)) .Filter(Filterchain.FilterTo <VideoStream>(new Filters.Concat(1, 0))); command.Select(audioConcat, videoConcat) .MapTo <Mp4>(@"c:\source\ffmpeg\bin\temp\foo.mp4", SettingsCollection.ForOutput(new OverwriteOutput())); //render the output factory.Render(); }
public static async Task RemuxVideos(IEnumerable <string> inputFiles, bool removeTransportStreamFilesAfterRemuxing) { ResourceManagement.CommandConfiguration = CommandConfiguration.Create(Path.GetTempPath(), "ffmpeg.exe", "ffprobe.exe"); var actionBlock = new ActionBlock <JobConfiguration>(RemuxToMpeg4Container, new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = Environment.ProcessorCount }); foreach (string inputFile in inputFiles) { var jobConfiguration = new JobConfiguration { InputFile = inputFile, OutputFile = Path.ChangeExtension(inputFile, "mp4"), RemoveInputFileAfterRemux = removeTransportStreamFilesAfterRemuxing }; if (!File.Exists(jobConfiguration.OutputFile)) { actionBlock.Post(jobConfiguration); } else { Console.WriteLine($"Skipping existing file {jobConfiguration.OutputFile}"); } } actionBlock.Complete(); await actionBlock.Completion; }
public static void SetGlobalAssets() { const string outputPath = "c:/source/ffmpeg/bin/temp"; const string ffmpegPath = "c:/source/ffmpeg/bin/ffmpeg.exe"; const string ffprobePath = "c:/source/ffmpeg/bin/ffprobe.exe"; ResourceManagement.CommandConfiguration = CommandConfiguration.Create(outputPath, ffmpegPath, ffprobePath); }
public static void Run() { //set up ffmpeg command configuration with locations of default output folders, ffmpeg, and ffprobe. ResourceManagement.CommandConfiguration = CommandConfiguration.Create( @"c:\source\ffmpeg\bin\temp", @"c:\source\ffmpeg\bin\ffmpeg.exe", @"c:\source\ffmpeg\bin\ffprobe.exe"); //create a factory var factory = CommandFactory.Create(); //create a command adding a video file var command = factory.CreateOutputCommand() .AddInput(Assets.Utilities.GetVideoFile(), SettingsCollection.ForInput(new SeekTo(2))) .To <Jpg>(@"c:\source\ffmpeg\bin\temp\foo.jpg", SettingsCollection.ForOutput(new VideoFrames(1), new OverwriteOutput())); //render the output factory.Render(); }
public static void Run() { //set up ffmpeg command configuration with locations of default output folders, ffmpeg, and ffprobe. ResourceManagement.CommandConfiguration = CommandConfiguration.Create( @"c:\source\ffmpeg\bin\temp", @"c:\source\ffmpeg\bin\ffmpeg.exe", @"c:\source\ffmpeg\bin\ffprobe.exe"); //create a factory var factory = CommandFactory.Create(); //create a command adding a video file var command = factory.CreateOutputCommand() .AddInput(Assets.Utilities.GetVideoFile()) .OnSuccess(OnSuccessAction) .OnError(OnErrorAction) .To <Mp4>(@"c:\source\ffmpeg\bin\temp\foo.mp4", SettingsCollection.ForOutput(new OverwriteOutput())); factory.Render(); }
public static void Run() { //set up ffmpeg command configuration with locations of default output folders, ffmpeg, and ffprobe. ResourceManagement.CommandConfiguration = CommandConfiguration.Create( @"c:\source\ffmpeg\bin\temp", @"c:\source\ffmpeg\bin\ffmpeg.exe", @"c:\source\ffmpeg\bin\ffprobe.exe"); //create a factory var factory = CommandFactory.Create(); //create a command adding a two audio files factory.CreateOutputCommand() .WithInput <AudioStream>(Assets.Utilities.GetAudioFile()) .WithInput <AudioStream>(Assets.Utilities.GetAudioFile()) .Filter(Filterchain.FilterTo <AudioStream>(new Filters.Concat(1, 0))) .MapTo <M4A>(@"c:\source\ffmpeg\bin\temp\foo.m4a", SettingsCollection.ForOutput(new OverwriteOutput())); //render the output factory.Render(); }
private void MainWindow_OnLoaded(object sender, RoutedEventArgs e) { FFmePlayer.Source = new Uri(AppDomain.CurrentDomain.BaseDirectory + "test.mp4"); // FFmePlayer.Source = new Uri("https://zippy.gfycat.com/HairyIdenticalCougar.webm"); FFmePlayer.Play(); string ffmpegPath = Unosquare.FFmpegMediaElement.MediaElement.FFmpegPaths.FFmpeg; string ffprobePath = Unosquare.FFmpegMediaElement.MediaElement.FFmpegPaths.FFprobe; ResourceManagement.CommandConfiguration = CommandConfiguration.Create(TempPath, ffmpegPath, ffprobePath); if (!Directory.Exists(OutputPath)) { Directory.CreateDirectory(OutputPath); } if (!Directory.Exists(TempPath)) { Directory.CreateDirectory(TempPath); } }
public static void Run() { //set up ffmpeg command configuration with locations of default output folders, ffmpeg, and ffprobe. ResourceManagement.CommandConfiguration = CommandConfiguration.Create( @"c:\source\ffmpeg\bin\temp", @"c:\source\ffmpeg\bin\ffmpeg.exe", @"c:\source\ffmpeg\bin\ffprobe.exe"); //create a factory var factory = CommandFactory.Create(); //OPTION 1: // - this option uses the add input method, which adds the input to the command // but does not add any streams to a stage object. var option1 = factory.CreateOutputCommand() .AddInput(Assets.Utilities.GetVideoFile()) .AddInput(Assets.Utilities.GetAudioFile()); //select the first two streams from the input command var stage = option1.Select(option1.Take(0), option1.Take(1)); //map that directly to an output stream stage.MapTo <Mp4>(@"c:\source\ffmpeg\bin\temp\foo.mp4", SettingsCollection.ForOutput(new OverwriteOutput())); //OPTION 2: // - this option uses the with input method which adds the input to the command // and also adds the streams from the input file to a staging object var option2 = factory.CreateOutputCommand() .WithInput <VideoStream>(Assets.Utilities.GetVideoFile()) .WithInput <AudioStream>(Assets.Utilities.GetAudioFile()) .MapTo <Mp4>(@"c:\source\ffmpeg\bin\temp\bar.mp4", SettingsCollection.ForOutput(new OverwriteOutput())); factory.Render(); }