Commit a8f591ea authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Minor optimization on project load (don't unnecessarily request a frame)

parent b5f95255
Pipeline #117274 passed with stage
in 6 minutes and 43 seconds
......@@ -564,7 +564,19 @@ void ClipLoadTask::run()
int h = frameSize.height();
std::unique_ptr<Mlt::Frame> frame(producer->get_frame());
frame->get_image(format, w, h);
// Check audio / video
bool hasAudio = frame->get_int("test_audio") == 0;
bool hasVideo = frame->get_int("test_image") == 0;
frame.reset();
if (hasAudio) {
if (hasVideo) {
producer->set("kdenlive:clip_type", 0);
} else {
producer->set("kdenlive:clip_type", 1);
}
} else if (hasVideo) {
producer->set("kdenlive:clip_type", 2);
}
// Check if file is seekable
seekable = producer->get_int("seekable");
vindex = producer->get_int("video_index");
......
......@@ -672,14 +672,41 @@ void ClipController::checkAudioVideo()
}
return;
}
QScopedPointer<Mlt::Frame> frame(m_masterProducer->get_frame());
if (frame->is_valid()) {
// test_audio returns 1 if there is NO audio (strange but true at the time this code is written)
m_hasAudio = frame->get_int("test_audio") == 0;
m_hasVideo = frame->get_int("test_image") == 0;
m_masterProducer->seek(0);
if (m_masterProducer->property_exists("kdenlive:clip_type")) {
int clipType = m_masterProducer->get_int("kdenlive:clip_type");
switch (clipType) {
case 1:
m_hasAudio = true;
m_hasVideo = false;
break;
case 2:
m_hasAudio = false;
m_hasVideo = true;
break;
default:
m_hasAudio = true;
m_hasVideo = true;
break;
}
} else {
qDebug()<<"* * * *ERROR INVALID FRAME On test";
QScopedPointer<Mlt::Frame> frame(m_masterProducer->get_frame());
if (frame->is_valid()) {
// test_audio returns 1 if there is NO audio (strange but true at the time this code is written)
m_hasAudio = frame->get_int("test_audio") == 0;
m_hasVideo = frame->get_int("test_image") == 0;
if (m_hasAudio) {
if (m_hasVideo) {
m_masterProducer->set("kdenlive:clip_type", 0);
} else {
m_masterProducer->set("kdenlive:clip_type", 1);
}
} else if (m_hasVideo) {
m_masterProducer->set("kdenlive:clip_type", 2);
}
m_masterProducer->seek(0);
} else {
qDebug()<<"* * * *ERROR INVALID FRAME On test";
}
}
}
bool ClipController::hasVideo() const
......@@ -832,8 +859,7 @@ void ClipController::mirrorOriginalProperties(Mlt::Properties &props)
} else {
if (m_clipType == ClipType::AV || m_clipType == ClipType::Video || m_clipType == ClipType::Audio) {
// Make sure that a frame / image was fetched to initialize all meta properties
QString progressive = m_properties->get("meta.media.progressive");
if (progressive.isEmpty()) {
if (!m_properties->property_exists("meta.media.progressive")) {
// Fetch a frame to initialize required properties
QScopedPointer<Mlt::Producer> tmpProd(nullptr);
if (KdenliveSettings::gpu_accel()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment