public void Stop() { _videoFrameConverter.Dispose(); ffmpeg.av_frame_unref(_pFrame); ffmpeg.av_free(_pFrame); ffmpeg.av_packet_unref(_pPacket); ffmpeg.av_free(_pPacket); ffmpeg.avcodec_close(_pCodecContext); var pFormatContext = _pFormatContext; ffmpeg.avformat_close_input(&pFormatContext); }
public void Dispose() { if (_videoConverter != null) { _videoConverter.Dispose(); _videoConverter = null; } if (_audioConverter != null) { _audioConverter.Dispose(); _audioConverter = null; } _outputName = null; _inputName = null; _validStreamIndexes = null; for (int i = 0; i < _StreamsContextArr.Length; i++) { fixed(AVCodecContext **ptr = &_StreamsContextArr[i].DecoderContext) { ffmpeg.avcodec_free_context(ptr); } if (_pOutputFmCtx != null && _StreamsContextArr.Length > i && _pOutputFmCtx->streams[i] != null && _StreamsContextArr[i].EncoderContext != null) { fixed(AVCodecContext **ptr = &_StreamsContextArr[i].EncoderContext) { ffmpeg.avcodec_free_context(ptr); } } } fixed(AVFormatContext **ptr = &_pInputFmtCtx) { ffmpeg.avformat_close_input(ptr); } if (_pOutputFmCtx != null && (_pOutputFmCtx->oformat->flags & ffmpeg.AVFMT_NOFILE) == 0) { ffmpeg.avio_closep(&_pOutputFmCtx->pb); } ffmpeg.avformat_free_context(_pOutputFmCtx); _pOutputFmCtx = null; ffmpeg.avformat_free_context(_pInputFmtCtx); _pInputFmtCtx = null; if (_pReusablePacket != null) { FreePacket(realloc: false); } if (_pReusableFrame != null) { FreeFrame(realloc: false); } _StreamsContextArr = null; }