Exemplo n.º 1
0
        public MediaRecorder(string fileName, int width, int height, int sampleRate)
        {
            CheckUnmanagedReference("avcodec-53.dll");
            CheckUnmanagedReference("avformat-53.dll");
            CheckUnmanagedReference("avutil-51.dll");
            CheckUnmanagedReference("swscale-2.dll");

            _fileNameMP4 = Path.GetFullPath(fileName);
            _fileNameWAV = Path.ChangeExtension(_fileNameMP4, ".wav");
            _width       = width;
            _height      = height;
            _sampleRate  = sampleRate;
            _writerMP4   = new VideoFileWriter();
            _writerWAV   = new WavSampleWriter(_fileNameWAV, sampleRate);
            try
            {
                var ext   = Path.GetExtension(_fileNameMP4).ToUpperInvariant();
                var codec = GetCodec(ext);
                _writerMP4.Open(_fileNameMP4, _width, _height, 50, codec, 200000000);//200000000);
                _bitmap = new Bitmap(_width, _height, PixelFormat.Format32bppRgb);
            }
            catch
            {
                _writerMP4.Dispose();
                throw;
            }
            _threadRecord              = new Thread(RecordProc);
            _threadRecord.Name         = "Record";
            _threadRecord.IsBackground = true;
            _threadRecord.Start();
        }
Exemplo n.º 2
0
        public SoundRecorder(string fileName, int sampleRate)
        {
            _fileName   = Path.GetFullPath(fileName);
            _sampleRate = sampleRate;
            _writer     = new WavSampleWriter(fileName, sampleRate);

            _threadRecord              = new Thread(RecordProc);
            _threadRecord.Name         = "Record";
            _threadRecord.IsBackground = true;
            _threadRecord.Start();
        }