ffmpeg: ensure duration detection responds to cancel action

This commit is contained in:
itsmattkc
2022-11-19 17:36:16 -08:00
parent 42a7cc10c8
commit 5bcb426488
3 changed files with 15 additions and 5 deletions
+5 -2
View File
@@ -315,6 +315,9 @@ FootageDescription FFmpegDecoder::Probe(const QString &filename, CancelAtom *can
int64_t footage_duration = fmt_ctx->duration;
bool duration_guessed_from_bitrate = (fmt_ctx->duration_estimation_method == AVFMT_DURATION_FROM_BITRATE);
if (duration_guessed_from_bitrate) {
qWarning() << "Unreliable duration detected - we will manually determine it ourselves (this may take some time)";
}
// Dump it into the Footage object
for (unsigned int i=0;i<fmt_ctx->nb_streams;i++) {
@@ -383,7 +386,7 @@ FootageDescription FFmpegDecoder::Probe(const QString &filename, CancelAtom *can
do {
new_dur = frame->best_effort_timestamp;
} while (instance.GetFrame(pkt, frame) >= 0);
} while (instance.GetFrame(pkt, frame) >= 0 && (!cancelled || !cancelled->IsCancelled()));
avstream->duration = new_dur;
@@ -447,7 +450,7 @@ FootageDescription FFmpegDecoder::Probe(const QString &filename, CancelAtom *can
do {
new_dur = frame->best_effort_timestamp;
} while (instance.GetFrame(pkt, frame) >= 0);
} while (instance.GetFrame(pkt, frame) >= 0 && (!cancelled || !cancelled->IsCancelled()));
avstream->duration = new_dur;
+2
View File
@@ -474,9 +474,11 @@ void Footage::Reprobe()
}
}
if (!cancelled_ || !cancelled_->HeardCancel()) {
if (!footage_info.Save(meta_cache_file)) {
qWarning() << "Failed to save stream cache, footage will have to be re-probed";
}
}
}
+6 -1
View File
@@ -106,10 +106,15 @@ void ProjectImportTask::Import(Folder *folder, QFileInfoList import, int &counte
} else {
Footage* footage = new Footage(file_info.absoluteFilePath());
Footage* footage = new Footage();
footage->SetCancelPointer(this->GetCancelAtom());
footage->set_filename(file_info.absoluteFilePath());
footage->SetLabel(file_info.fileName());
footage->SetCancelPointer(nullptr);
if (footage->IsValid()) {
// See if this footage is an image sequence
ValidateImageSequence(footage, import, i);