8 int info(char *filename)
12 Mlt::Factory::init(NULL);
14 // Load an arbitrary profile
15 Mlt::Profile prof("hdv_1080_25p");
18 std::cout << "MLT initialized, profile loaded. Loading clips ..." << std::endl;
21 Mlt::Producer producer(prof, filename);
22 if (!producer.is_valid()) {
23 std::cout << filename << " is invalid." << std::endl;
26 std::cout << "Successfully loaded producer " << filename << std::endl;
28 int streams = atoi(producer.get("meta.media.nb_streams"));
29 std::cout << "Number of streams: " << streams << std::endl;
32 for (int i = 0; i < streams; i++) {
33 std::string propertyName = QString("meta.media.%1.stream.type").arg(i).toStdString();
34 std::cout << "Producer " << i << ": " << producer.get(propertyName.c_str());
35 if (strcmp("audio", producer.get(propertyName.c_str())) == 0) {
36 std::cout << " (Using this stream)";
39 std::cout << std::endl;
42 if (audioStream >= 0) {
43 QMap<QString, QString> map;
44 map.insert("Sampling format", QString("meta.media.%1.codec.sample_fmt").arg(audioStream));
45 map.insert("Sampling rate", QString("meta.media.%1.codec.sample_rate").arg(audioStream));
46 map.insert("Bit rate", QString("meta.media.%1.codec.bit_rate").arg(audioStream));
47 map.insert("Channels", QString("meta.media.%1.codec.channels").arg(audioStream));
48 map.insert("Codec", QString("meta.media.%1.codec.name").arg(audioStream));
49 map.insert("Codec, long name", QString("meta.media.%1.codec.long_name").arg(audioStream));
51 std::cout << "Audio properties (stream " << audioStream << ")" << std::endl;
52 foreach (QString key, map.keys()) {
53 std::string value = map.value(key).toStdString();
54 std::cout << "\t" << key.toStdString() << ": " << producer.get(value.c_str())
55 << " (" << value << ")" << std::endl;
62 int main(int argc, char *argv[])
70 std::cout << "Usage: " << argv[0] << " <main audio file> <second audio file>" << std::endl;
73 std::cout << "Trying to align (1)\n\t" << fileSub << "\nto fit on (2)\n\t" << fileMain
74 << "\n, result will indicate by how much (1) has to be moved." << std::endl;
81 Mlt::Frame *frame = producer.get_frame();
84 float *data = (float*)frame->get_audio(format, samplingRate, channels, nSamples);
85 producer.set("video_index", "-1");
87 if (KdenliveSettings::normaliseaudiothumbs()) {
88 Mlt::Filter m_convert(prof, "volume");
89 m_convert.set("gain", "normalise");
90 producer.attach(m_convert);
95 double framesPerSecond = mlt_producer_get_fps(producer.get_producer());
96 Mlt::Frame *mlt_frame;
98 for (int z = (int) frame; z < (int)(frame + lengthInFrames) && producer.is_valid() && !m_abortAudioThumb; z++) {
99 val = (int)((z - frame) / (frame + lengthInFrames) * 100.0);
100 if (last_val != val && val > 1) {
101 setThumbsProgress(i18n("Creating audio thumbnail for %1", url.fileName()), val);
105 mlt_frame = producer.get_frame();
106 if (mlt_frame && mlt_frame->is_valid()) {
107 int samples = mlt_sample_calculator(framesPerSecond, frequency, mlt_frame_get_position(mlt_frame->get_frame()));
108 qint16* pcm = static_cast<qint16*>(mlt_frame->get_audio(audioFormat, frequency, channels, samples));
109 for (int c = 0; c < channels; c++) {
110 QByteArray audioArray;
111 audioArray.resize(arrayWidth);
112 for (int i = 0; i < audioArray.size(); i++) {
113 audioArray[i] = ((*(pcm + c + i * samples / audioArray.size())) >> 9) + 127 / 2 ;
116 storeIn[z][c] = audioArray;
119 f.write(QByteArray(arrayWidth, '\x00'));
124 setThumbsProgress(i18n("Creating audio thumbnail for %1", url.fileName()), -1);
125 if (m_abortAudioThumb) {
128 clip->updateAudioThumbnail(storeIn);