Esempio n. 1
0
        public void Test2()
        {
            MediaDictionary options = new MediaDictionary();

            Output.WriteLine($"{((IntPtr)options.internalPointerPlaceHolder).ToInt64()}");
            Output.WriteLine($"={((IntPtr)options.ppDictionary).ToInt64()}");
            options.Add("protocol_whitelist", "file");
            options.Add("key", "value");
            options.Add("protocol_blacklist", "cache");
            Output.WriteLine($"{((IntPtr)options.internalPointerPlaceHolder).ToInt64()}");
            Output.WriteLine($"={((IntPtr)options.ppDictionary).ToInt64()}");
            var file = "222.mp4";
            AVFormatContext * pFormatContext  = null;
            AVFormatContext **ppFormatContext = &pFormatContext;
            var ret1 = ffmpeg.avformat_alloc_output_context2(ppFormatContext, OutFormat.Get("mpeg"), null, file);
            var ret2 = ffmpeg.avio_open2(&pFormatContext->pb, file, ffmpeg.AVIO_FLAG_WRITE, null, options);

            //Output.WriteLine($"{((IntPtr)options.ppDictionary).ToInt64()}");
            //Output.WriteLine($"{((IntPtr)options.internalPointerPlaceHolder).ToInt64()}");
            Output.WriteLine($"{((IntPtr)options.internalPointerPlaceHolder).ToInt64()}");
            Output.WriteLine($"={((IntPtr)options.ppDictionary).ToInt64()}");
            Output.WriteLine($"+{((IntPtr)(*options.ppDictionary)).ToInt64()}");
            Assert.True(options.Count == 1);
            Assert.Equal("key", options.First().Key);
            Assert.Equal("value", options.First().Value);
        }
Esempio n. 2
0
        public void TestNotSupported()
        {
            MediaDictionary options = new MediaDictionary();

            options.Add("protocol_whitelist", "file");
            options.Add("key", "value"); // not supported
            options.Add("protocol_blacklist", "cache");
            var file = "test.mp4";
            AVFormatContext * pFormatContext  = null;
            AVFormatContext **ppFormatContext = &pFormatContext;
            var ret1 = ffmpeg.avformat_alloc_output_context2(ppFormatContext, null, null, file);
            var ret2 = ffmpeg.avio_open2(&pFormatContext->pb, file, ffmpeg.AVIO_FLAG_WRITE, null, options);

            Assert.True(options.Count == 1);
            Assert.Equal("key", options.First().Key);
            Assert.Equal("value", options.First().Value);
        }
Esempio n. 3
0
        public void TestDictionary()
        {
            MediaDictionary options = new MediaDictionary();

            options.Add("k1", "v1");
            options.Add("k2", "v2");
            Assert.Equal(2, options.Count);

            options.Add("K1", "v3", AVDictWriteFlags.MultiKey);
            Assert.Equal(3, options.Count);
            Assert.Equal("v3", options["K1"]);
            Assert.Equal("v1", options["k1"]);

            options.Add("k2", "v4", AVDictWriteFlags.DontOverwrite);
            Assert.Equal(3, options.Count);
            Assert.Equal("v2", options["k2"]);

            options.Add("k1", "v5", AVDictWriteFlags.Append);
            Assert.Equal(3, options.Count);
            Assert.Equal("v1v5", options["k1"]);
        }
Esempio n. 4
0
        public RtmpPull(string input)
        {
            MediaDictionary options = new MediaDictionary();

            options.Add("stimeout", "30000000"); // set connect timeout 30s

            using (MediaReader reader = new MediaReader(input, null, options))
            {
                var codecContext = reader.Where(_ => _.Codec.Type == AVMediaType.AVMEDIA_TYPE_VIDEO).First().Codec.AVCodecContext;

                PixelConverter videoFrameConverter = new PixelConverter(AVPixelFormat.AV_PIX_FMT_BGR24, codecContext.width, codecContext.height);
                foreach (var packet in reader.ReadPacket())
                {
                    foreach (var frame in reader[packet.StreamIndex].ReadFrame(packet))
                    {
                        // TODO
                    }
                }
            }
        }