]> git.sesse.net Git - kdenlive/commitdiff
Make the "video index" and "audio index" work (still requires a patch to MLT not...
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 27 Oct 2008 21:48:09 +0000 (21:48 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 27 Oct 2008 21:48:09 +0000 (21:48 +0000)
svn path=/branches/KDE4/; revision=2579

src/clipproperties.cpp
src/docclipbase.cpp
src/renderer.cpp

index c13af83a33339c31918751e68cde2dc060436f0d..14903cec3edbdfc033092ffe6f876343ea4a4b66 100644 (file)
@@ -73,6 +73,14 @@ ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidg
         m_view.clip_aindex->setValue(props.value("audio_index").toInt());
     }
 
+    if (props.contains("audio_max")) {
+        m_view.clip_aindex->setMaximum(props.value("audio_max").toInt());
+    }
+
+    if (props.contains("video_max")) {
+        m_view.clip_vindex->setMaximum(props.value("video_max").toInt());
+    }
+
     connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar, SLOT(setEnabled(bool)));
     connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), m_view.clip_threads, SLOT(setEnabled(bool)));
     connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), m_view.clip_vindex, SLOT(setEnabled(bool)));
@@ -240,9 +248,12 @@ const QString &ClipProperties::clipId() const {
 
 QMap <QString, QString> ClipProperties::properties() {
     QMap <QString, QString> props;
-    props["description"] = m_view.clip_description->text();
     CLIPTYPE t = m_clip->clipType();
     QMap <QString, QString> old_props = m_clip->properties();
+
+    if (old_props.value("description") != m_view.clip_description->text())
+        props["description"] = m_view.clip_description->text();
+
     double aspect = m_view.clip_ar->value();
     if (m_view.clip_force_ar->isChecked()) {
         if (aspect != old_props.value("force_aspect_ratio").toDouble()) {
index 27d8912ad991e61572e0bfe1b4878113f86ba146..40560034ee33095d96cc7a25f6e046a23ea123c0 100644 (file)
@@ -485,12 +485,12 @@ void DocClipBase::setProperty(const QString &key, const QString &value) {
     } else if (key == "video_index") {
         if (value.isEmpty()) {
             m_properties.remove("video_index");
-            m_clipProducer->set("video_index", 0);
+            m_clipProducer->set("video_index", m_properties.value("default_video").toInt());
         } else m_clipProducer->set("video_index", value.toInt());
     } else if (key == "audio_index") {
         if (value.isEmpty()) {
             m_properties.remove("audio_index");
-            m_clipProducer->set("audio_index", 0);
+            m_clipProducer->set("audio_index", m_properties.value("default_audio").toInt());
         } else m_clipProducer->set("audio_index", value.toInt());
     }
 }
index 7d80895ec239410dbb98af28d25ad46f4f544322..442450e5c4e0dc40711e896cff262c2a0b080beb 100644 (file)
@@ -618,13 +618,43 @@ void Render::getFileProperties(const QDomElement &xml, const QString &clipId) {
         }*/
         // Get the video_index
         int index = mlt_properties_get_int(properties, "video_index");
+        int default_video = -1;
+        int video_max = 0;
+        int default_audio = -1;
+        int audio_max = 0;
+        // Find default audio stream (borrowed from MLT)
+        for (int ix = 0; ix < context->nb_streams; ix++) {
+            // Get the codec context
+            AVCodecContext *codec_context = context->streams[ ix ]->codec;
+
+            if (avcodec_find_decoder(codec_context->codec_id) == NULL)
+                continue;
+            // Determine the type and obtain the first index of each type
+            switch (codec_context->codec_type) {
+            case CODEC_TYPE_VIDEO:
+                if (default_video < 0) default_video = ix;
+                video_max = ix;
+                break;
+            case CODEC_TYPE_AUDIO:
+                if (default_audio < 0) default_audio = ix;
+                audio_max = ix;
+                break;
+            default:
+                break;
+            }
+        }
+        filePropertyMap["default_video"] = QString::number(default_video);
+        filePropertyMap["video_max"] = QString::number(video_max);
+        filePropertyMap["default_audio"] = QString::number(default_audio);
+        filePropertyMap["audio_max"] = QString::number(audio_max);
+
 
 #if ENABLE_FFMPEG_CODEC_DESCRIPTION
-        if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->long_name) {
+        if (index > -1 && context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->long_name) {
             filePropertyMap["videocodec"] = context->streams[ index ]->codec->codec->long_name;
         } else
 #endif
-            if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->name) {
+            if (index > -1 && context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->name) {
                 filePropertyMap["videocodec"] = context->streams[ index ]->codec->codec->name;
             }
     } else kDebug() << " / / / / /WARNING, VIDEO CONTEXT IS NULL!!!!!!!!!!!!!!";
@@ -634,11 +664,11 @@ void Render::getFileProperties(const QDomElement &xml, const QString &clipId) {
         int index = mlt_properties_get_int(properties, "audio_index");
 
 #if ENABLE_FFMPEG_CODEC_DESCRIPTION
-        if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->long_name)
+        if (index > -1 && context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->long_name)
             filePropertyMap["audiocodec"] = context->streams[ index ]->codec->codec->long_name;
         else
 #endif
-            if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->name)
+            if (index > -1 && context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->name)
                 filePropertyMap["audiocodec"] = context->streams[ index ]->codec->codec->name;
     }
 #endif
@@ -660,6 +690,7 @@ void Render::getFileProperties(const QDomElement &xml, const QString &clipId) {
     //if (producer) delete producer;
 }
 
+
 /** Create the producer from the Westley QDomDocument */
 #if 0
 void Render::initSceneList() {