Files
oak-editor/app/task/index/index.cpp
T

35 lines
881 B
C++

#include "index.h"
#include "codec/decoder.h"
#include "codec/ffmpeg/ffmpegdecoder.h"
IndexTask::IndexTask(StreamPtr stream) :
stream_(stream)
{
SetTitle(tr("Indexing %1:%2").arg(stream_->footage()->filename(), QString::number(stream_->index())));
}
void IndexTask::Action()
{
if (stream_->footage()->decoder().isEmpty()) {
emit Failed(QStringLiteral("Stream has no decoder"));
} else {
DecoderPtr decoder = Decoder::CreateFromID(stream_->footage()->decoder());
decoder->set_stream(stream_);
// Force multithreading for faster indexing
if (decoder->id() == "ffmpeg") {
static_cast<FFmpegDecoder*>(decoder.get())->SetMultithreading(true);
}
connect(decoder.get(), &Decoder::IndexProgress, this, &IndexTask::ProgressChanged);
decoder->Open();
decoder->Index(&IsCancelled());
decoder->Close();
emit Succeeded();
}
}