X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Frenderer.cpp;h=51670b58118d0e16a4a3131f7b337dd36564b34e;hb=f90fd0bd3c420f17c41b4375bbc4e6c520343c4c;hp=0f457483ca8d78c9e8ef3fbb34701e28b5053079;hpb=c148205d494f207b0a0cfeb882e78918124cc10b;p=kdenlive diff --git a/src/renderer.cpp b/src/renderer.cpp index 0f457483..51670b58 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -53,6 +53,7 @@ #include +#define SEEK_INACTIVE (-1) static void kdenlive_callback(void* /*ptr*/, int level, const char* fmt, va_list vl) { @@ -105,6 +106,7 @@ static void consumer_gl_frame_show(mlt_consumer, Render * self, mlt_frame frame_ Render::Render(Kdenlive::MONITORID rendererName, int winid, QString profile, QWidget *parent) : AbstractRender(rendererName, parent), + requestedSeekPosition(SEEK_INACTIVE), m_name(rendererName), m_mltConsumer(NULL), m_mltProducer(NULL), @@ -118,6 +120,7 @@ Render::Render(Kdenlive::MONITORID rendererName, int winid, QString profile, QWi m_blackClip(NULL), m_winid(winid) { + qRegisterMetaType ("stringMap"); analyseAudio = KdenliveSettings::monitor_audio(); if (profile.isEmpty()) profile = KdenliveSettings::current_profile(); buildConsumer(profile); @@ -127,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,QList,stringMap)), this, SLOT(slotMultiStreamProducerFound(const QString &,QList,QList,stringMap))); } Render::~Render() @@ -189,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"); @@ -211,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())); @@ -242,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); @@ -285,7 +301,7 @@ void Render::buildConsumer(const QString &profileName) Mlt::Producer *Render::invalidProducer(const QString &id) { Mlt::Producer *clip; - QString txt = "+" + i18n("Missing clip") + ".txt"; + QString txt = '+' + i18n("Missing clip") + ".txt"; char *tmp = qstrdup(txt.toUtf8().constData()); clip = new Mlt::Producer(*m_mltProfile, tmp); delete[] tmp; @@ -324,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(); @@ -376,24 +386,23 @@ int Render::resetProfile(const QString &profileName, bool dropSceneList) void Render::seek(GenTime time) { - if (!m_mltProducer) - return; - - m_mltProducer->seek((int)(time.frames(m_fps))); - if (m_mltProducer->get_speed() == 0) { - refresh(); - } + int pos = time.frames(m_fps); + seek(pos); } void Render::seek(int time) { if (!m_mltProducer) return; - - m_mltProducer->seek(time); - if (m_mltProducer->get_speed() == 0) { - refresh(); + if (requestedSeekPosition == SEEK_INACTIVE) { + requestedSeekPosition = time; + m_mltProducer->seek(time); + m_mltConsumer->purge(); + if (m_mltProducer->get_speed() == 0) { + refresh(); + } } + else requestedSeekPosition = time; } //static @@ -531,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++; } } @@ -861,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 audio_list; + QList 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 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()) { @@ -917,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; @@ -1032,6 +1076,7 @@ void Render::initSceneList() int Render::setProducer(Mlt::Producer *producer, int position) { m_refreshTimer.stop(); + requestedSeekPosition = SEEK_INACTIVE; QMutexLocker locker(&m_mutex); QString currentId; int consumerPosition = 0; @@ -1106,6 +1151,7 @@ int Render::setSceneList(QDomDocument list, int position) int Render::setSceneList(QString playlist, int position) { + requestedSeekPosition = SEEK_INACTIVE; m_refreshTimer.stop(); QMutexLocker locker(&m_mutex); if (m_winid == -1) return -1; @@ -1412,6 +1458,7 @@ void Render::start() void Render::stop() { + requestedSeekPosition = SEEK_INACTIVE; m_refreshTimer.stop(); QMutexLocker locker(&m_mutex); if (m_mltProducer == NULL) return; @@ -1428,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) { @@ -1440,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; @@ -1452,6 +1501,7 @@ void Render::pause() void Render::switchPlay(bool play) { QMutexLocker locker(&m_mutex); + requestedSeekPosition = SEEK_INACTIVE; if (!m_mltProducer || !m_mltConsumer) return; if (m_isZoneMode) resetZoneMode(); @@ -1482,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); @@ -1495,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))); @@ -1504,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"); @@ -1514,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; @@ -1527,7 +1581,7 @@ void Render::playZone(const GenTime & startTime, const GenTime & stopTime) void Render::resetZoneMode() { - if (!m_isZoneMode && !m_isLoopMode) return; + if (!m_mltProducer || (!m_isZoneMode && !m_isLoopMode)) return; m_mltProducer->set("out", m_originalOut); //m_mltProducer->set("eof", "pause"); m_isZoneMode = false; @@ -1536,22 +1590,16 @@ void Render::resetZoneMode() void Render::seekToFrame(int pos) { - if (!m_mltProducer) - return; resetZoneMode(); - m_mltProducer->seek(pos); - if (m_mltProducer->get_speed() == 0) { - refresh(); - } + seek(pos); } void Render::seekToFrameDiff(int diff) { - if (!m_mltProducer) - return; resetZoneMode(); - m_mltProducer->seek(m_mltProducer->position() + diff); - refresh(); + if (requestedSeekPosition == SEEK_INACTIVE) + seek(m_mltProducer->position() + diff); + else seek(requestedSeekPosition + diff); } void Render::doRefresh() @@ -1598,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(); } @@ -1629,7 +1678,16 @@ void Render::emitFrameUpdated(Mlt::Frame& frame) void Render::emitFrameNumber() { - if (m_mltConsumer) emit rendererPosition((int) m_mltConsumer->position()); + int currentPos = m_mltConsumer->position(); + if (currentPos == requestedSeekPosition) requestedSeekPosition = SEEK_INACTIVE; + emit rendererPosition(currentPos); + if (requestedSeekPosition != SEEK_INACTIVE) { + m_mltProducer->seek(requestedSeekPosition); + requestedSeekPosition = SEEK_INACTIVE; + if (m_mltProducer->get_speed() == 0) { + refresh(); + } + } } void Render::emitConsumerStopped() @@ -1875,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); @@ -1903,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); @@ -1913,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; @@ -1940,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++) { @@ -2871,7 +2933,7 @@ bool Render::mltEditEffect(int track, GenTime position, EffectsParameterList par } for (int j = 0; j < params.count(); j++) { - filter->set((params.at(j).name()).toUtf8().constData(), params.at(j).value().toUtf8().constData()); + filter->set(params.at(j).name().toUtf8().constData(), params.at(j).value().toUtf8().constData()); } for (int j = 0; j < filtersList.count(); j++) { @@ -3289,10 +3351,10 @@ void Render::fixAudioMixing(Mlt::Tractor tractor) mlt_service_unlock(serv); } -bool Render::mltResizeClipCrop(ItemInfo info, GenTime diff) +bool Render::mltResizeClipCrop(ItemInfo info, GenTime newCropStart) { Mlt::Service service(m_mltProducer->parent().get_service()); - int frameOffset = (int) diff.frames(m_fps); + int newCropFrame = (int) newCropStart.frames(m_fps); Mlt::Tractor tractor(service); Mlt::Producer trackProducer(tractor.track(info.track)); Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service()); @@ -3311,7 +3373,13 @@ bool Render::mltResizeClipCrop(ItemInfo info, GenTime diff) int previousStart = clip->get_in(); int previousOut = clip->get_out(); delete clip; - trackPlaylist.resize_clip(clipIndex, previousStart + frameOffset, previousOut + frameOffset); + if (previousStart == newCropFrame) { + kDebug() << "//////// No ReSIZING Required"; + service.unlock(); + return true; + } + int frameOffset = newCropFrame - previousStart; + trackPlaylist.resize_clip(clipIndex, newCropFrame, previousOut + frameOffset); service.unlock(); m_mltConsumer->set("refresh", 1); return true; @@ -3509,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) { @@ -4398,6 +4466,7 @@ const QString Render::activeClipId() //static bool Render::getBlackMagicDeviceList(KComboBox *devicelist) { + if (!KdenliveSettings::decklink_device_found()) return false; Mlt::Profile profile; Mlt::Producer bm(profile, "decklink"); int found_devices = 0; @@ -4405,6 +4474,7 @@ bool Render::getBlackMagicDeviceList(KComboBox *devicelist) bm.set("list_devices", 1); found_devices = bm.get_int("devices"); } + else KdenliveSettings::setDecklink_device_found(false); if (found_devices <= 0) { devicelist->setEnabled(false); return false; @@ -4419,6 +4489,7 @@ bool Render::getBlackMagicDeviceList(KComboBox *devicelist) bool Render::getBlackMagicOutputDeviceList(KComboBox *devicelist) { + if (!KdenliveSettings::decklink_device_found()) return false; Mlt::Profile profile; Mlt::Consumer bm(profile, "decklink"); int found_devices = 0; @@ -4426,6 +4497,7 @@ bool Render::getBlackMagicOutputDeviceList(KComboBox *devicelist) bm.set("list_devices", 1); found_devices = bm.get_int("devices"); } + else KdenliveSettings::setDecklink_device_found(false); if (found_devices <= 0) { devicelist->setEnabled(false); return false; @@ -4438,5 +4510,63 @@ bool Render::getBlackMagicOutputDeviceList(KComboBox *devicelist) return true; } +void Render::slotMultiStreamProducerFound(const QString path, QList audio_list, QList 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 groupList; + QList 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: "<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"