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

Fix timeline preview when fps != 25

parent 487ce84f
Pipeline #4494 passed with stage
in 21 minutes and 7 seconds
......@@ -32,4 +32,4 @@ DNxHD 1080p 60fps=r=60 s=1920x1080 vb=90M threads=0 vcodec=dnxhd progressive=1;m
ProRes=vcodec=prores_ks vb=0 g=1 bf=0 vprofile=0 vendor=ap10 qscale=4 s=800x450;mov
MJPEG=f=avi vcodec=mjpeg progressive=1 qscale=1;avi
x264-nvenc=vcodec=h264_nvenc g=1 bf=0 profile=0;mkv
x264-vaapi=vcodec=h264_vaapi g=1 bf=0 profile=0;mkv
x264-vaapi=vcodec=h264_vaapi g=1 bf=0 profile=578;mkv
......@@ -63,6 +63,9 @@ int main(int argc, char **argv)
// chunk size in frames
int chunkSize = args.at(0).toInt();
args.removeFirst();
// chunk size in frames
QString profilePath = args.at(0);
args.removeFirst();
// rendered file extension
QString extension = args.at(0);
args.removeFirst();
......@@ -71,13 +74,13 @@ int main(int argc, char **argv)
args.removeFirst();
QDir baseFolder(target);
Mlt::Factory::init();
Mlt::Profile profile;
Mlt::Profile profile(profilePath.toUtf8().constData());
profile.set_explicit(1);
Mlt::Producer prod(profile, nullptr, playlist.toUtf8().constData());
if (!prod.is_valid()) {
fprintf(stderr, "INVALID playlist: %s \n", playlist.toUtf8().constData());
return 1;
}
profile.from_producer(prod);
profile.set_explicit(1);
const char *localename = prod.get_lcnumeric();
QLocale::setDefault(QLocale(localename));
for (const QString &frame : chunks) {
......@@ -98,6 +101,7 @@ int main(int argc, char **argv)
}
if (!cons->is_valid()) {
fprintf(stderr, " = = = INVALID CONSUMER\n\n");
return 1;
}
cons->set("terminate_on_pause", 1);
cons->connect(*playlst);
......@@ -113,7 +117,7 @@ int main(int argc, char **argv)
}
int in = -1;
int out = -1;
// older MLT version, does not support embeded consumer in/out in xml, and current
// MLT (6.16) does not pass it onto the multi / movit consumer, so read it manually and enforce
QFile f(playlist);
......@@ -133,7 +137,7 @@ int main(int argc, char **argv)
playlist.append(QStringLiteral("?multi=1"));
}
}
auto *rJob = new RenderJob(render, playlist, target, pid, in, out);
rJob->start();
return app.exec();
......
......@@ -385,7 +385,9 @@ void PreviewManager::clearPreviewRange(bool resetZones)
bool hasPreview = m_previewTrack != nullptr;
for (const auto &ix : m_renderedChunks) {
m_cacheDir.remove(QStringLiteral("%1.%2").arg(ix.toInt()).arg(m_extension));
m_dirtyChunks << ix;
if (!m_dirtyChunks.contains(ix)) {
m_dirtyChunks << ix;
}
if (!hasPreview) {
continue;
}
......@@ -419,7 +421,7 @@ void PreviewManager::addPreviewRange(const QPoint zone, bool add)
for (int i = startChunk; i <= endChunk; i++) {
int frame = i * chunkSize;
if (add) {
if (!m_renderedChunks.contains(frame)) {
if (!m_renderedChunks.contains(frame) && !m_dirtyChunks.contains(frame)) {
m_dirtyChunks << frame;
}
} else {
......@@ -547,6 +549,7 @@ void PreviewManager::doPreviewRender(const QString &scene)
QStringLiteral("-split"),
chunks.join(QLatin1Char(',')),
QString::number(chunkSize - 1),
pCore->getCurrentProfilePath(),
m_extension,
m_consumerParams.join(QLatin1Char(' '))};
qDebug() << " - - -STARTING PREVIEW JOBS: " << args;
......@@ -628,9 +631,12 @@ void PreviewManager::invalidatePreview(int startFrame, int endFrame)
}
Mlt::Producer *prod = m_previewTrack->replace_with_blank(ix);
delete prod;
m_renderedChunks.removeAll(QVariant(i));
m_dirtyChunks << QVariant(i);
chunksChanged = true;
QVariant val(i);
m_renderedChunks.removeAll(val);
if (!m_dirtyChunks.contains(val)) {
m_dirtyChunks << val;
chunksChanged = true;
}
}
}
if (chunksChanged) {
......@@ -716,8 +722,10 @@ void PreviewManager::corruptedChunk(int frame, const QString &fileName)
}
emit previewRender(0, m_errorLog, -1);
m_cacheDir.remove(fileName);
m_dirtyChunks << frame;
qSort(m_dirtyChunks);
if (!m_dirtyChunks.contains(frame)) {
m_dirtyChunks << frame;
qSort(m_dirtyChunks);
}
}
int PreviewManager::setOverlayTrack(Mlt::Playlist *overlay)
......
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