From: Jean-Baptiste Mardelle Date: Fri, 24 Jun 2011 21:08:23 +0000 (+0000) Subject: Fix several issues with project profile, including: X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=ce58013c54eee710d83860f0841a2bf4b4536baf;p=kdenlive Fix several issues with project profile, including: http://kdenlive.org/mantis/view.php?id=2188 svn path=/trunk/kdenlive/; revision=5728 --- diff --git a/src/kdenlivedoc.cpp b/src/kdenlivedoc.cpp index eebaf6f7..b9cb39f4 100644 --- a/src/kdenlivedoc.cpp +++ b/src/kdenlivedoc.cpp @@ -270,7 +270,7 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup } } } - + // Something went wrong, or a new file was requested: create a new project if (!success) { m_url.clear(); @@ -278,9 +278,6 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup m_document = createEmptyDocument(tracks.x(), tracks.y()); } - // Set the video profile (empty == default) - KdenliveSettings::setCurrent_profile(profilePath()); - // Ask to create the project directory if it does not exist if (!QFile::exists(m_projectFolder.path())) { int create = KMessageBox::questionYesNo(parent, i18n("Project directory %1 does not exist. Create it?", m_projectFolder.path())); @@ -327,7 +324,7 @@ KdenliveDoc::~KdenliveDoc() int KdenliveDoc::setSceneList() { - m_render->resetProfile(KdenliveSettings::current_profile()); + m_render->resetProfile(KdenliveSettings::current_profile(), true); if (m_render->setSceneList(m_document.toString(), m_documentProperties.value("position").toInt()) == -1) { // INVALID MLT Consumer, something is wrong return -1; @@ -375,8 +372,7 @@ QDomDocument KdenliveDoc::createEmptyDocument(QList tracks) QDomDocument doc; QDomElement mlt = doc.createElement("mlt"); doc.appendChild(mlt); - - + // Create black producer // For some unknown reason, we have to build the black producer here and not in renderer.cpp, otherwise // the composite transitions with the black track are corrupted. @@ -845,6 +841,7 @@ bool KdenliveDoc::setProfilePath(QString path) m_height = m_profile.height; kDebug() << "Kdenlive document, init timecode from path: " << path << ", " << m_fps; m_timecode.setFormat(m_fps); + KdenliveSettings::setCurrent_profile(m_profile.path); return (current_fps != m_fps); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index fe3fcd83..380128f6 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -3552,7 +3552,23 @@ void MainWindow::slotSaveZone(Render *render, QPoint zone, DocClipBase *baseClip } if (baseClip && !baseClip->fileURL().isEmpty()) { // create zone from clip url, so that we don't have problems with proxy clips - QProcess::startDetached(KdenliveSettings::rendererpath(), QStringList() << baseClip->fileURL().path() << "in=" + QString::number(zone.x()) << "out=" + QString::number(zone.y()) << "-consumer" << "xml:" + url->url().path()); + QProcess p; +#if QT_VERSION >= 0x040600 + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + env.remove("MLT_PROFILE"); + p.setProcessEnvironment(env); +#else + QStringList env = QProcess::systemEnvironment(); + env << "MLT_PROFILE='\0'"; + p.setEnvironment(env); +#endif + p.start(KdenliveSettings::rendererpath(), QStringList() << baseClip->fileURL().path() << "in=" + QString::number(zone.x()) << "out=" + QString::number(zone.y()) << "-consumer" << "xml:" + url->url().path()); + if (!p.waitForStarted(3000)) { + KMessageBox::sorry(this, i18n("Cannot start MLT's renderer:\n%1", KdenliveSettings::rendererpath())); + } + else if (!p.waitForFinished(5000)) { + KMessageBox::sorry(this, i18n("Timeout while creating xml output")); + } } else render->saveZone(url->url(), edit->text(), zone); } diff --git a/src/mltdevicecapture.cpp b/src/mltdevicecapture.cpp index 1e16e178..71bee1b3 100644 --- a/src/mltdevicecapture.cpp +++ b/src/mltdevicecapture.cpp @@ -114,7 +114,7 @@ void MltDeviceCapture::buildConsumer(const QString &profileName) char *tmp = qstrdup(m_activeProfile.toUtf8().constData()); setenv("MLT_PROFILE", tmp, 1); m_mltProfile = new Mlt::Profile(tmp); - m_mltProfile->get_profile()->is_explicit = 1; + m_mltProfile->set_explicit(true); delete[] tmp; QString videoDriver = KdenliveSettings::videodrivername(); diff --git a/src/renderer.cpp b/src/renderer.cpp index c4889999..f157c5dd 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -183,15 +183,15 @@ void Render::slotSwitchFullscreen() void Render::buildConsumer(const QString profileName) { - m_activeProfile = profileName; - char *tmp = qstrdup(m_activeProfile.toUtf8().constData()); delete m_blackClip; m_blackClip = NULL; //TODO: uncomment following line when everything is clean // uncommented Feb 2011 --Granjow if (m_mltProfile) delete m_mltProfile; - + m_activeProfile = profileName; + char *tmp = qstrdup(m_activeProfile.toUtf8().constData()); + setenv("MLT_PROFILE", tmp, 1); m_mltProfile = new Mlt::Profile(tmp); m_mltProfile->set_explicit(true); delete[] tmp; @@ -287,9 +287,10 @@ Mlt::Producer *Render::invalidProducer(const QString &id) return clip; } -int Render::resetProfile(const QString profileName) +int Render::resetProfile(const QString profileName, bool dropSceneList) { - QString scene = sceneList(); + QString scene; + if (!dropSceneList) scene = sceneList(); if (m_mltConsumer) { if (m_externalConsumer == KdenliveSettings::external_display()) { if (KdenliveSettings::external_display() && m_activeProfile == profileName) return 1; @@ -335,31 +336,17 @@ int Render::resetProfile(const QString profileName) buildConsumer(profileName); double new_fps = m_mltProfile->fps(); double new_dar = m_mltProfile->dar(); - if (current_fps != new_fps) { - // fps changed, we must update the scenelist positions - scene = updateSceneListFps(current_fps, new_fps, scene); + + if (!dropSceneList) { + // We need to recover our playlist + if (current_fps != new_fps) { + // fps changed, we must update the scenelist positions + scene = updateSceneListFps(current_fps, new_fps, scene); + } + setSceneList(scene, pos); + // producers have changed (different profile), so reset them... + emit refreshDocumentProducers(new_dar != current_dar, current_fps != new_fps); } - //kDebug() << "//RESET WITHSCENE: " << scene; - setSceneList(scene, pos); - // producers have changed (different profile), so reset them... - emit refreshDocumentProducers(new_dar != current_dar, current_fps != new_fps); - /*Mlt::Producer *producer = new Mlt::Producer(*m_mltProfile , "xml-string", scene.toUtf8().constData()); - m_mltProducer = producer; - m_blackClip = new Mlt::Producer(*m_mltProfile , "colour", "black"); - m_mltProducer->optimise(); - m_mltProducer->set_speed(0); - connectPlaylist();*/ - - //delete m_mltProfile; - // mlt_properties properties = MLT_CONSUMER_PROPERTIES(m_mltConsumer->get_consumer()); - //mlt_profile prof = m_mltProfile->get_profile(); - //mlt_properties_set_data(properties, "_profile", prof, 0, (mlt_destructor)mlt_profile_close, NULL); - //mlt_properties_set(properties, "profile", "hdv_1080_50i"); - //m_mltConsumer->set("profile", (char *) profile.toUtf8().data()); - //m_mltProfile = new Mlt::Profile((char*) profile.toUtf8().data()); - - //apply_profile_properties( m_mltProfile, m_mltConsumer->get_consumer(), properties ); - //refresh(); return 1; } @@ -1050,7 +1037,6 @@ int Render::setSceneList(QString playlist, int position) playlist.replace(">avformat", ">avformat-novalidate"); else playlist.replace(">avformat-novalidate", ">avformat"); - m_mltProducer = new Mlt::Producer(*m_mltProfile, "xml-string", playlist.toUtf8().constData()); if (!m_mltProducer || !m_mltProducer->is_valid()) { kDebug() << " WARNING - - - - -INVALID PLAYLIST: " << playlist.toUtf8().constData(); diff --git a/src/renderer.h b/src/renderer.h index d0a323db..b8927923 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -166,7 +166,11 @@ Q_OBJECT public: /** @brief Turns on or off on screen display. */ void refreshDisplay(); - int resetProfile(const QString profileName); + /** @brief Change the Mlt PROFILE + * @param profileName The MLT profile name + * @param dropSceneList If true, the current playlist will be deleted + * . */ + int resetProfile(const QString profileName, bool dropSceneList = false); double fps() const; /** @brief Returns the width of a frame for this profile. */