]> git.sesse.net Git - kdenlive/commitdiff
Fix several issues with project profile, including:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 24 Jun 2011 21:08:23 +0000 (21:08 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 24 Jun 2011 21:08:23 +0000 (21:08 +0000)
http://kdenlive.org/mantis/view.php?id=2188

svn path=/trunk/kdenlive/; revision=5728

src/kdenlivedoc.cpp
src/mainwindow.cpp
src/mltdevicecapture.cpp
src/renderer.cpp
src/renderer.h

index eebaf6f721ba2df2a28cbaf24211d94ff0ba85c5..b9cb39f4e5e6647623e64ddf71ba0d92dc386fb2 100644 (file)
@@ -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 <TrackInfo> 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);
 }
 
index fe3fcd837510ef9f546b99ce026818698e963041..380128f695754d207a6b8ca36a029d836a3fd835 100644 (file)
@@ -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);
     }
index 1e16e1783de5d17c270e6d17e0ff70a1ceba658d..71bee1b35f6fde4c9743e48d253fc1b2a45b56bf 100644 (file)
@@ -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();
index c48899992d208d5acb8884047ed438fbf4379eb4..f157c5ddcea02576a1cf509016bca01c082eb171 100644 (file)
@@ -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</property>", ">avformat-novalidate</property>");
     else
         playlist.replace(">avformat-novalidate</property>", ">avformat</property>");
-
     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();
index d0a323db0c9106620af54702374c428a25da07b7..b892792330186a66778002fe8b53ee89d6c26f3f 100644 (file)
@@ -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. */