- if (producer->get_double("meta.media.frame_rate_den") > 0) {
- filePropertyMap["fps"] = QString::number(producer->get_double("meta.media.frame_rate_num") / producer->get_double("meta.media.frame_rate_den"));
- } else filePropertyMap["fps"] = producer->get("source_fps");
-
- if (frame && frame->is_valid()) {
- filePropertyMap["frame_size"] = QString::number(frame->get_int("width")) + 'x' + QString::number(frame->get_int("height"));
- filePropertyMap["frequency"] = QString::number(frame->get_int("frequency"));
- filePropertyMap["channels"] = QString::number(frame->get_int("channels"));
- filePropertyMap["aspect_ratio"] = frame->get("aspect_ratio");
-
- if (frame->get_int("test_image") == 0) {
- if (url.path().endsWith(".mlt") || url.path().endsWith(".westley") || url.path().endsWith(".kdenlive")) {
- filePropertyMap["type"] = "playlist";
- metadataPropertyMap["comment"] = QString::fromUtf8(producer->get("title"));
- } else if (frame->get_int("test_audio") == 0)
- filePropertyMap["type"] = "av";
- else
- filePropertyMap["type"] = "video";
-
- mlt_image_format format = mlt_image_rgb24a;
- int frame_width = width;
- int frame_height = imageHeight;
- uint8_t *data = frame->get_image(format, frame_width, frame_height, 0);
- QImage image((uchar *)data, frame_width, frame_height, QImage::Format_ARGB32_Premultiplied);
- QPixmap pix;
-
- if (!image.isNull()) {
- if (frame_width > (2 * width)) {
- // there was a scaling problem, do it manually
- QImage scaled = image.scaled(width, imageHeight);
- pix = QPixmap::fromImage(scaled.rgbSwapped());
- } else pix = QPixmap::fromImage(image.rgbSwapped());
- } else
- pix.fill(Qt::black);
-
- emit replyGetImage(clipId, pix);
-
- } else if (frame->get_int("test_audio") == 0) {
- QPixmap pixmap = KIcon("audio-x-generic").pixmap(QSize(width, imageHeight));
- emit replyGetImage(clipId, pixmap);
- filePropertyMap["type"] = "audio";
- }
- }
- delete frame;
- // Retrieve audio / video codec name
-
- // If there is a
- char property[200];
- if (producer->get_int("video_index") > -1) {
- /*if (context->duration == AV_NOPTS_VALUE) {
- kDebug() << " / / / / / / / /ERROR / / / CLIP HAS UNKNOWN DURATION";
- emit removeInvalidClip(clipId);
+ 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()) {
+ filePropertyMap["frame_size"] = QString::number(frame->get_int("width")) + 'x' + QString::number(frame->get_int("height"));
+ filePropertyMap["frequency"] = QString::number(frame->get_int("frequency"));
+ filePropertyMap["channels"] = QString::number(frame->get_int("channels"));
+ filePropertyMap["aspect_ratio"] = frame->get("aspect_ratio");
+
+ if (frame->get_int("test_image") == 0) {
+ if (url.path().endsWith(".mlt") || url.path().endsWith(".westley") || url.path().endsWith(".kdenlive")) {
+ filePropertyMap["type"] = "playlist";
+ metadataPropertyMap["comment"] = QString::fromUtf8(producer->get("title"));
+ } else if (frame->get_int("test_audio") == 0)
+ filePropertyMap["type"] = "av";
+ else
+ filePropertyMap["type"] = "video";
+
+ int variance;
+ QImage img;
+ do {
+ variance = 100;
+ img = KThumb::getFrame(frame, imageWidth, fullWidth, info.imageHeight);
+ variance = KThumb::imageVariance(img);
+ if (frameNumber == -1 && variance< 6) {
+ // Thumbnail is not interesting (for example all black, seek to fetch better thumb
+ frameNumber = duration > 100 ? 100 : duration / 2 ;
+ producer->seek(frameNumber);
+ delete frame;
+ frame = producer->get_frame();
+ variance = -1;
+ }
+ } while (variance == -1);
+ delete frame;
+ if (frameNumber > -1) filePropertyMap["thumbnail"] = frameNumber;
+ emit replyGetImage(info.clipId, img);
+ } else if (frame->get_int("test_audio") == 0) {
+ emit replyGetImage(info.clipId, "audio-x-generic", fullWidth, info.imageHeight);
+ filePropertyMap["type"] = "audio";
+ }
+ }
+ // Retrieve audio / video codec name
+
+ // If there is a
+ char property[200];
+ if (producer->get_int("video_index") > -1) {
+ /*if (context->duration == AV_NOPTS_VALUE) {
+ kDebug() << " / / / / / / / /ERROR / / / CLIP HAS UNKNOWN DURATION";
+ emit removeInvalidClip(clipId);