oiiodecoder: implemented heuristic to auto-detect start and end index
This commit is contained in:
@@ -86,11 +86,23 @@ bool OIIODecoder::Probe(Footage *f, const QAtomicInt *cancelled)
|
||||
video_stream->set_frame_rate(default_timebase.flipped());
|
||||
video_stream->set_image_sequence(true);
|
||||
|
||||
// FIXME: Get actual start number
|
||||
video_stream->set_start_time(1);
|
||||
int64_t seq_index = GetImageSequenceIndex(f->filename());
|
||||
|
||||
// FIXME: Get actual duration
|
||||
video_stream->set_duration(200);
|
||||
int64_t start_index = seq_index;
|
||||
int64_t end_index = seq_index;
|
||||
|
||||
// Heuristic to find the first and last images (users can always override this later in FootagePropertiesDialog)
|
||||
while (QFileInfo::exists(TransformImageSequenceFileName(f->filename(), start_index-1))) {
|
||||
start_index--;
|
||||
}
|
||||
|
||||
while (QFileInfo::exists(TransformImageSequenceFileName(f->filename(), end_index+1))) {
|
||||
end_index++;
|
||||
}
|
||||
|
||||
video_stream->set_start_time(start_index);
|
||||
|
||||
video_stream->set_duration(end_index - start_index);
|
||||
} else {
|
||||
image_stream = std::make_shared<ImageStream>();
|
||||
}
|
||||
@@ -261,6 +273,19 @@ QString OIIODecoder::TransformImageSequenceFileName(const QString &filename, con
|
||||
return file_info.dir().filePath(file_info.fileName().replace(original_basename, new_basename));
|
||||
}
|
||||
|
||||
int64_t OIIODecoder::GetImageSequenceIndex(const QString &filename)
|
||||
{
|
||||
int digit_count = GetImageSequenceDigitCount(filename);
|
||||
|
||||
QFileInfo file_info(filename);
|
||||
|
||||
QString original_basename = file_info.baseName();
|
||||
|
||||
QString number_only = original_basename.mid(original_basename.size() - digit_count);
|
||||
|
||||
return number_only.toLongLong();
|
||||
}
|
||||
|
||||
bool OIIODecoder::OpenImageHandler(const QString &fn)
|
||||
{
|
||||
image_ = OIIO::ImageInput::open(fn.toStdString());
|
||||
|
||||
@@ -58,6 +58,8 @@ private:
|
||||
|
||||
static QString TransformImageSequenceFileName(const QString& filename, const int64_t& number);
|
||||
|
||||
static int64_t GetImageSequenceIndex(const QString& filename);
|
||||
|
||||
bool OpenImageHandler(const QString& fn);
|
||||
|
||||
void CloseImageHandle();
|
||||
|
||||
Reference in New Issue
Block a user