Commit 192907ef authored by Philippe Gorley's avatar Philippe Gorley

encoder: close io if file

Change-Id: I2b901f56b82ce5206314a1f87a878818cc1fc46c
parent 431cee5d
......@@ -64,6 +64,9 @@ MediaEncoder::~MediaEncoder()
if (outputCtx_) {
if (outputCtx_->priv_data)
av_write_trailer(outputCtx_);
if (fileIO_) {
avio_close(outputCtx_->pb);
}
for (auto encoderCtx : encoders_) {
if (encoderCtx) {
#ifndef _MSC_VER
......@@ -354,6 +357,7 @@ MediaEncoder::openIOContext()
const char* filename = outputCtx_->filename;
#endif
if (!(outputCtx_->oformat->flags & AVFMT_NOFILE)) {
fileIO_ = true;
if ((ret = avio_open(&outputCtx_->pb, filename, AVIO_FLAG_WRITE)) < 0) {
std::stringstream ss;
ss << "Could not open IO context for '" << filename << "': " << libav_utils::getError(ret);
......
......@@ -123,6 +123,7 @@ private:
int currentStreamIdx_ = -1;
unsigned sent_samples = 0;
bool initialized_ {false};
bool fileIO_ {false};
#ifdef ENABLE_VIDEO
video::VideoScaler scaler_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment