-void Render::getFileProperties(const QDomElement &xml, int clipId)
-{
- int height = 40;
- int width = height * 16/9.0; //KdenliveSettings::displayratio();
- QDomDocument doc;
- QDomElement westley = doc.createElement("westley");
- doc.appendChild(westley);
- westley.appendChild(doc.importNode(xml, true));
- kDebug()<<"////////////\n"<<doc.toString()<<"////////////////\n";
- char *tmp = decodedString(doc.toString());
-
- Mlt::Producer producer(*m_mltProfile, "westley-xml", tmp);
- delete[] tmp;
-
- if (producer.is_blank()) {
- return;
- }
- int frameNumber = xml.attribute( "frame_thumbnail", 0).toInt();
- if ( frameNumber != 0 ) producer.seek( frameNumber );
- mlt_properties properties = MLT_PRODUCER_PROPERTIES( producer.get_producer() );
-
- QMap < QString, QString > filePropertyMap;
- QMap < QString, QString > metadataPropertyMap;
-
- KUrl url = xml.attribute("resource", QString::null);
- filePropertyMap["filename"] = url.path();
- filePropertyMap["duration"] = QString::number(producer.get_playtime());
- kDebug()<<"/////// PRODUCER: "<<url.path()<<" IS: "<<producer.get_playtime();
- Mlt::Filter m_convert(*m_mltProfile, "avcolour_space");
- m_convert.set("forced", mlt_image_rgb24a);
- producer.attach(m_convert);
- Mlt::Frame * frame = producer.get_frame();
-
- if (frame->is_valid()) {
- filePropertyMap["fps"] =
- QString::number(mlt_producer_get_fps( producer.get_producer() ));
- filePropertyMap["width"] =
- QString::number(frame->get_int("width"));
- filePropertyMap["height"] =
- QString::number(frame->get_int("height"));
- filePropertyMap["frequency"] =
- QString::number(frame->get_int("frequency"));
- filePropertyMap["channels"] =
- QString::number(frame->get_int("channels"));
-
- // Retrieve audio / video codec name
-
- // Fetch the video_context
- AVFormatContext *context = (AVFormatContext *) mlt_properties_get_data( properties, "video_context", NULL );
- if (context != NULL) {
- // Get the video_index
- int index = mlt_properties_get_int( properties, "video_index" );
- filePropertyMap["videocodec"] = context->streams[ index ]->codec->codec->name;
- }
- context = (AVFormatContext *) mlt_properties_get_data( properties, "audio_context", NULL );
- if (context != NULL) {
- // Get the video_index
- int index = mlt_properties_get_int( properties, "audio_index" );
- filePropertyMap["audiocodec"] = context->streams[ index ]->codec->codec->name;
- }
-
-
-
- // metadata
-
- mlt_properties metadata = mlt_properties_new( );
- mlt_properties_pass( metadata, properties, "meta.attr." );
- int count = mlt_properties_count( metadata );
- for ( int i = 0; i < count; i ++ )
- {
- QString name = mlt_properties_get_name( metadata, i );
- QString value = QString::fromUtf8(mlt_properties_get_value( metadata, i ));
- if (name.endsWith("markup") && !value.isEmpty())
- metadataPropertyMap[ name.section(".", 0, -2) ] = value;
- }
-
- if (frame->get_int("test_image") == 0) {
- if (url.path().endsWith(".westley") || url.path().endsWith(".kdenlive")) {
- filePropertyMap["type"] = "playlist";
- metadataPropertyMap["comment"] = QString::fromUtf8(mlt_properties_get( MLT_SERVICE_PROPERTIES( producer.get_service() ), "title"));
- }
- else if (frame->get_int("test_audio") == 0)
- filePropertyMap["type"] = "av";
- else
- filePropertyMap["type"] = "video";
-
- // Generate thumbnail for this frame
- QPixmap pixmap = frameThumbnail(frame, width, height, true);
-
- emit replyGetImage(clipId, 0, pixmap, width, height);
-
- } else if (frame->get_int("test_audio") == 0) {
- QPixmap pixmap(KStandardDirs::locate("appdata", "graphics/music.png"));
- emit replyGetImage(clipId, 0, pixmap, width, height);
- filePropertyMap["type"] = "audio";
- }
- }
- emit replyGetFileProperties(clipId, filePropertyMap, metadataPropertyMap);
- kDebug()<<"REquested fuile info for: "<<url.path();
- delete frame;
-}