コード例 #1
0
QString ThumbnailProvider::cacheKey(Mlt::Producer& producer, int frameNumber)
{
    QString time = producer.frames_to_time(frameNumber, mlt_time_clock);
    // Reduce the precision to centiseconds to increase chance for cache hit
    // without much loss of accuracy.
    time = time.left(time.size() - 1);
    QString key = QString("%1 %2")
            .arg(producer.get("resource"))
            .arg(time);
    QCryptographicHash hash(QCryptographicHash::Sha1);
    hash.addData(key.toUtf8());
    return hash.result().toHex();
}
コード例 #2
0
ファイル: mltcontroller.cpp プロジェクト: GNUmedia/shotcut
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;
}
コード例 #3
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;
}