Exemplo n.º 1
0
    void run()
    {
        QString setting = Settings.playlistThumbnails();
        if (setting == "hidden")
            return;

        QImage image = DB.getThumbnail(cacheKey(m_in));
        if (image.isNull()) {
            image = makeThumbnail(m_in);
            m_producer.set(kThumbnailInProperty, new QImage(image), 0, (mlt_destructor) deleteQImage, NULL);
            DB.putThumbnail(cacheKey(m_in), image);
        } else {
            m_producer.set(kThumbnailInProperty, new QImage(image), 0, (mlt_destructor) deleteQImage, NULL);
        }
        m_model->showThumbnail(m_row);

        if (setting == "tall" || setting == "wide") {
            image = DB.getThumbnail(cacheKey(m_out));
            if (image.isNull()) {
                image = makeThumbnail(m_out);
                m_producer.set(kThumbnailOutProperty, new QImage(image), 0, (mlt_destructor) deleteQImage, NULL);
                DB.putThumbnail(cacheKey(m_out), image);
            } else {
                m_producer.set(kThumbnailOutProperty, new QImage(image), 0, (mlt_destructor) deleteQImage, NULL);
            }
            m_model->showThumbnail(m_row);
        }
    }
Exemplo n.º 2
0
void QtResourceViewPrivate::createResources(const QString &path)
{
    const bool matchAll = m_filterPattern.isEmpty();

    QDir dir(path);
    QStringList fileNames = m_pathToContents.value(path);
    QStringListIterator it(fileNames);
    while (it.hasNext()) {
        QString fileName = it.next();
        const bool showProperty = matchAll || fileName.contains(m_filterPattern, Qt::CaseInsensitive);
        if (showProperty) {
            QString filePath = dir.absoluteFilePath(fileName);
            QFileInfo fi(filePath);
            if (fi.isFile()) {
                QListWidgetItem *item = new QListWidgetItem(fi.fileName(), m_listWidget);
                const QPixmap pix = QPixmap(filePath);
                if (pix.isNull()) {
                    item->setToolTip(filePath);
                } else {
                    item->setIcon(QIcon(makeThumbnail(pix)));
                    const QSize size = pix.size();
                    item->setToolTip(QtResourceView::tr("Size: %1 x %2\n%3").arg(size.width()).arg(size.height()).arg(filePath));
                }
                item->setFlags(item->flags() | Qt::ItemIsDragEnabled);
                item->setData(Qt::UserRole, filePath);
                m_itemToResource[item] = filePath;
                m_resourceToItem[filePath] = item;
            }
        }
    }
}
Exemplo n.º 3
0
QImage ThumbnailProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
{
    QImage result;

    // id is mlt_service/resource#frameNumber
    int index = id.lastIndexOf('#');

    if (index != -1) {
        QString service = id.section('/', 0, 0);
        QString resource = id.section('/', 1);
        int frameNumber = id.mid(index + 1).toInt();

        if (service == "avformat-novalidate")
            service = "avformat";
        else if (service.startsWith("xml"))
            service = "xml-nogl";
        resource = resource.left(resource.lastIndexOf('#'));

        Mlt::Producer producer(MLT.profile(), service.toUtf8().constData(), resource.toUtf8().constData());
        if (producer.is_valid()) {
            QString key = cacheKey(producer, frameNumber);
            result = DB.getThumbnail(key);
            if (result.isNull()) {
                result = makeThumbnail(producer, frameNumber, requestedSize);
                DB.putThumbnail(key, result);
            }
            if (size)
                *size = result.size();
        }
    }
    return result;
}
Exemplo n.º 4
0
HistoryDataPoint::HistoryDataPoint(long long date,
                                   std::map<int, boost::shared_ptr<Genome>> randomGenomeForEachSpecies,
                                   LandscapeParameters landscapeParameters,
                                   std::map<int, std::vector<std::pair<float, float> > > organismLocationsForEachSpecies) :
    m_date(date), m_landscapeParameters(landscapeParameters),
    m_organismLocationsForEachSpecies(organismLocationsForEachSpecies)
{
    //Make an organism for each genome.
    for (std::map<int, boost::shared_ptr<Genome>>::iterator i = randomGenomeForEachSpecies.begin();
         i != randomGenomeForEachSpecies.end(); ++i)
    {
        int speciesNumber = i->first;
        m_randomOrganismForEachSpecies[speciesNumber] = new Organism(i->second);
    }

    makeThumbnail();
}
Exemplo n.º 5
0
/**
 * Mux a h264 file to mp4, remove h264 and create a thumbnail
 * 
 * @param input the full path of the h264 file
 * @param outputCTime the ctime of the input file
 */
void muxAndCreateThumbnail(char* input, int ctime) {
    char videoOutput[256];
    snprintf(videoOutput, 256, "%s/%d.mp4", config.VideoSaveDirectory, ctime);

    syslog(LOG_INFO, "Muxing: %s -> %s.", input, videoOutput);
    
    //Muxing h264 to mp4
    {
        pid_t muxPid = mux(config.ffmpegPath, config.RaspividFramerate, input, videoOutput);
        if (muxPid < 0) {
            syslog(LOG_ERR, "Failed to create muxer thread.");
        } else {
            waitpid(muxPid, NULL, 0);   //Waiting
            syslog(LOG_INFO, "Video %s saved.", videoOutput);
        }
    }

    //Removing h264
    {
        int status = remove(input);
        if (status == 0) {
            syslog(LOG_INFO, "Temporary raw file %s removed.", input);
        } else {
            syslog(LOG_ERR, "Failed to remove %s: %d.", input, status);
        }
    }

    //Making a thumbnail for this video
    {
        pid_t thumbnailPid = makeThumbnail(config.ffmpegPath, config.ThumbnailWidth, config.ThumbnailFormat, videoOutput, config.ThumbnailSaveDirectory);
        if (thumbnailPid < 0) {
            syslog(LOG_ERR, "Failed to create thumbnail thread.");
        } else {
            waitpid(thumbnailPid, NULL, 0);  //Waiting
            syslog(LOG_INFO, "Thumbnail saved.");
        }
    }
}