Ejemplo 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);
        }
        /// <summary>
        /// <see cref="avformat_find_stream_info(AVFormatContext*, AVDictionary**)"/>
        /// </summary>
        public MediaDictionary FindStreamInfo()
        {
            AVDictionary *dict;

            avformat_find_stream_info(this, &dict);
            return(MediaDictionary.FromNative(dict, isOwner: true));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// <see cref="av_packet_unpack_dictionary(byte*, int, AVDictionary**)"/>
        /// </summary>
        public static MediaDictionary UnpackDictionary(Span <byte> data)
        {
            AVDictionary *dict = null;

            fixed(byte *ptr = data)
            {
                av_packet_unpack_dictionary(ptr, data.Length, &dict).ThrowIfError();
            }

            return(MediaDictionary.FromNative(dict, isOwner: true));
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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
                    }
                }
            }
        }
Ejemplo n.º 6
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"]);
        }
Ejemplo n.º 7
0
 public ViewSettings()
 {
     ScreenConfigs   = new MediaDictionary <string, ScreenConfig>();
     ScreenHierarchy = new MediaDictionary <string, string>();
 }
Ejemplo n.º 8
0
        /// <summary>
        /// <see cref="av_packet_pack_dictionary(AVDictionary*, int*)"/>
        /// </summary>
        public static DataPointer PackDirectory(MediaDictionary dict)
        {
            int size;

            return(new DataPointer(av_packet_pack_dictionary(dict, &size), size));
        }