public static Filtergraph Create(FFmpegCommand command) { return(new Filtergraph { Owner = command }); }
public void GenerateDash_MidLevelApiOptions_ProducesCorrectDashEncodeResult() { Encoder encoder = new Encoder(ffmpegPath, ffprobePath, mp4boxPath, ffmpegCommandGenerator: (dashConfig, mediaMetadata) => { DashConfig c = dashConfig; MediaMetadata m = mediaMetadata; FFmpegCommand r = Encoder.GenerateFFmpegCommand(c, m); return(r); }, mp4BoxCommandGenerator: (dashConfig, videoStreams, audioStreams) => { DashConfig c = dashConfig; IEnumerable <VideoStreamCommand> v = videoStreams; IEnumerable <AudioStreamCommand> a = audioStreams; Mp4BoxCommand r = Encoder.GenerateMp4BoxCommand(c, v, a); return(r); }); DashConfig config = new DashConfig(testFileName, RunPath, Qualities, "output"); encodeResult = encoder.GenerateDash(config, encoder.ProbeFile(config.InputFilePath, out _)); Assert.NotNull(encodeResult.DashFilePath); Assert.NotNull(encodeResult.DashFileContent); Assert.NotNull(encodeResult.MediaFiles); Assert.Equal(4, encodeResult.MediaFiles.Count()); }
/// <summary> /// Create a typical instance of DashEncodeResult. /// </summary> /// <param name="mpdPath">The exact path to the mpd file.</param> /// <param name="mpdContent">The exact mpd content deserialized from XML.</param> /// <param name="ffmpegCommand">The generated ffmpeg command used when </param> /// <param name="inputMetadata">Metadata about the DASHed input file.</param> public DashEncodeResult(string mpdPath, MPD mpdContent, FFmpegCommand ffmpegCommand, MediaMetadata inputMetadata) { DashFileContent = mpdContent; DashFilePath = mpdPath; FFmpegCommand = ffmpegCommand; InputMetadata = inputMetadata; }
public override List <StreamIdentifier> SetupTemplate(FFmpegCommand command, List <StreamIdentifier> streamIdList) { if (streamIdList.Count != 2) { throw new InvalidOperationException("Crossfade Concatenate requires two input video streams."); } var streamTo = streamIdList[1]; var streamFrom = streamIdList[0]; //grab the current length of the streamId specified var streamFromMetadata = MetadataHelpers.GetMetadataInfo(command, streamFrom); //from == // - split // - 1: start -> (end - durationOf) // - 2: (end - durationOf) -> end //to == // - split // - 1: start -> (start + durationOf) // - 2: (start + durationOf) -> end //blend == // - from:2 / to:1 //output == // - (from:1, blend, to:2) var endMinusDuration = streamFromMetadata.VideoStream.Duration - Duration; var fromSplit = command.Select(streamFrom) .Filter(Filterchain.FilterTo <VideoStream>(new Split(2))); var fromMain = fromSplit.Take(0) .Filter(new TrimVideo(null, endMinusDuration.TotalSeconds, VideoUnitType.Seconds)); var fromBlend = fromSplit.Take(1) .Filter(new TrimVideo(endMinusDuration.TotalSeconds, null, VideoUnitType.Seconds)); var toSplit = command.Select(streamTo) .Filter(Filterchain.FilterTo <VideoStream>(new Split(2))); var toBlend = toSplit.Take(0) .Filter(new TrimVideo(null, Duration.TotalSeconds, VideoUnitType.Seconds)); var toMain = toSplit.Take(1) .Filter(new TrimVideo(Duration.TotalSeconds, null, VideoUnitType.Seconds)); var blendOut = command.Select(toBlend.StreamIdentifiers) .Select(fromBlend.StreamIdentifiers) .Filter(Filterchain.FilterTo <VideoStream>(new Blend(string.Format(CrossfadeAlgorithm, Duration.TotalSeconds)))); var result = command.Select(fromMain.StreamIdentifiers) .Select(blendOut.StreamIdentifiers) .Select(toMain.StreamIdentifiers) .Filter(Filterchain.FilterTo <VideoStream>(new Concat())); return(result.StreamIdentifiers); }
public static MetadataInfoTreeContainer GetMetadataInfo(FFmpegCommand command, StreamIdentifier streamId) { //first validate that the streamId does in fact belong to the command. if (!CommandHelper.ReceiptBelongsToCommand(command, streamId)) { throw new ArgumentException("The provided streamId is not part of the provided ffmpeg command.", "streamId"); } var resourceIndex = CommandHelper.IndexOfResource(command, streamId); if (resourceIndex > -1) { return(ResourceMetadataInfo(command, resourceIndex)); } var filterchainIndex = CommandHelper.IndexOfFilterchain(command, streamId); if (filterchainIndex > -1) { return(FilterchainMetadataInfo(command, filterchainIndex)); } var outputIndex = CommandHelper.IndexOfOutput(command, streamId); if (outputIndex > -1) { return(OutputMetadataInfo(command, outputIndex)); } return(null); }
private static void ValidateTo(FFmpegCommand command) { if (command.Owner == null) { throw new ArgumentException("Command must contain an owner before sugar is allowed.", "command"); } }
public static CommandStage Select <TStreamType>(this FFmpegCommand command, int index) where TStreamType : class, IStream { var streamId = command.StreamIdentifier <TStreamType>(index); return(command.Select(streamId)); }
public static IStream StreamFromStreamIdentifier(FFmpegCommand command, StreamIdentifier streamId) { var commandInput = CommandInputFromStreamIdentifier(command, streamId); if (commandInput != null) { return(commandInput.Resource.Streams.FirstOrDefault(si => si.Map == streamId.Map)); } var commandOutput = CommandOutputFromStreamIdentifier(command, streamId); if (commandOutput != null) { return(commandOutput.Resource.Streams.FirstOrDefault(si => si.Map == streamId.Map)); } var filterchain = FilterchainFromStreamIdentifier(command, streamId); if (filterchain != null) { var filterchainOutput = filterchain.OutputList.First(si => si.Stream.Map == streamId.Map); return(filterchainOutput.Stream); } throw new StreamNotFoundException(); }
//command stage public static CommandStage WithInput <TStreamType>(this FFmpegCommand command, string fileName) where TStreamType : class, IStream { var commandStage = CommandStage.Create(command); return(commandStage.WithInput <TStreamType>(fileName)); }
public static CommandStage WithInput <TStreamType>(this FFmpegCommand command, string fileName, SettingsCollection settings) where TStreamType : class, IStream { command.AddInput(fileName, settings); return(command.Select(command.LastInputStream <TStreamType>())); }
public static MetadataInfoTreeGroup Create(FFmpegCommand command, CommandOutput commandOutput) { var metadataInfoTreeGroup = new MetadataInfoTreeGroup(commandOutput.Settings); metadataInfoTreeGroup.Fill(command, commandOutput); return(metadataInfoTreeGroup); }
public static MetadataInfoTreeGroup Create(FFmpegCommand command, Filterchain filterchain) { var metadataInfoTreeGroup = new MetadataInfoTreeGroup(filterchain); metadataInfoTreeGroup.Fill(command, filterchain); return(metadataInfoTreeGroup); }
public async Task VerifyTestAsync() { using var ffmpeg = new FFmpegCommand { FFmpegPath = @"ffmpeg" }; using var _ = ffmpeg.MessageUpdated.Subscribe(Console.WriteLine); Assert.IsTrue(await ffmpeg.VerifyAsync(default));
public static CommandStage Select(this FFmpegCommand command, params CommandStage[] stages) { if (stages == null || stages.Length == 0) { throw new ArgumentNullException("stages"); } return(command.Select(stages.ToList())); }
public static CommandOutput CommandOutputFromStreamIdentifier(FFmpegCommand command, StreamIdentifier streamId) { if (streamId == null) { throw new ArgumentNullException("streamId"); } return(command.Objects.Outputs.FirstOrDefault(i => i.GetStreamIdentifiers().Any(si => si.Map == streamId.Map))); }
public static Filterchain FilterchainFromStreamIdentifier(FFmpegCommand command, StreamIdentifier streamId) { if (streamId == null) { throw new ArgumentNullException("streamId"); } return(command.Objects.Filtergraph.FilterchainList.FirstOrDefault(f => f.GetStreamIdentifiers().Any(r => r.Equals(streamId)))); }
//stream ids public static StreamIdentifier StreamIdentifier(this FFmpegCommand command, int index) { if (index < 0 || index >= command.Inputs.Count) { throw new IndexOutOfRangeException(); } return(command.Inputs[index].GetStreamIdentifier()); }
public static CommandStage Select(this FFmpegCommand command, List <StreamIdentifier> streamIds) { ValidateStreams(command, streamIds); return(new CommandStage(command) { StreamIdentifiers = streamIds }); }
public static StreamIdentifier LastInputStream(this FFmpegCommand command) { if (command.Inputs.Count == 0) { return(null); } return(command.Inputs[command.Inputs.Count - 1].GetStreamIdentifier()); }
public static CommandStage Select(this FFmpegCommand command, CommandInput resource) { if (resource == null) { throw new ArgumentNullException("resource"); } return(command.Select(resource.GetStreamIdentifier())); }
public static CommandStage Select(this FFmpegCommand command, StreamIdentifier streamId) { var streamIdList = new List <StreamIdentifier>() { streamId }; return(command.Select(streamIdList)); }
internal static MetadataInfoTreeContainer FilterchainMetadataInfo(FFmpegCommand command, int index) { if (command.Filtergraph.Count <= index) { return(null); } return(ExecuteStreamCalculator(MetadataInfoStreamCalculator.Create(command, command.Filtergraph[index]))); }
internal static MetadataInfoTreeContainer OutputMetadataInfo(FFmpegCommand command, int index) { if (command.Outputs.Count <= index) { return(null); } return(ExecuteStreamCalculator(MetadataInfoStreamCalculator.Create(command, command.Outputs[index]))); }
public static CommandStage Select <TStreamType>(this FFmpegCommand command, CommandInput resource) where TStreamType : class, IStream { if (resource == null) { throw new ArgumentNullException("resource"); } return(command.Select(resource.GetStreamIdentifier <TStreamType>())); }
public static StreamIdentifier StreamIdentifier <TStreamType>(this FFmpegCommand command, int index) where TStreamType : class, IStream { if (index < 0 || index >= command.Inputs.Count) { throw new IndexOutOfRangeException(); } return(command.Inputs[index].GetStreamIdentifier <TStreamType>()); }
public static StreamIdentifier LastInputStream <TStreamType>(this FFmpegCommand command) where TStreamType : class, IStream { if (command.Inputs.Count == 0) { return(null); } return(command.Inputs[command.Inputs.Count - 1].GetStreamIdentifier <TStreamType>()); }
public static FFmpegCommand AddInput(this FFmpegCommand command, List <string> files) { if (files == null || files.Count == 0) { throw new ArgumentException("Files cannot be null or empty.", "files"); } files.ForEach(fileName => command.AddInput(fileName)); return(command); }
public static int IndexOfOutput(FFmpegCommand command, StreamIdentifier streamId) { var matchingOutput = CommandOutputFromStreamIdentifier(command, streamId); if (matchingOutput == null) { return(-1); } return(command.Outputs.IndexOf(matchingOutput)); }
public static int IndexOfResource(FFmpegCommand command, StreamIdentifier streamId) { var matchingResource = CommandInputFromStreamIdentifier(command, streamId); if (matchingResource == null) { return(-1); } return(command.Inputs.IndexOf(matchingResource)); }
public static int IndexOfFilterchain(FFmpegCommand command, StreamIdentifier streamId) { var matchingFilterchain = FilterchainFromStreamIdentifier(command, streamId); if (matchingFilterchain == null) { return(-1); } return(command.Filtergraph.IndexOf(matchingFilterchain)); }
internal static CommandOutputManager Create(FFmpegCommand owner) { return new CommandOutputManager(owner); }
internal static CommandFiltergraphManager Create(FFmpegCommand owner) { return new CommandFiltergraphManager(owner); }
private CommandOutputManager(FFmpegCommand owner) { Owner = owner; }
private CommandFiltergraphManager(FFmpegCommand owner) { Owner = owner; }