Skip to content

Commit 6f80011

Browse files
authored
Merge pull request #876 from OpenShot/fix-double-avcodec-open
Fix a huge regression which invokes the avcodec_open() twice
2 parents bcd54c0 + 520446c commit 6f80011

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/FFmpegReader.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,12 @@ void FFmpegReader::Open() {
426426
}
427427

428428
// Open video codec
429-
if (avcodec_open2(pCodecCtx, pCodec, &opts) < 0)
430-
throw InvalidCodec("A video codec was found, but could not be opened.", path);
429+
int avcodec_return = avcodec_open2(pCodecCtx, pCodec, &opts);
430+
if (avcodec_return < 0) {
431+
std::stringstream avcodec_error_msg;
432+
avcodec_error_msg << "A video codec was found, but could not be opened. Error: " << av_err2string(avcodec_return);
433+
throw InvalidCodec(avcodec_error_msg.str(), path);
434+
}
431435

432436
#if USE_HW_ACCEL
433437
if (hw_de_on && hw_de_supported) {
@@ -569,13 +573,13 @@ void FFmpegReader::Open() {
569573
CheckFPS();
570574
}
571575

576+
// Mark as "open"
577+
is_open = true;
578+
572579
// Seek back to beginning of file (if not already seeking)
573580
if (!is_seeking) {
574581
Seek(1);
575582
}
576-
577-
// Mark as "open"
578-
is_open = true;
579583
}
580584
}
581585

0 commit comments

Comments
 (0)