]> git.sesse.net Git - kdenlive/blobdiff - src/renderer.cpp
No need to delete consumer anymore when changing the profile
[kdenlive] / src / renderer.cpp
index d675671fee0f66f0881973595109b2585a02e638..51670b58118d0e16a4a3131f7b337dd36564b34e 100644 (file)
@@ -120,6 +120,7 @@ Render::Render(Kdenlive::MONITORID rendererName, int winid, QString profile, QWi
     m_blackClip(NULL),
     m_winid(winid)
 {
+    qRegisterMetaType<stringMap> ("stringMap");
     analyseAudio = KdenliveSettings::monitor_audio();
     if (profile.isEmpty()) profile = KdenliveSettings::current_profile();
     buildConsumer(profile);
@@ -129,6 +130,7 @@ Render::Render(Kdenlive::MONITORID rendererName, int winid, QString profile, QWi
     m_refreshTimer.setSingleShot(true);
     m_refreshTimer.setInterval(70);
     connect(&m_refreshTimer, SIGNAL(timeout()), this, SLOT(refresh()));
+    connect(this, SIGNAL(multiStreamFound(const QString &,QList<int>,QList<int>,stringMap)), this, SLOT(slotMultiStreamProducerFound(const QString &,QList<int>,QList<int>,stringMap)));
 }
 
 Render::~Render()
@@ -191,15 +193,23 @@ void Render::buildConsumer(const QString &profileName)
     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);
+    if (m_mltProfile) {
+       Mlt::Profile tmpProfile(m_activeProfile.toUtf8().constData());
+       m_mltProfile->set_colorspace(tmpProfile.colorspace());
+       m_mltProfile->set_frame_rate(tmpProfile.frame_rate_num(), tmpProfile.frame_rate_den());
+       m_mltProfile->set_height(tmpProfile.height());
+       m_mltProfile->set_width(tmpProfile.width());
+       m_mltProfile->set_progressive(tmpProfile.progressive());
+       m_mltProfile->set_sample_aspect(tmpProfile.sample_aspect_num(), tmpProfile.sample_aspect_den());
+       m_mltProfile->get_profile()->display_aspect_num = tmpProfile.display_aspect_num();
+       m_mltProfile->get_profile()->display_aspect_den = tmpProfile.display_aspect_den();
+    }
+    else {
+       m_mltProfile = new Mlt::Profile(m_activeProfile.toUtf8().constData());
+    }
+    setenv("MLT_PROFILE", m_activeProfile.toUtf8().constData(), 1);
     m_mltProfile->set_explicit(true);
-    delete[] tmp;
 
     m_blackClip = new Mlt::Producer(*m_mltProfile, "colour", "black");
     m_blackClip->set("id", "black");
@@ -213,16 +223,16 @@ void Render::buildConsumer(const QString &profileName)
         if (device >= 0) {
             if (BMInterface::isSupportedProfile(device, profileProperties)) {
                 QString decklink = "decklink:" + QString::number(KdenliveSettings::blackmagic_output_device());
-                tmp = qstrdup(decklink.toUtf8().constData());
-                m_mltConsumer = new Mlt::Consumer(*m_mltProfile, tmp);
-                delete[] tmp;
+                if (!m_mltConsumer) {
+                   m_mltConsumer = new Mlt::Consumer(*m_mltProfile, decklink.toUtf8().constData());
+                   m_showFrameEvent = m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_frame_show);
+                   mlt_log_set_callback(kdenlive_callback);
+               }
                 if (m_mltConsumer->is_valid()) {
                     m_externalConsumer = true;
-                    m_showFrameEvent = m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_frame_show);
                     m_mltConsumer->set("terminate_on_pause", 0);
                     m_mltConsumer->set("deinterlace_method", "onefield");
                     m_mltConsumer->set("real_time", KdenliveSettings::mltthreads());
-                    mlt_log_set_callback(kdenlive_callback);
                 }
                 if (m_mltConsumer && m_mltConsumer->is_valid()) return;
             } else KMessageBox::informationList(qApp->activeWindow(), i18n("Your project's profile %1 is not compatible with the blackmagic output card. Please see supported profiles below. Switching to normal video display.", m_mltProfile->description()), BMInterface::supportedModes(KdenliveSettings::blackmagic_output_device()));
