1 /***************************************************************************
2 * Copyright (C) 2012 by Simon Andreas Eugster (simon.eu@gmail.com) *
3 * This file is part of kdenlive. See www.kdenlive.org. *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 ***************************************************************************/
18 #include <mlt++/Mlt.h>
23 #include "audioInfo.h"
24 #include "audioStreamInfo.h"
25 #include "audioEnvelope.h"
27 int main(int argc, char *argv[])
35 std::cout << "Usage: " << argv[0] << " <main audio file> <second audio file>" << std::endl;
38 std::cout << "Trying to align (1)\n\t" << fileSub << "\nto fit on (2)\n\t" << fileMain
39 << "\n, result will indicate by how much (1) has to be moved." << std::endl;
42 Mlt::Factory::init(NULL);
44 // Load an arbitrary profile
45 Mlt::Profile prof("hdv_1080_25p");
47 // Load the MLT producers
48 Mlt::Producer prodMain(prof, fileMain);
49 if (!prodMain.is_valid()) {
50 std::cout << fileMain << " is invalid." << std::endl;
53 Mlt::Producer profSub(prof, fileSub);
54 if (!profSub.is_valid()) {
55 std::cout << fileSub << " is invalid." << std::endl;
59 AudioInfo infoMain(&prodMain);
60 AudioInfo infoSub(&profSub);
67 int framesToFetch = prodMain.get_length();
68 std::cout << "Length: " << framesToFetch
69 << " (Seconds: " << framesToFetch/prodMain.get_fps() << ")"
71 if (framesToFetch > 5000) {
75 AudioEnvelope envelopeMain(&prodMain);
76 envelopeMain.loadEnvelope();
77 envelopeMain.loadStdDev();
78 envelopeMain.dumpInfo();
81 QString outImg = QString("envelope-%1.png")
82 .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd-hh:mm:ss"));
83 envelopeMain.drawEnvelope().save(outImg);
84 std::cout << "Saved volume envelope as "
85 << QFileInfo(outImg).absoluteFilePath().toStdString()