From: Simon A. Eugster Date: Sun, 12 Feb 2012 11:46:15 +0000 (+0100) Subject: Successfully dumping audio information from the input files now :) X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=90c14d4bb82610998ec08178dfea570fbe56c61f;p=kdenlive Successfully dumping audio information from the input files now :) --- diff --git a/testingArea/audioOffset.cpp b/testingArea/audioOffset.cpp index 6e9a0b55..2f8351a8 100644 --- a/testingArea/audioOffset.cpp +++ b/testingArea/audioOffset.cpp @@ -1,23 +1,12 @@ +#include #include #include #include #include -int main(int argc, char *argv[]) +int info(char *filename) { - char *fileMain; - char *fileSub; - if (argc > 2) { - fileMain = argv[1]; - fileSub = argv[2]; - } else { - std::cout << "Usage: " << argv[0] << "
" << std::endl; - return 0; - } - std::cout << "Trying to align (1)\n\t" << fileSub << "\nto fit on (2)\n\t" << fileMain - << "\n, result will indicate by how much (1) has to be moved." << std::endl; - // Initialize MLT Mlt::Factory::init(NULL); @@ -29,26 +18,70 @@ int main(int argc, char *argv[]) std::cout << "MLT initialized, profile loaded. Loading clips ..." << std::endl; - Mlt::Producer producer(prof, fileMain); + Mlt::Producer producer(prof, filename); if (!producer.is_valid()) { - std::cout << fileMain << " is invalid." << std::endl; + std::cout << filename << " is invalid." << std::endl; return 2; } - std::cout << "Successfully loaded producer " << fileMain << std::endl; - std::cout << "Some data: " << std::endl - << "Length: " << producer.get_length() << std::endl - << "fps: " << producer.get_fps() << std::endl; + std::cout << "Successfully loaded producer " << filename << std::endl; + + int streams = atoi(producer.get("meta.media.nb_streams")); + std::cout << "Number of streams: " << streams << std::endl; + + int audioStream = -1; + for (int i = 0; i < streams; i++) { + std::string propertyName = QString("meta.media.%1.stream.type").arg(i).toStdString(); + std::cout << "Producer " << i << ": " << producer.get(propertyName.c_str()); + if (strcmp("audio", producer.get(propertyName.c_str())) == 0) { + std::cout << " (Using this stream)"; + audioStream = i; + } + std::cout << std::endl; + } - int nSamples = 50; - Mlt::Frame *frame = producer.get_frame(); - float *data = frame->get_audio(mlt_audio_float, 24000, 1, nSamples); + if (audioStream >= 0) { + QMap map; + map.insert("Sampling format", QString("meta.media.%1.codec.sample_fmt").arg(audioStream)); + map.insert("Sampling rate", QString("meta.media.%1.codec.sample_rate").arg(audioStream)); + map.insert("Bit rate", QString("meta.media.%1.codec.bit_rate").arg(audioStream)); + map.insert("Channels", QString("meta.media.%1.codec.channels").arg(audioStream)); + map.insert("Codec", QString("meta.media.%1.codec.name").arg(audioStream)); + map.insert("Codec, long name", QString("meta.media.%1.codec.long_name").arg(audioStream)); + + std::cout << "Audio properties (stream " << audioStream << ")" << std::endl; + foreach (QString key, map.keys()) { + std::string value = map.value(key).toStdString(); + std::cout << "\t" << key.toStdString() << ": " << producer.get(value.c_str()) + << " (" << value << ")" << std::endl; + } + } + + return 0; +} - for (int i = 0; i < nSamples; i++) { - std::cout << " " << data[i]; +int main(int argc, char *argv[]) +{ + char *fileMain; + char *fileSub; + if (argc > 2) { + fileMain = argv[1]; + fileSub = argv[2]; + } else { + std::cout << "Usage: " << argv[0] << "
" << std::endl; + return 0; } - std::cout << std::endl; + std::cout << "Trying to align (1)\n\t" << fileSub << "\nto fit on (2)\n\t" << fileMain + << "\n, result will indicate by how much (1) has to be moved." << std::endl; + + + info(fileMain); + info(fileSub); /* + Mlt::Frame *frame = producer.get_frame(); + + + float *data = (float*)frame->get_audio(format, samplingRate, channels, nSamples); producer.set("video_index", "-1"); if (KdenliveSettings::normaliseaudiothumbs()) {