@@ -244,15 +254,19 @@ void Render::buildConsumer(const QString &profileName)
     //m_mltConsumer->set("fullscreen", 1);
     if (m_winid == 0) {
         // OpenGL monitor
-        m_mltConsumer = new Mlt::Consumer(*m_mltProfile, "sdl_audio");
+        if (!m_mltConsumer) {
+           m_mltConsumer = new Mlt::Consumer(*m_mltProfile, "sdl_audio");
+           m_showFrameEvent = m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_gl_frame_show);
+       }
         m_mltConsumer->set("preview_off", 1);
         m_mltConsumer->set("preview_format", mlt_image_rgb24a);
-        m_showFrameEvent = m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_gl_frame_show);
     } else {
-        m_mltConsumer = new Mlt::Consumer(*m_mltProfile, "sdl_preview");
-        m_showFrameEvent = m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_frame_show);
-        m_pauseEvent = m_mltConsumer->listen("consumer-sdl-paused", this, (mlt_listener) consumer_paused);
-        m_mltConsumer->set("window_id", m_winid);
+        if (!m_mltConsumer) {
+           m_mltConsumer = new Mlt::Consumer(*m_mltProfile, "sdl_preview");
+         m_showFrameEvent = m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_frame_show);
+         m_pauseEvent = m_mltConsumer->listen("consumer-sdl-paused", this, (mlt_listener) consumer_paused);
+       }
+       m_mltConsumer->set("window_id", m_winid);
     }
     m_mltConsumer->set("resize", 1);
     m_mltConsumer->set("terminate_on_pause", 1);
@@ -326,12 +340,6 @@ int Render::resetProfile(const QString &profileName, bool dropSceneList)
         if (m_isSplitView) slotSplitView(false);
         if (!m_mltConsumer->is_stopped()) m_mltConsumer->stop();
         m_mltConsumer->purge();
-        if (m_showFrameEvent) delete m_showFrameEvent;
-        m_showFrameEvent = NULL;
-        if (m_pauseEvent) delete m_pauseEvent;
-        m_pauseEvent = NULL;
-        delete m_mltConsumer;
-        m_mltConsumer = NULL;
     }
     QString scene;
     if (!dropSceneList) scene = sceneList();
@@ -387,12 +395,14 @@ void Render::seek(int time)
     if (!m_mltProducer)
         return;
     if (requestedSeekPosition == SEEK_INACTIVE) {
+       requestedSeekPosition = time;
        m_mltProducer->seek(time);
+       m_mltConsumer->purge();
        if (m_mltProducer->get_speed() == 0) {
            refresh();
        }
     }
-    requestedSeekPosition = time;
+    else requestedSeekPosition = time;
 }
 
 //static
@@ -530,26 +540,25 @@ void Render::slotSplitView(bool doit)
                 transition->set("b_track", i);
                 transition->set("distort", 1);
                 transition->set("internal_added", "200");
-                const char *tmp;
+                QString geometry;
                 switch (screen) {
                 case 0:
-                    tmp = "0,0:50%x50%";
+                    geometry = "0/0:50%x50%";
                     break;
                 case 1:
-                    tmp = "50%,0:50%x50%";
+                    geometry = "50%/0:50%x50%";
                     break;
                 case 2:
-                    tmp = "0,50%:50%x50%";
+                    geometry = "0/50%:50%x50%";
                     break;
                 case 3:
                 default:
-                    tmp = "50%,50%:50%x50%";
+                    geometry = "50%/50%:50%x50%";
                     break;
                 }
-                transition->set("geometry", tmp);
+                transition->set("geometry", geometry.toUtf8().constData());
                 transition->set("always_active", "1");
                 field->plant_transition(*transition, 0, i);
-                //delete[] tmp;
                 screen++;
             }
         }
@@ -860,19 +869,53 @@ void Render::processFileProperties()
             }
         }
 
