Improved Profile Class (Helper methods, Sortable, Unit tests) (#895)

* Removing legacy profile property. Add new operators for Profile classes (for comparison). Also added new functions to generate different variations of the Profile data (key, short name, long name, long name w/description).

* Add empty constructor for Profile class, and new Profile unit tets

* Adding zero padding to profile Key function, for easier sorting: 01920x1080i2997_16:09

* Clear setfill flag after creating Key() output

* Updating example exe to load an *.osp project file via C++, which makes debugging complex broken projects much easier.

* - Add new unit test to FFmpegWriter to create an animated GIF and verify it can be wrapped with a FrameMapper (with no audio track)
- Improve FrameMapper to ignore missing audio data (i.e. when no audio samples present, don't try and find them or resample them)

* Fix some whitespace issues

* Fix inline documentation mistype

* Fixed missing reuse licensing on new example profile files

* Changing Profile::Key() format to exclude the : character, since Windows file names cannot contain that

* - Large memory leak fixed in FFmpegWriter when closing the video & audio contexts
- Reducing # of cached frames and rescalers to 1, since we no longer use OMP and this is unneeded - we need to refactor much of this code out eventually

* - Fixing whitespace issues
- Code clean-up / line wrapping / etc...
This commit is contained in:
Jonathan Thomas
2023-02-02 16:29:38 -06:00
committed by GitHub
parent 510a7690f6
commit 70e86ef044
11 changed files with 1064 additions and 647 deletions

View File

@@ -13,25 +13,56 @@
#include <fstream>
#include <iostream>
#include <memory>
#include <QFileDialog>
#include "Clip.h"
#include "Frame.h"
#include "FFmpegReader.h"
#include "Timeline.h"
#include "Profiles.h"
using namespace openshot;
int main(int argc, char* argv[]) {
// FFmpeg Reader performance test
FFmpegReader r9("/home/jonathan/Downloads/pts-test-files/broken-files/lady-talking-1.mp4");
r9.Open();
for (long int frame = 1; frame <= r9.info.video_length; frame++)
{
std::cout << "Requesting Frame: #: " << frame << std::endl;
std::shared_ptr<Frame> f = r9.GetFrame(frame);
QString filename = "/home/jonathan/test-crash.osp";
//QString filename = "/home/jonathan/Downloads/drive-download-20221123T185423Z-001/project-3363/project-3363.osp";
//QString filename = "/home/jonathan/Downloads/drive-download-20221123T185423Z-001/project-3372/project-3372.osp";
//QString filename = "/home/jonathan/Downloads/drive-download-20221123T185423Z-001/project-3512/project-3512.osp";
QString project_json = "";
QFile file(filename);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
std::cout << "File error!" << std::endl;
exit(1);
} else {
while (!file.atEnd()) {
QByteArray line = file.readLine();
project_json += line;
}
}
r9.Close();
// Open timeline reader
std::cout << "Project JSON length: " << project_json.length() << std::endl;
Timeline r(1280, 720, openshot::Fraction(30, 1), 44100, 2, openshot::LAYOUT_STEREO);
r.SetJson(project_json.toStdString());
r.DisplayInfo();
r.Open();
// Get max frame
int64_t max_frame = r.GetMaxFrame();
std::cout << "max_frame: " << max_frame << ", r.info.video_length: " << r.info.video_length << std::endl;
for (long int frame = 1; frame <= max_frame; frame++)
{
float percent = (float(frame) / max_frame) * 100.0;
std::cout << "Requesting Frame #: " << frame << " (" << percent << "%)" << std::endl;
std::shared_ptr<Frame> f = r.GetFrame(frame);
// Preview frame image
if (frame % 1 == 0) {
f->Save("preview.jpg", 1.0, "jpg", 100);
}
}
r.Close();
exit(0);
}