Beispiel #1
0
        public static MediaFilterGraph CreateMediaFilterGraph(string graphDesc)
        {
            MediaFilterGraph filterGraph = new MediaFilterGraph();
            AVFilterInOut *  inputs;
            AVFilterInOut *  outputs;

            ffmpeg.avfilter_graph_parse2(filterGraph, graphDesc, &inputs, &outputs).ThrowExceptionIfError();
            AVFilterInOut *cur = inputs;

            for (cur = inputs; cur != null; cur = cur->next)
            {
                Trace.TraceInformation($"{((IntPtr)cur->name).PtrToStringUTF8()}");
                filterGraph.inputs.Add(new MediaFilterContext(cur->filter_ctx));
            }
            for (cur = outputs; cur != null; cur = cur->next)
            {
                Trace.TraceInformation($"{((IntPtr)cur->name).PtrToStringUTF8()}");
                filterGraph.outputs.Add(new MediaFilterContext(cur->filter_ctx));
            }

            foreach (var item in filterGraph)
            {
                Trace.TraceInformation($"{item.Name}");
                for (int i = 0; i < item.NbInputs; i++)
                {
                    Trace.TraceInformation(ffmpeg.avfilter_pad_get_name(item.AVFilterContext.input_pads, i));
                }
                Trace.TraceInformation("++++");
                for (int i = 0; i < item.NbOutputs; i++)
                {
                    Trace.TraceInformation(ffmpeg.avfilter_pad_get_name(item.AVFilterContext.output_pads, i));
                }
                Trace.TraceInformation("---------");
            }
            // TODO: Link
            filterGraph.Initialize();
            ffmpeg.avfilter_inout_free(&inputs);
            ffmpeg.avfilter_inout_free(&outputs);
            return(filterGraph);
        }
Beispiel #2
0
        public static MediaFilterGraph CreateMediaFilterGraph(string graphDesc)
        {
            unsafe
            {
                MediaFilterGraph filterGraph = new MediaFilterGraph();
                AVFilterInOut *  inputs;
                AVFilterInOut *  outputs;
                ffmpeg.avfilter_graph_parse2(filterGraph, graphDesc, &inputs, &outputs).ThrowExceptionIfError();
                AVFilterInOut *cur = inputs;
                for (cur = inputs; cur != null; cur = cur->next)
                {
                    ffmpeg.av_log(null, (int)LogLevel.Debug, $"{((IntPtr)cur->name).PtrToStringUTF8()}{Environment.NewLine}");
                    filterGraph.inputs.Add(new MediaFilterContext(cur->filter_ctx));
                }
                for (cur = outputs; cur != null; cur = cur->next)
                {
                    ffmpeg.av_log(null, (int)LogLevel.Debug, $"{((IntPtr)cur->name).PtrToStringUTF8()}{Environment.NewLine}");
                    filterGraph.outputs.Add(new MediaFilterContext(cur->filter_ctx));
                }

                foreach (var item in filterGraph)
                {
                    ffmpeg.av_log(null, (int)LogLevel.Debug, $"{item.Name}{Environment.NewLine}");
                    for (int i = 0; i < item.NbInputs; i++)
                    {
                        ffmpeg.av_log(null, (int)LogLevel.Debug, $"{ffmpeg.avfilter_pad_get_name(item.AVFilterContext.input_pads, i)}{Environment.NewLine}");
                    }
                    for (int i = 0; i < item.NbOutputs; i++)
                    {
                        ffmpeg.av_log(null, (int)LogLevel.Debug, $"{ffmpeg.avfilter_pad_get_name(item.AVFilterContext.output_pads, i)}{Environment.NewLine}");
                    }
                }
                // TODO: Link
                filterGraph.Initialize();
                ffmpeg.avfilter_inout_free(&inputs);
                ffmpeg.avfilter_inout_free(&outputs);
                return(filterGraph);
            }
        }