-        // Get frame rate
-        int vindex = producer->get_int("video_index");
-        if (vindex > -1) {
-            snprintf(property, sizeof(property), "meta.media.%d.stream.frame_rate", vindex);
-            if (producer->get(property))
-                filePropertyMap["fps"] = producer->get(property);
-        }
+       int vindex = -1;
+       const QString mltService = producer->get("mlt_service");
+       
+       if (mltService == "xml" || mltService == "consumer") {
+           // MLT playlist
+           mlt_profile prof = producer->get_profile();
+           filePropertyMap["progressive"] = QString::number(prof->progressive);
+           filePropertyMap["colorspace"] = QString::number(prof->colorspace);
+           filePropertyMap["fps"] = QString::number(mlt_profile_fps(prof));
+       }
+       else if (mltService == "avformat") {
+           // Get frame rate
+           vindex = producer->get_int("video_index");
+
+           // List streams
+           int streams = producer->get_int("meta.media.nb_streams");
+           QList <int> audio_list;
+           QList <int> video_list;
+           for (int i = 0; i < streams; i++) {
+               QByteArray propertyName = QString("meta.media.%1.stream.type").arg(i).toLocal8Bit();
+               QString type = producer->get(propertyName.data());
+               if (type == "audio") audio_list.append(i);
+               else if (type == "video") video_list.append(i);
+           }
 
-        if (!filePropertyMap.contains("fps")) {
-            if (producer->get_double("meta.media.frame_rate_den") > 0) {
-                filePropertyMap["fps"] = locale.toString(producer->get_double("meta.media.frame_rate_num") / producer->get_double("meta.media.frame_rate_den"));
-            } else filePropertyMap["fps"] = producer->get("source_fps");
-        }
+           if (!info.xml.hasAttribute("video_index") && video_list.count() > 1) {
+               // Clip has more than one video stream, ask which one should be used
+               QMap <QString, QString> data;
+               if (info.xml.hasAttribute("group")) data.insert("group", info.xml.attribute("group"));
+               if (info.xml.hasAttribute("groupId")) data.insert("groupId", info.xml.attribute("groupId"));
+               emit multiStreamFound(path, audio_list, video_list, data);
+               // Force video index so that when reloading the clip we don't ask again for other streams
+               filePropertyMap["video_index"] = QString::number(vindex);
+           }
+       
+           if (vindex > -1) {
+               snprintf(property, sizeof(property), "meta.media.%d.stream.frame_rate", vindex);
+               if (producer->get(property))
+                   filePropertyMap["fps"] = producer->get(property);
+           }
+
+           if (!filePropertyMap.contains("fps")) {
+               if (producer->get_double("meta.media.frame_rate_den") > 0) {
+                   filePropertyMap["fps"] = locale.toString(producer->get_double("meta.media.frame_rate_num") / producer->get_double("meta.media.frame_rate_den"));
+               } else filePropertyMap["fps"] = producer->get("source_fps");
+           }
+       }
 
         Mlt::Frame *frame = producer->get_frame();
         if (frame && frame->is_valid()) {
@@ -916,61 +959,63 @@ void Render::processFileProperties()
         // Retrieve audio / video codec name
         // If there is a
 
-        if (vindex > -1) {
-            /*if (context->duration == AV_NOPTS_VALUE) {
-            kDebug() << " / / / / / / / /ERROR / / / CLIP HAS UNKNOWN DURATION";
-                emit removeInvalidClip(clipId);
-            delete producer;
-            return;
-            }*/
-            // Get the video_index
-            int video_max = 0;
-            int default_audio = producer->get_int("audio_index");
-            int audio_max = 0;
-
-            int scan = producer->get_int("meta.media.progressive");
-            filePropertyMap["progressive"] = QString::number(scan);
-
-            // Find maximum stream index values
-            for (int ix = 0; ix < producer->get_int("meta.media.nb_streams"); ix++) {
-                snprintf(property, sizeof(property), "meta.media.%d.stream.type", ix);
-                QString type = producer->get(property);
-                if (type == "video")
-                    video_max = ix;
-                else if (type == "audio")
-                    audio_max = ix;
-            }
-            filePropertyMap["default_video"] = QString::number(vindex);
-            filePropertyMap["video_max"] = QString::number(video_max);
-            filePropertyMap["default_audio"] = QString::number(default_audio);
-            filePropertyMap["audio_max"] = QString::number(audio_max);
-
-            snprintf(property, sizeof(property), "meta.media.%d.codec.long_name", vindex);
-            if (producer->get(property)) {
-                filePropertyMap["videocodec"] = producer->get(property);
-            } else {
-                snprintf(property, sizeof(property), "meta.media.%d.codec.name", vindex);
-                if (producer->get(property))
-                    filePropertyMap["videocodec"] = producer->get(property);
-            }
-            QString query;
-            query = QString("meta.media.%1.codec.pix_fmt").arg(vindex);
-            filePropertyMap["pix_fmt"] = producer->get(query.toUtf8().constData());
-            filePropertyMap["colorspace"] = producer->get("meta.media.colorspace");
-
-        } else kDebug() << " / / / / /WARNING, VIDEO CONTEXT IS NULL!!!!!!!!!!!!!!";
-        if (producer->get_int("audio_index") > -1) {
-            // Get the audio_index
-            int index = producer->get_int("audio_index");
-            snprintf(property, sizeof(property), "meta.media.%d.codec.long_name", index);
-            if (producer->get(property)) {
-                filePropertyMap["audiocodec"] = producer->get(property);
-            } else {
-                snprintf(property, sizeof(property), "meta.media.%d.codec.name", index);
-                if (producer->get(property))
-                    filePropertyMap["audiocodec"] = producer->get(property);
-            }
-        }
+        if (mltService == "avformat") {
+           if (vindex > -1) {
+               /*if (context->duration == AV_NOPTS_VALUE) {
+               kDebug() << " / / / / / / / /ERROR / / / CLIP HAS UNKNOWN DURATION";
+                   emit removeInvalidClip(clipId);
+               delete producer;
+               return;
+               }*/
+               // Get the video_index
+               int video_max = 0;
+               int default_audio = producer->get_int("audio_index");
+               int audio_max = 0;
+
+               int scan = producer->get_int("meta.media.progressive");
+               filePropertyMap["progressive"] = QString::number(scan);
+
+               // Find maximum stream index values
+               for (int ix = 0; ix < producer->get_int("meta.media.nb_streams"); ix++) {
+                   snprintf(property, sizeof(property), "meta.media.%d.stream.type", ix);
+                   QString type = producer->get(property);
+                   if (type == "video")
+                       video_max = ix;
+                   else if (type == "audio")
+                       audio_max = ix;
+               }
+               filePropertyMap["default_video"] = QString::number(vindex);
+               filePropertyMap["video_max"] = QString::number(video_max);
+               filePropertyMap["default_audio"] = QString::number(default_audio);
+               filePropertyMap["audio_max"] = QString::number(audio_max);
+
+               snprintf(property, sizeof(property), "meta.media.%d.codec.long_name", vindex);
+               if (producer->get(property)) {
+                   filePropertyMap["videocodec"] = producer->get(property);
+               } else {
+                   snprintf(property, sizeof(property), "meta.media.%d.codec.name", vindex);
+                   if (producer->get(property))
+                       filePropertyMap["videocodec"] = producer->get(property);
+               }
+               QString query;
+               query = QString("meta.media.%1.codec.pix_fmt").arg(vindex);
+               filePropertyMap["pix_fmt"] = producer->get(query.toUtf8().constData());
+               filePropertyMap["colorspace"] = producer->get("meta.media.colorspace");
+
+           } else kDebug() << " / / / / /WARNING, VIDEO CONTEXT IS NULL!!!!!!!!!!!!!!";
+           if (producer->get_int("audio_index") > -1) {
+               // Get the audio_index
+               int index = producer->get_int("audio_index");
+               snprintf(property, sizeof(property), "meta.media.%d.codec.long_name", index);
+               if (producer->get(property)) {
+                   filePropertyMap["audiocodec"] = producer->get(property);
+               } else {
+                   snprintf(property, sizeof(property), "meta.media.%d.codec.name", index);
+                   if (producer->get(property))
+                       filePropertyMap["audiocodec"] = producer->get(property);
+               }
+           }
+       }
 
         // metadata
         Mlt::Properties metadata;
@@ -1413,6 +1458,7 @@ void Render::start()
 
 void Render::stop()
 {
+    requestedSeekPosition = SEEK_INACTIVE;
     m_refreshTimer.stop();
     QMutexLocker locker(&m_mutex);
     if (m_mltProducer == NULL) return;
@@ -1429,6 +1475,7 @@ void Render::stop()
 
 void Render::stop(const GenTime & startTime)
 {
+    requestedSeekPosition = SEEK_INACTIVE;
     m_refreshTimer.stop();
     QMutexLocker locker(&m_mutex);
     if (m_mltProducer) {
@@ -1441,6 +1488,7 @@ void Render::stop(const GenTime & startTime)
 
 void Render::pause()
 {
+    requestedSeekPosition = SEEK_INACTIVE;
     if (!m_mltProducer || !m_mltConsumer)
         return;
     if (m_mltProducer->get_speed() == 0.0) return;
@@ -1484,6 +1532,7 @@ void Render::switchPlay(bool play)
 
 void Render::play(double speed)
 {
+    requestedSeekPosition = SEEK_INACTIVE;
     if (!m_mltProducer)
         return;
     // if (speed == 0.0) m_mltProducer->set("out", m_mltProducer->get_length() - 1);
@@ -1497,6 +1546,7 @@ void Render::play(double speed)
 
 void Render::play(const GenTime & startTime)
 {
+    requestedSeekPosition = SEEK_INACTIVE;
     if (!m_mltProducer || !m_mltConsumer)
         return;
     m_mltProducer->seek((int)(startTime.frames(m_fps)));
@@ -1506,6 +1556,7 @@ void Render::play(const GenTime & startTime)
 
 void Render::loopZone(const GenTime & startTime, const GenTime & stopTime)
 {
+    requestedSeekPosition = SEEK_INACTIVE;
     if (!m_mltProducer || !m_mltConsumer)
         return;
     //m_mltProducer->set("eof", "loop");
@@ -1516,6 +1567,7 @@ void Render::loopZone(const GenTime & startTime, const GenTime & stopTime)
 
 void Render::playZone(const GenTime & startTime, const GenTime & stopTime)
 {
+    requestedSeekPosition = SEEK_INACTIVE;
     if (!m_mltProducer || !m_mltConsumer)
         return;
     if (!m_isZoneMode) m_originalOut = m_mltProducer->get_playtime() - 1;
@@ -1545,7 +1597,9 @@ void Render::seekToFrame(int pos)
 void Render::seekToFrameDiff(int diff)
 {
     resetZoneMode();
-    seek(m_mltProducer->position() + diff);
+    if (requestedSeekPosition == SEEK_INACTIVE)
+       seek(m_mltProducer->position() + diff);
+    else seek(requestedSeekPosition + diff);
 }
 
 void Render::doRefresh()
@@ -1592,7 +1646,8 @@ double Render::playSpeed() const
 
 GenTime Render::seekPosition() const
 {
-    if (m_mltProducer) return GenTime((int) m_mltProducer->position(), m_fps);
+    if (m_mltConsumer) return GenTime((int) m_mltConsumer->position(), m_fps);
+    //if (m_mltProducer) return GenTime((int) m_mltProducer->position(), m_fps);
     else return GenTime();
 }
 
@@ -1628,6 +1683,7 @@ void Render::emitFrameNumber()
     emit rendererPosition(currentPos);
     if (requestedSeekPosition != SEEK_INACTIVE) {
        m_mltProducer->seek(requestedSeekPosition);
+       requestedSeekPosition = SEEK_INACTIVE;
        if (m_mltProducer->get_speed() == 0) {
            refresh();
        }
@@ -1877,12 +1933,12 @@ int Render::mltInsertClip(ItemInfo info, QDomElement element, Mlt::Producer *pro
 }
 
 
-void Render::mltCutClip(int track, GenTime position)
+bool Render::mltCutClip(int track, GenTime position)
 {
     Mlt::Service service(m_mltProducer->parent().get_service());
     if (service.type() != tractor_type) {
         kWarning() << "// TRACTOR PROBLEM";
-        return;
+        return false;
     }
 
     Mlt::Tractor tractor(service);
@@ -1905,7 +1961,7 @@ void Render::mltCutClip(int track, GenTime position)
     int clipIndex = trackPlaylist.get_clip_index_at(cutPos);
     if (trackPlaylist.is_blank(clipIndex)) {
         kDebug() << "// WARNING, TRYING TO CUT A BLANK";
-        return;
+        return false;
     }
     service.lock();
     int clipStart = trackPlaylist.clip_start(clipIndex);
@@ -1915,12 +1971,16 @@ void Render::mltCutClip(int track, GenTime position)
     // duplicate effects
     Mlt::Producer *original = trackPlaylist.get_clip_at(clipStart);
     Mlt::Producer *clip = trackPlaylist.get_clip_at(cutPos);
-
+    
     if (original == NULL || clip == NULL) {
         kDebug() << "// ERROR GRABBING CLIP AFTER SPLIT";
+       return false;
     }
+
     Mlt::Service clipService(original->get_service());
     Mlt::Service dupService(clip->get_service());
+
+
     delete original;
     delete clip;
     int ct = 0;
@@ -1942,7 +2002,7 @@ void Render::mltCutClip(int track, GenTime position)
         ct++;
         filter = clipService.filter(ct);
     }
-
+    return true;
     /* // Display playlist info
     kDebug()<<"////////////  AFTER";
     for (int i = 0; i < trackPlaylist.count(); i++) {
@@ -3517,7 +3577,7 @@ bool Render::mltMoveClip(int startTrack, int endTrack, int moveStart, int moveEn
             // check if we are moving a slowmotion producer
             QString serv = clipProducer->parent().get("mlt_service");
             QString currentid = clipProducer->parent().get("id");
-            if (serv == "framebuffer" || currentid.endsWith("_video")) {
+            if (serv == "framebuffer") {
                 clip = clipProducer;
             } else {
                 if (prod == NULL) {
@@ -4450,5 +4510,63 @@ bool Render::getBlackMagicOutputDeviceList(KComboBox *devicelist)
     return true;
 }
 
+void Render::slotMultiStreamProducerFound(const QString path, QList<int> audio_list, QList<int> video_list, stringMap data)
+{
+    int width = 60.0 * m_mltProfile->dar();
+    int swidth = 60.0 * m_mltProfile->width() / m_mltProfile->height();
+    if (width % 2 == 1) width++;
+
+    KDialog dialog(qApp->activeWindow());
+    dialog.setCaption("Multi Stream Clip");
+    dialog.setButtons(KDialog::Ok | KDialog::Cancel);
+    dialog.setButtonText(KDialog::Ok, i18n("Import selected clips"));
+    QWidget *content = new QWidget(&dialog);
+    dialog.setMainWidget(content);
+    QVBoxLayout *vbox = new QVBoxLayout(content);
+    QLabel *lab1 = new QLabel(i18n("Additional streams for clip\n %1", path), content);
+    vbox->addWidget(lab1);
+    QList <QGroupBox*> groupList;
+    QList <QComboBox*> comboList;
+    // We start loading the list at 1, video index 0 should already be loaded
+    for (int j = 1; j < video_list.count(); j++) {
+       Mlt::Producer multiprod(* m_mltProfile, path.toUtf8().constData());
+       multiprod.set("video_index", video_list.at(j));
+       kDebug()<<"// LOADING: "<<j<<" = "<<video_list.at(j);
+       QImage thumb = KThumb::getFrame(&multiprod, 0, swidth, width, 60);
+       QGroupBox *streamFrame = new QGroupBox(i18n("Video stream %1", video_list.at(j)), content);
+       streamFrame->setProperty("vindex", video_list.at(j));
+       groupList << streamFrame;
+       streamFrame->setCheckable(true);
+       streamFrame->setChecked(false);
+       QVBoxLayout *vh = new QVBoxLayout( streamFrame );
+       QLabel *iconLabel = new QLabel(content);
+       iconLabel->setPixmap(QPixmap::fromImage(thumb));
+       vh->addWidget(iconLabel);
+       if (audio_list.count() > 1) {
+           QComboBox *cb = new QComboBox(content);
+           for (int k = 0; k < audio_list.count(); k++) {
+               cb->addItem(i18n("Audio stream %1", audio_list.at(k)), audio_list.at(k));
+           }
+           comboList << cb;
+           cb->setCurrentIndex(j);
+           vh->addWidget(cb);
+       }
+       vbox->addWidget(streamFrame);
+    }
+    if (dialog.exec() == QDialog::Accepted) {
+       // import selected streams
+       for (int i = 0; i < groupList.count(); i++) {
+           if (groupList.at(i)->isChecked()) {
+               int vindex = groupList.at(i)->property("vindex").toInt();
+               int aindex = comboList.at(i)->itemData(comboList.at(i)->currentIndex()).toInt();
+               data.insert("video_index", QString::number(vindex));
+               data.insert("audio_index", QString::number(aindex));
+               data.insert("bypassDuplicate", "1");
+               emit addClip(KUrl(path), data);
+           }
+       }
+    }
+}
+
 #include "renderer.moc"