private void WriteFiltergraph(FFmpegCommand command, Filtergraph filtergraph)
        {
            if (filtergraph == null)
            {
                throw new ArgumentNullException("filtergraph");
            }

            var shouldIncludeDelimitor = false;

            filtergraph.FilterchainList.ForEach(filterchain =>
            {
                if (shouldIncludeDelimitor)
                {
                    BuilderBase.Append(";");
                }
                else
                {
                    BuilderBase.Append(" -filter_complex \"");
                    shouldIncludeDelimitor = true;
                }

                WriteFilterchain(command, filterchain);
            });

            if (shouldIncludeDelimitor)
            {
                BuilderBase.Append("\"");
            }
        }
        public static Filtergraph FilterTo <TStreamType>(this Filtergraph filtergraph, int count, params IFilter[] filters)
            where TStreamType : class, IStream, new()
        {
            var filterchain = Filterchain.FilterTo <TStreamType>(count, filters);

            return(filtergraph.Add(filterchain));
        }
Beispiel #3
0
        public void Filtergraph_FilterTo()
        {
            var filtergraph = Filtergraph.Create(CommandHelper.CreateCommand());

            filtergraph.FilterTo <VideoStream>();

            Assert.True(filtergraph.Count == 1);

            filtergraph.FilterTo <AudioStream>();

            Assert.True(filtergraph.Count == 2);
        }
Beispiel #4
0
        public void Filtergraph_RemoveAll()
        {
            var filtergraph = Filtergraph.Create(CommandHelper.CreateCommand());

            filtergraph.FilterTo <VideoStream>();
            filtergraph.FilterTo <VideoStream>();

            Assert.True(filtergraph.Count == 2);

            filtergraph.RemoveAll(f => true);

            Assert.True(filtergraph.Count == 0);
        }
Beispiel #5
0
        public void Filtergraph_Add()
        {
            var filtergraph  = Filtergraph.Create(CommandHelper.CreateCommand());
            var filterchain1 = Filterchain.FilterTo <AudioStream>();
            var filterchain2 = Filterchain.FilterTo <VideoStream>();

            filtergraph.Add(filterchain1);

            Assert.True(filtergraph.Count == 1);

            filtergraph.Add(filterchain2);

            Assert.True(filtergraph.Count == 2);
        }
 public static Filtergraph FilterTo <TStreamType>(this Filtergraph filtergraph, params IFilter[] filters)
     where TStreamType : class, IStream, new()
 {
     return(filtergraph.FilterTo <TStreamType>(1, filters));
 }
Beispiel #7
0
 private CommandObjects(FFmpegCommand owner)
 {
     Outputs     = new List <CommandOutput>();
     Inputs      = new List <CommandInput>();
     Filtergraph = Filtergraph.Create(owner);
 }
Beispiel #8
0
        public void Filtergraph_EmptyToString_ThrowsException()
        {
            var filtergraph = Filtergraph.Create(CommandHelper.CreateCommand());

            Assert.Throws <InvalidOperationException>(() => filtergraph.ToString());
        }