public void SettingsCollection_MergeRange() { var startAtDefault = new SeekPositionInput(2); var vcodecDefault = new CodecVideo(VideoCodecType.Copy); var settingsCollectionI = SettingsCollection.ForInput(new SeekPositionInput(1)); var settingsCollectionO = SettingsCollection.ForOutput(new CodecVideo(VideoCodecType.Libx264)); var settingsCollectionMergeI = SettingsCollection.ForInput(startAtDefault); var settingsCollectionMergeO = SettingsCollection.ForOutput(vcodecDefault); Assert.Throws <ArgumentException>(() => settingsCollectionI.MergeRange(settingsCollectionMergeO, FFmpegMergeOptionType.OldWins)); Assert.Throws <ArgumentException>(() => settingsCollectionO.MergeRange(settingsCollectionMergeI, FFmpegMergeOptionType.OldWins)); Assert.Throws <ArgumentException>(() => settingsCollectionI.MergeRange(settingsCollectionMergeO, FFmpegMergeOptionType.NewWins)); Assert.Throws <ArgumentException>(() => settingsCollectionO.MergeRange(settingsCollectionMergeI, FFmpegMergeOptionType.NewWins)); settingsCollectionI.MergeRange(settingsCollectionMergeI, FFmpegMergeOptionType.OldWins); settingsCollectionO.MergeRange(settingsCollectionMergeO, FFmpegMergeOptionType.OldWins); var startAtSetting = settingsCollectionI.Items[0] as SeekPositionInput; var vcodecSetting = settingsCollectionO.Items[0] as CodecVideo; Assert.False(startAtSetting != null && startAtSetting.Length == startAtDefault.Length); Assert.False(vcodecSetting != null && vcodecSetting.Codec == vcodecDefault.Codec); settingsCollectionI.MergeRange(settingsCollectionMergeI, FFmpegMergeOptionType.NewWins); settingsCollectionO.MergeRange(settingsCollectionMergeO, FFmpegMergeOptionType.NewWins); startAtSetting = settingsCollectionI.Items[0] as SeekPositionInput; vcodecSetting = settingsCollectionO.Items[0] as CodecVideo; Assert.True(startAtSetting != null && startAtSetting.Length == startAtDefault.Length); Assert.True(vcodecSetting != null && vcodecSetting.Codec == vcodecDefault.Codec); }
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 SettingsCollection_RemoveAll() { var settingsCollectionI = SettingsCollection.ForInput(new SeekPositionInput(1), new DurationInput(2)); var settingsCollectionO = SettingsCollection.ForOutput(new RemoveAudio(), new OverwriteOutput()); Assert.True(settingsCollectionI.Count == 2); Assert.True(settingsCollectionO.Count == 2); settingsCollectionI.RemoveAll(s => true); settingsCollectionO.RemoveAll(s => true); Assert.True(settingsCollectionI.Count == 0); Assert.True(settingsCollectionO.Count == 0); }
public void SettingsCollection_RemoveAt() { var settingsCollectionI = SettingsCollection.ForInput(new StartAt(1), new DurationInput(2)); var settingsCollectionO = SettingsCollection.ForOutput(new RemoveAudio(), new OverwriteOutput()); Assert.True(settingsCollectionI.Count == 2); Assert.True(settingsCollectionO.Count == 2); settingsCollectionI.RemoveAt(0); settingsCollectionO.RemoveAt(0); Assert.True(settingsCollectionI.Count == 1); Assert.True(settingsCollectionO.Count == 1); }
public void InputSettingsToOutput_Verify() { var inputSettings = SettingsCollection.ForInput( new StartAt(1d), new DurationInput(3d)); var output = CommandFactory.Create() .CreateOutputCommand() .WithInput <VideoStream>(Utilities.GetVideoFile(), inputSettings) .To <Mp4>() .First(); var metadataInfo = MetadataHelpers.GetMetadataInfo(output.Owner, output.GetStreamIdentifier()); Assert.True(metadataInfo.VideoStream.VideoMetadata.Duration == TimeSpan.FromSeconds(3)); }
public void SettingsCollection_Add() { var settingsCollectionI = SettingsCollection.ForInput(); var settingsCollectionO = SettingsCollection.ForOutput(); Assert.Throws <ArgumentException>(() => settingsCollectionI.Add(new OverwriteOutput())); Assert.Throws <ArgumentException>(() => settingsCollectionO.Add(new SeekPositionInput(1))); settingsCollectionI.Add(new SeekPositionInput(1)); settingsCollectionO.Add(new OverwriteOutput()); Assert.True(settingsCollectionI.Count == 1); Assert.True(settingsCollectionO.Count == 1); }
public void InputSettingsToOutputSettingsOverDuration_Verify() { var inputSettings = SettingsCollection.ForInput(new StartAt(1d)); var outputSettings = SettingsCollection.ForOutput( new BitRateVideo(3000), new DurationOutput(10d)); var output = CommandFactory.Create() .CreateOutputCommand() .WithInput <VideoStream>(Utilities.GetVideoFile(), inputSettings) .To <Mp4>(outputSettings) .First(); var metadataInfo = MetadataHelpers.GetMetadataInfo(output.Owner, output.GetStreamIdentifier()); Assert.True(metadataInfo.VideoStream.VideoMetadata.Duration == TimeSpan.FromSeconds(9)); // we have a 10 second video, and start 1 second in, this should only be 9 Assert.True(metadataInfo.VideoStream.VideoMetadata.BitRate == 3000000L); }
public void InputSettingsToOutputSettings_Verify() { var inputSettings = SettingsCollection.ForInput(new StartAt(1d)); var outputSettings = SettingsCollection.ForOutput( new BitRateVideo(3000), new DurationOutput(5d)); var output = CommandFactory.Create() .CreateOutputCommand() .WithInput <VideoStream>(Utilities.GetVideoFile(), inputSettings) .To <Mp4>(outputSettings) .First(); var metadataInfo = MetadataHelpers.GetMetadataInfo(output.Owner, output.GetStreamIdentifier()); Assert.True(metadataInfo.VideoStream.Duration == TimeSpan.FromSeconds(3)); // this is because the input is only 4 seconds, we start at 1 Assert.True(metadataInfo.VideoStream.BitRate == 3000000L); }
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 void SettingsCollection_AddRange() { var settingsCollectionI = SettingsCollection.ForInput(); var settingsCollectionO = SettingsCollection.ForOutput(); var settingsCollectionAddI = SettingsCollection.ForInput(new SeekPositionInput(1), new DurationInput(1)); var settingsCollectionAddO = SettingsCollection.ForOutput(new OverwriteOutput(), new RemoveAudio()); Assert.Throws <ArgumentNullException>(() => settingsCollectionI.AddRange(null)); Assert.Throws <ArgumentNullException>(() => settingsCollectionO.AddRange(null)); settingsCollectionI.AddRange(settingsCollectionAddI); settingsCollectionO.AddRange(settingsCollectionAddO); Assert.Throws <ArgumentException>(() => settingsCollectionI.AddRange(settingsCollectionAddO)); Assert.Throws <ArgumentException>(() => settingsCollectionO.AddRange(settingsCollectionAddI)); Assert.Throws <ArgumentException>(() => settingsCollectionI.AddRange(settingsCollectionAddI)); Assert.Throws <ArgumentException>(() => settingsCollectionO.AddRange(settingsCollectionAddO)); Assert.True(settingsCollectionI.Count == 2); Assert.True(settingsCollectionO.Count == 2); }
public void InputSettingsToFilterToOutputSettings_Verify() { var baseline = Resource.From(Utilities.GetVideoFile()) .LoadMetadata() .Streams .OfType <VideoStream>() .First(); var calculatedSeconds = ((baseline.Info.VideoMetadata.Duration.TotalSeconds - 1) * 3d) - 2d; var calculatedDuration = TimeSpan.FromSeconds(calculatedSeconds); var inputSettings = SettingsCollection.ForInput(new StartAt(1d)); var outputSettings = SettingsCollection.ForOutput( new BitRateVideo(3000), new DurationOutput(5d)); var filterchain = Filterchain.FilterTo <VideoStream>(new Split(3)); var split = CommandFactory.Create() .CreateOutputCommand() .WithInput <VideoStream>(Utilities.GetVideoFile(), inputSettings) .Filter(filterchain); var concat1 = split.Command .Select(split.StreamIdentifiers[0]) .Select(split.StreamIdentifiers[1]) .Filter(new Dissolve(1d)); var concat2 = concat1.Select(split.StreamIdentifiers[2]) .Filter(new Dissolve(1d)); var output = concat2.MapTo <Mp4>(outputSettings).First(); var metadataInfo1 = MetadataHelpers.GetMetadataInfo(concat2.Command, concat2.StreamIdentifiers.FirstOrDefault()); var metadataInfo2 = MetadataHelpers.GetMetadataInfo(output.Owner, output.GetStreamIdentifier()); Assert.True(metadataInfo1.VideoStream.VideoMetadata.Duration == calculatedDuration); Assert.True(metadataInfo2.VideoStream.VideoMetadata.Duration == TimeSpan.FromSeconds(5)); Assert.True(metadataInfo2.VideoStream.VideoMetadata.BitRate == 3000000L); }
public static CommandStage WithInput <TStreamType>(this CommandStage command, string fileName) where TStreamType : class, IStream { return(command.WithInput <TStreamType>(fileName, SettingsCollection.ForInput())); }
public void SettingsCollection_ForAny() { Assert.DoesNotThrow(() => SettingsCollection.ForOutput(new SampleRate(44100))); Assert.DoesNotThrow(() => SettingsCollection.ForInput(new SampleRate(44100))); }
public void SettingsCollection_ForAny() { SettingsCollection.ForOutput(new SampleRate(44100)); SettingsCollection.ForInput(new SampleRate(44100)); }
public void SettingsCollection_ForInput_Invalid() { Assert.Throws <ArgumentException>(() => SettingsCollection.ForInput(new OverwriteOutput())); }
public static FFmpegCommand AddInput(this FFmpegCommand command, string fileName) { return(command.AddInput(fileName, SettingsCollection.ForInput())); }
public void SettingsCollection_ForInput_Valid() { var settingsCollection = SettingsCollection.ForInput(new SeekPositionInput(1)); Assert.True(settingsCollection.Count == 1); }
public static CommandInput Create(IContainer resource) { return(Create(resource, SettingsCollection.ForInput())); }