public void InitHeader(FfmpegHeader header) { _ffmpegHeaderInit = true; _ffmpegDecoder.Init(header.CodecID, header.Width, header.Height); }
public FfmpegStreamDecoder(Constants.AVCodecID codecId, int width, int height) { _decoder = new FfmpegDecoder(); _decoder.Init(codecId, width, height); }
void run() { FfmpegDecoder decoder = new FfmpegDecoder(); int index = 0; int wait = 0; while (!_disposeEvent.WaitOne(wait)) { wait = 1; if (_records.Length > 0) { bool reposed = false; DateTime startRealTime; DateTime startPlayTime; lock (_playTimeLockObj) { startRealTime = _startRealTime; startPlayTime = _startPlayTime; reposed = _reposed; _reposed = false; } if (_playing || reposed) { DateTime curPlayTime = startPlayTime + new TimeSpan((long)Math.Round((DateTime.Now - startRealTime).Ticks * _speed)); if (curPlayTime > EndTime) { curPlayTime = EndTime; } Record <FfmpegPackage> record = null; if (reposed) { for (index = 0; index < _records.Length; index++) { if (_records[index].Time >= curPlayTime) { break; } } if (index < _records.Length) { record = _records[index]; } } else { int next = index + 1; if (next < _records.Length && _records[next].Time < curPlayTime) { index = next; record = _records[index]; } } if (record != null) { _currentTime = record.Time; decoder.Init(record.Package.CodecID, record.Package.Width, record.Package.Height); var frame = decoder.Decode(record.Package.Type, record.Package.Pts, record.Package.Data); if (frame != null) { var videoFrame = new VideoFrame() { Width = frame.Width, Height = frame.Height, Timestamp = (int)frame.Pts, Data = frame.Data, }; fireVideoFrameEvent(videoFrame); } wait = 0; } } } } }