Example #1
0
        static MediaFile()
        {
            streams = new Dictionary <string, Stream>();

            // Create FFmpeg protocol for reading .NET streams
            protocol           = new URLProtocol();
            protocol.openfunc  = Open;
            protocol.readfunc  = Read;
            protocol.seekfunc  = Seek;
            protocol.closefunc = Close;
            protocol.name      = "stream";

            // Write protocol to pointer
            streamprotocol = Allocate <URLProtocol>();
            Marshal.StructureToPtr(protocol, streamprotocol, false);

            // Register protocols and codecs with FFmpeg
            FFmpeg.av_register_all();
            FFmpeg.register_protocol(streamprotocol);
        }
Example #2
0
        /// <summary>
        /// Register FFmpeg for all convert requests.
        /// Method is called once by FFmpegManager on application load.
        /// </summary>
        public void RegisterFFmpeg()
        {
            if (_ffmpegRegistered)
            {
                return;
            }

            try
            {
                // Setup Data list / attributes
                _nextConvertId      = 0;
                _videoMemoryStreams = new Dictionary <int, MemoryStream>();

                // Create defraser (input) protocol
                _protocol           = new URLProtocol();
                _protocol.openfunc  = ProtocolOpen;
                _protocol.readfunc  = ProtocolRead;
                _protocol.seekfunc  = ProtocolSeek;
                _protocol.closefunc = ProtocolClose;
                _protocol.name      = "defraser";

                // Write protocol to pointer
                _pDefraserProtocol = Allocate <URLProtocol>();
                Marshal.StructureToPtr(_protocol, _pDefraserProtocol, false);

                // Register DLL and 'defraser' protocol
                _ffmpeg.AvRegisterAll();
                _ffmpeg.RegisterProtocol(_pDefraserProtocol);                 // calls av_register_protocol
                _ffmpegRegistered = true;
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.Message + Environment.NewLine + e.StackTrace);
                //MessageBox.Show("FFmpeg was not able to register itself, frame visualisation is not available." + Environment.NewLine + e.Message,"FFmpeg not available",MessageBoxButtons.OK,MessageBoxIcon.Error); //FIXME: add commandline argument to be visual-style or user interaction allowed or not.
            }
        }
Example #3
0
 public static extern int register_protocol(ref URLProtocol protocol);