ffmpeg: ensure duration detection responds to cancel action
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -474,8 +474,10 @@ void Footage::Reprobe()
|
||||
}
|
||||
}
|
||||
|
||||
if (!footage_info.Save(meta_cache_file)) {
|
||||
qWarning() << "Failed to save stream cache, footage will have to be re-probed";
|
||||
if (!cancelled_ || !cancelled_->HeardCancel()) {
|
||||
if (!footage_info.Save(meta_cache_file)) {
|
||||
qWarning() << "Failed to save stream cache, footage will have to be re-probed";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user