[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdenlive/Applications/16.12] src: Fix creation of project profile with messy fps
From: Jean-Baptiste Mardelle <null () kde ! org>
Date: 2017-01-08 11:23:36
Message-ID: E1cQBZY-0007gJ-BA () code ! kde ! org
[Download RAW message or body]
Git commit c27117f07bfdedad10462b587f1b1b7f01f7ef33 by Jean-Baptiste Mardelle.
Committed on 08/01/2017 at 11:23.
Pushed by mardelle into branch 'Applications/16.12'.
Fix creation of project profile with messy fps
BUG: 374613
M +37 -3 src/doc/kdenlivedoc.cpp
M +2 -2 src/mltcontroller/clipcontroller.cpp
https://commits.kde.org/kdenlive/c27117f07bfdedad10462b587f1b1b7f01f7ef33
diff --git a/src/doc/kdenlivedoc.cpp b/src/doc/kdenlivedoc.cpp
index 819bcf2a8..2bfc04e44 100644
--- a/src/doc/kdenlivedoc.cpp
+++ b/src/doc/kdenlivedoc.cpp
@@ -1444,8 +1444,9 @@ void KdenliveDoc::loadDocumentProperties()
}
QString profile = m_documentProperties.value(QStringLiteral("profile"));
- if (!profile.isEmpty())
+ if (!profile.isEmpty()) {
m_profile = ProfilesDialog::getVideoProfile(profile);
+ }
if (!m_profile.isValid()) {
// try to find matching profile from MLT profile properties
list = m_document.elementsByTagName(QStringLiteral("profile"));
@@ -1471,7 +1472,7 @@ void KdenliveDoc::updateProjectProfile(bool reloadProducers)
pCore->monitorManager()->resetProfiles(m_profile, m_timecode);
if (!reloadProducers) return;
emit updateFps(fpsChanged);
- if (fpsChanged) {
+ if (fpsChanged != 1.0) {
pCore->bin()->reloadAllProducers();
}
}
@@ -1551,7 +1552,40 @@ void KdenliveDoc::switchProfile(MltVideoProfile profile, const \
QString &id, cons
pCore->bin()->doDisplayMessage(i18n("Switch to clip profile %1?", \
profile.descriptiveString()), KMessageWidget::Information, list); } else {
// No known profile, ask user if he wants to use clip profile anyway
- if (KMessageBox::warningContinueCancel(QApplication::activeWindow(), \
i18n("No profile found for your clip.\nCreate and switch to new profile (%1x%2, \
%3fps)?", profile.width, profile.height, \
QString::number((double)profile.frame_rate_num / profile.frame_rate_den, 'f', 2))) == \
KMessageBox::Continue) { + // Check profile fps so that we don't end up with \
an fps = 30.003 which would mess things up + QString adjustMessage;
+ double fps = (double)profile.frame_rate_num / profile.frame_rate_den;
+ double fps_int;
+ double fps_frac = std::modf(fps, &fps_int);
+ if (fps_frac < 0.4) {
+ profile.frame_rate_num = (int) fps_int;
+ profile.frame_rate_den = 1;
+ } else {
+ // Check for 23.98, 29.97, 59.94
+ if (fps_int == 23.0) {
+ if (qAbs(fps - 23.98) < 0.01) {
+ profile.frame_rate_num = 24000;
+ profile.frame_rate_den = 1001;
+ }
+ } else if (fps_int == 29.0) {
+ if (qAbs(fps - 29.97) < 0.01) {
+ profile.frame_rate_num = 30000;
+ profile.frame_rate_den = 1001;
+ }
+ } else if (fps_int == 59.0) {
+ if (qAbs(fps - 59.94) < 0.01) {
+ profile.frame_rate_num = 60000;
+ profile.frame_rate_den = 1001;
+ }
+ } else {
+ // Unknown profile fps, warn user
+ adjustMessage = i18n("\nWarning: unknown non integer fps, might \
cause incorrect duration display."); + }
+ }
+ if ((double)profile.frame_rate_num / profile.frame_rate_den != fps) {
+ adjustMessage = i18n("\nProfile fps adjusted from original %1", \
QString::number(fps, 'f', 4)); + }
+ if (KMessageBox::warningContinueCancel(QApplication::activeWindow(), \
i18n("No profile found for your clip.\nCreate and switch to new profile (%1x%2, \
%3fps)?%4", profile.width, profile.height, \
QString::number((double)profile.frame_rate_num / profile.frame_rate_den, 'f', 2), \
adjustMessage)) == KMessageBox::Continue) { m_profile = profile;
m_profile.description = QString("%1x%2 \
%3fps").arg(profile.width).arg(profile.height).arg(QString::number((double)profile.frame_rate_num \
/ profile.frame_rate_den, 'f', 2)); ProfilesDialog::saveProfile(m_profile);
diff --git a/src/mltcontroller/clipcontroller.cpp \
b/src/mltcontroller/clipcontroller.cpp index 5e0243148..0b2cdb0d1 100644
--- a/src/mltcontroller/clipcontroller.cpp
+++ b/src/mltcontroller/clipcontroller.cpp
@@ -308,9 +308,9 @@ const QString ClipController::getStringDuration()
if (m_masterProducer) {
int playtime = m_masterProducer->get_int("kdenlive:duration");
if (playtime > 0) {
- return QString(properties().frames_to_time(playtime, mlt_time_smpte));
+ return QString(m_properties->frames_to_time(playtime, \
mlt_time_smpte_df)); }
- return m_masterProducer->get_length_time(mlt_time_smpte);
+ return m_masterProducer->get_length_time(mlt_time_smpte_df);
}
return QString(i18n("Unknown"));
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic