Ejemplo n.º 1
0
Mlt::Producer* DecklinkProducerWidget::producer(Mlt::Profile& profile)
{
    Mlt::Producer* p = new Mlt::Producer(profile,
        QString("consumer:decklink:%1").arg(ui->deviceCombo->currentIndex()).toAscii().constData());
    if (p->is_valid())
        p->set("profile", ui->profileCombo->itemData(ui->profileCombo->currentIndex()).toString().toAscii().constData());
    return p;
}
Ejemplo n.º 2
0
Mlt::Producer* Video4LinuxWidget::newProducer(Mlt::Profile& profile)
{
    if (!profile.is_explicit()) {
        Mlt::Profile ntscProfile("dv_ntsc");
        Mlt::Profile palProfile("dv_pal");
        if (ui->v4lWidthSpinBox->value() == ntscProfile.width() && ui->v4lHeightSpinBox->value() == ntscProfile.height()) {
            profile.set_sample_aspect(ntscProfile.sample_aspect_num(), ntscProfile.sample_aspect_den());
            profile.set_progressive(ntscProfile.progressive());
            profile.set_colorspace(ntscProfile.colorspace());
            profile.set_frame_rate(ntscProfile.frame_rate_num(), ntscProfile.frame_rate_den());
        } else if (ui->v4lWidthSpinBox->value() == palProfile.width() && ui->v4lHeightSpinBox->value() == palProfile.height()) {
            profile.set_sample_aspect(palProfile.sample_aspect_num(), palProfile.sample_aspect_den());
            profile.set_progressive(palProfile.progressive());
            profile.set_colorspace(palProfile.colorspace());
            profile.set_frame_rate(palProfile.frame_rate_num(), palProfile.frame_rate_den());
        } else {
            profile.set_width(ui->v4lWidthSpinBox->value());
            profile.set_height(ui->v4lHeightSpinBox->value());
            profile.set_sample_aspect(1, 1);
            profile.set_progressive(1);
            profile.set_colorspace(601);
            profile.set_frame_rate(ui->v4lFramerateSpinBox->value() * 10000, 10000);
        }
    }
    Mlt::Producer* p = new Mlt::Producer(profile, URL().toLatin1().constData());
    if (!p->is_valid()) {
        delete p;
        p = new Mlt::Producer(profile, "color:");
        p->set("resource1", QString("video4linux2:%1")
               .arg(ui->v4lLineEdit->text()).toLatin1().constData());
        p->set("error", 1);
    }
    else if (m_audioWidget) {
        Mlt::Producer* audio = dynamic_cast<AbstractProducerWidget*>(m_audioWidget)->newProducer(profile);
        Mlt::Tractor* tractor = new Mlt::Tractor;
        tractor->set("_profile", profile.get_profile(), 0);
        tractor->set_track(*p, 0);
        delete p;
        tractor->set_track(*audio, 1);
        delete audio;
        p = new Mlt::Producer(tractor->get_producer());
        delete tractor;
        p->set("resource1", QString("video4linux2:%1")
               .arg(ui->v4lLineEdit->text()).toLatin1().constData());
    }
    p->set("device", ui->v4lLineEdit->text().toLatin1().constData());
    p->set("width", ui->v4lWidthSpinBox->value());
    p->set("height", ui->v4lHeightSpinBox->value());
    if (ui->v4lFramerateSpinBox->value() > 0)
        p->set("framerate", ui->v4lFramerateSpinBox->value());
    p->set("standard", ui->v4lStandardCombo->currentText().toLatin1().constData());
    p->set("channel", ui->v4lChannelSpinBox->value());
    p->set("audio_ix", ui->v4lAudioComboBox->currentIndex());
    p->set("force_seekable", 0);
    p->set(kBackgroundCaptureProperty, 1);
    p->set(kShotcutCaptionProperty, "Video4Linux");
    return p;
}
Ejemplo n.º 3
0
void TimelineDock::selectTrackHead(int trackIndex)
{
    if (trackIndex >= 0) {
        int i = m_model.trackList().at(trackIndex).mlt_index;
        Mlt::Producer* producer = m_model.tractor()->track(i);
        if (producer && producer->is_valid())
            emit trackSelected(producer);
        delete producer;
    }
}
Ejemplo n.º 4
0
void ClearCommand::undo()
{
    m_model.close();
    Mlt::Producer* producer = new Mlt::Producer(MLT.profile(), "xml-string", m_xml.toUtf8().constData());
    if (producer->is_valid()) {
        producer->set("resource", "<playlist>");
        MAIN.open(producer);
        MLT.pause();
        MAIN.seekPlaylist(0);
    }
}
Ejemplo n.º 5
0
QString Controller::resource() const
{
    QString resource;
    if (!m_producer)
        return resource;
    resource = QString(m_producer->get("resource"));
    if (m_producer->type() == tractor_type) {
        Mlt::Tractor tractor((mlt_tractor) m_producer->get_service());
        Mlt::Multitrack* multitrack = tractor.multitrack();
        if (multitrack->is_valid()) {
            Mlt::Producer* producer = multitrack->track(0);
            if (producer->is_valid())
                resource = QString(producer->get("resource"));
            delete producer;
        }
        delete multitrack;
    }
    return resource;
}
Ejemplo n.º 6
0
Mlt::Producer *DirectShowVideoWidget::producer(Mlt::Profile& profile)
{
#if 0
    if (!profile.is_explicit()) {
        Mlt::Profile ntscProfile("dv_ntsc");
        Mlt::Profile palProfile("dv_pal");
        if (ui->v4lWidthSpinBox->value() == ntscProfile.width() && ui->v4lHeightSpinBox->value() == ntscProfile.height()) {
            profile.set_sample_aspect(ntscProfile.sample_aspect_num(), ntscProfile.sample_aspect_den());
            profile.set_progressive(ntscProfile.progressive());
            profile.set_colorspace(ntscProfile.colorspace());
            profile.set_frame_rate(ntscProfile.frame_rate_num(), ntscProfile.frame_rate_den());
        } else if (ui->v4lWidthSpinBox->value() == palProfile.width() && ui->v4lHeightSpinBox->value() == palProfile.height()) {
            profile.set_sample_aspect(palProfile.sample_aspect_num(), palProfile.sample_aspect_den());
            profile.set_progressive(palProfile.progressive());
            profile.set_colorspace(palProfile.colorspace());
            profile.set_frame_rate(palProfile.frame_rate_num(), palProfile.frame_rate_den());
        } else {
            profile.set_width(ui->v4lWidthSpinBox->value());
            profile.set_height(ui->v4lHeightSpinBox->value());
            profile.set_sample_aspect(1, 1);
            profile.set_progressive(1);
            profile.set_colorspace(601);
            profile.set_frame_rate(ui->v4lFramerateSpinBox->value() * 10000, 10000);
        }
    }
#endif
    Mlt::Producer* p = 0;
    if (ui->videoCombo->currentIndex() > 0) {
        p = new Mlt::Producer(profile, QString("dshow:video=%1")
                          .arg(ui->videoCombo->currentText())
                          .toLatin1().constData());
    }
    if (ui->audioCombo->currentIndex() > 0) {
        Mlt::Producer* audio = new Mlt::Producer(profile,
            QString("dshow:audio=%1").arg(ui->audioCombo->currentText())
                                     .toLatin1().constData());
        if (p && p->is_valid() && audio->is_valid()) {
            Mlt::Tractor* tractor = new Mlt::Tractor;
            tractor->set("_profile", profile.get_profile(), 0);
            tractor->set("resource", p->get("resource"));
            tractor->set("resource2", audio->get("resource"));
            tractor->set_track(*p, 0);
            delete p;
            tractor->set_track(*audio, 1);
            delete audio;
            p = tractor;
        } else {
            p = audio;
        }
    }
    if (!p || !p->is_valid()) {
        delete p;
        p = new Mlt::Producer(profile, "color:");
        if (ui->videoCombo->currentIndex() > 0) {
            p->set("resource", QString("dshow:video=%1")
                   .arg(ui->videoCombo->currentText())
                   .toLatin1().constData());
        }
        if (ui->audioCombo->currentIndex() > 0) {
            QString resource = QString("dshow:audio=%1").arg(ui->audioCombo->currentText());
            if (ui->videoCombo->currentIndex() > 0) {
                p->set("resource2", resource.toLatin1().constData());
            } else {
                p->set("resource", resource.toLatin1().constData());
            }
        }
        p->set("error", 1);
    }
    p->set("force_seekable", 0);
    return p;
}
Ejemplo n.º 7
0
void BinController::initializeBin(Mlt::Playlist playlist)
{
    // Load folders
    Mlt::Properties folderProperties;
    Mlt::Properties playlistProps(playlist.get_properties());
    folderProperties.pass_values(playlistProps, "kdenlive:folder.");
    QMap <QString,QString> foldersData;
    for (int i = 0; i < folderProperties.count(); i++) {
        foldersData.insert(folderProperties.get_name(i), folderProperties.get(i));
    }
    emit loadFolders(foldersData);

    // Read notes
    QString notes = playlistProps.get("kdenlive:documentnotes");
    emit setDocumentNotes(notes);

    // Fill Controller's list
    m_binPlaylist = new Mlt::Playlist(playlist);
    m_binPlaylist->set("id", kPlaylistTrackId);
    int max = m_binPlaylist->count();
    for (int i = 0; i < max; i++) {
        Mlt::Producer *producer = m_binPlaylist->get_clip(i);
        if (producer->is_blank() || !producer->is_valid()) continue;
        QString id = producer->parent().get("id");
        if (id.contains(QStringLiteral("_"))) {
            // This is a track producer
            QString mainId = id.section(QStringLiteral("_"), 0, 0);
            QString track = id.section(QStringLiteral("_"), 1, 1);
            if (m_clipList.contains(mainId)) {
                // The controller for this track producer already exists
            }
            else {
                // Create empty controller for this track
                ClipController *controller = new ClipController(this);
                m_clipList.insert(mainId, controller);
            }
            delete producer;
        }
        else {
            if (m_clipList.contains(id) && m_clipList.value(id)) {
                //Controller was already added by a track producer, add master now
                m_clipList.value(id)->addMasterProducer(producer->parent());
            }
            else {
                // Controller has not been created yet
                ClipController *controller = new ClipController(this, producer->parent());
                // fix MLT somehow adding root to color producer's resource (report upstream)
                if (strcmp(producer->parent().get("mlt_service"), "color") == 0) {
                    QString color = producer->parent().get("resource");
                    if (color.contains(QStringLiteral("/"))) {
                        color = color.section(QStringLiteral("/"), -1, -1);
                        producer->parent().set("resource", color.toUtf8().constData());
                    }
                }
                m_clipList.insert(id, controller);
            }
        }
        emit loadingBin(i + 1);
    }
    // Load markers
    Mlt::Properties markerProperties;
    markerProperties.pass_values(playlistProps, "kdenlive:marker.");
    QMap <QString,QString> markersData;
    for (int i = 0; i < markerProperties.count(); i++) {
        QString markerId = markerProperties.get_name(i);
        QString controllerId = markerId.section(QStringLiteral(":"), 0, 0);
        ClipController *ctrl = m_clipList.value(controllerId);
        if (!ctrl) continue;
        ctrl->loadSnapMarker(markerId.section(QStringLiteral(":"), 1), markerProperties.get(i));
    }
}