|
turtletooth |
04d8fd |
#pragma once
|
|
turtletooth |
04d8fd |
|
|
turtletooth |
04d8fd |
#ifndef TTIO_FFMPEG_INCLUDED
|
|
turtletooth |
04d8fd |
#define TTIO_FFMPEG_INCLUDED
|
|
turtletooth |
04d8fd |
|
|
turtletooth |
04d8fd |
#include "tproperty.h"
|
|
turtletooth |
04d8fd |
#include "tlevel_io.h"
|
|
turtletooth |
04d8fd |
#include "trasterimage.h"
|
|
turtletooth |
04d8fd |
#include <qvector></qvector>
|
|
turtletooth |
04d8fd |
#include <qstringlist></qstringlist>
|
|
justburner |
69bbaf |
#include <qprocess></qprocess>
|
|
turtletooth |
04d8fd |
|
|
turtletooth |
04d8fd |
struct ffmpegFileInfo {
|
|
turtletooth |
04d8fd |
int m_lx, m_ly, m_frameCount;
|
|
turtletooth |
04d8fd |
double m_frameRate;
|
|
turtletooth |
04d8fd |
};
|
|
turtletooth |
04d8fd |
|
|
turtletooth |
04d8fd |
class Ffmpeg {
|
|
turtletooth |
04d8fd |
public:
|
|
turtletooth |
04d8fd |
Ffmpeg();
|
|
turtletooth |
04d8fd |
~Ffmpeg();
|
|
turtletooth |
04d8fd |
void createIntermediateImage(const TImageP &image, int frameIndex);
|
|
turtletooth |
04d8fd |
void runFfmpeg(QStringList preIArgs, QStringList postIArgs,
|
|
justburner |
64e039 |
bool includesInPath, bool includesOutPath, bool overWriteFiles,
|
|
justburner |
64e039 |
bool asyncProcess = true);
|
|
turtletooth |
04d8fd |
void runFfmpeg(QStringList preIArgs, QStringList postIArgs, TFilePath path);
|
|
turtletooth |
04d8fd |
QString runFfprobe(QStringList args);
|
|
turtletooth |
04d8fd |
void cleanUpFiles();
|
|
turtletooth |
04d8fd |
void addToCleanUp(QString);
|
|
turtletooth |
04d8fd |
void setFrameRate(double fps);
|
|
turtletooth |
04d8fd |
void setPath(TFilePath path);
|
|
turtletooth |
04d8fd |
void saveSoundTrack(TSoundTrack *st);
|
|
turtletooth |
04d8fd |
bool checkFilesExist();
|
|
turtletooth |
04d8fd |
static bool checkFormat(std::string format);
|
|
turtletooth |
04d8fd |
double getFrameRate();
|
|
turtletooth |
04d8fd |
TDimension getSize();
|
|
turtletooth |
04d8fd |
int getFrameCount();
|
|
turtletooth |
04d8fd |
void getFramesFromMovie(int frame = -1);
|
|
turtletooth |
04d8fd |
TRasterImageP getImage(int frameIndex);
|
|
turtletooth |
04d8fd |
TFilePath getFfmpegCache();
|
|
turtletooth |
04d8fd |
ffmpegFileInfo getInfo();
|
|
turtletooth |
04d8fd |
void disablePrecompute();
|
|
Jeremy Bullock |
779cdf |
int getGifFrameCount();
|
|
turtletooth |
04d8fd |
|
|
turtletooth |
04d8fd |
private:
|
|
justburner |
64e039 |
QString m_intermediateFormat, m_audioPath, m_audioFormat;
|
|
turtletooth |
04d8fd |
int m_frameCount = 0, m_lx, m_ly, m_bpp, m_bitsPerSample, m_channelCount,
|
|
justburner |
188d84 |
m_ffmpegTimeout = 30000, m_startNumber = 2147483647;
|
|
justburner |
64e039 |
double m_frameRate = 24.0;
|
|
justburner |
64e039 |
bool m_hasSoundTrack = false;
|
|
turtletooth |
04d8fd |
TFilePath m_path;
|
|
turtletooth |
04d8fd |
QVector<qstring> m_cleanUpList;</qstring>
|
|
turtletooth |
04d8fd |
QStringList m_audioArgs;
|
|
turtletooth |
04d8fd |
TUINT32 m_sampleRate;
|
|
Jeremy Bullock |
686e82 |
QString cleanPathSymbols();
|
|
justburner |
64e039 |
bool waitFfmpeg(QProcess &ffmpeg, bool asyncProcess);
|
|
turtletooth |
04d8fd |
};
|
|
turtletooth |
04d8fd |
|
|
justburner |
64e039 |
//===========================================================
|
|
justburner |
64e039 |
//
|
|
justburner |
64e039 |
// TLevelReaderFFmpeg
|
|
justburner |
64e039 |
//
|
|
justburner |
64e039 |
//===========================================================
|
|
justburner |
64e039 |
|
|
justburner |
64e039 |
class TLevelReaderFFmpeg final : public TLevelReader {
|
|
justburner |
64e039 |
public:
|
|
justburner |
64e039 |
TLevelReaderFFmpeg(const TFilePath &path);
|
|
justburner |
64e039 |
~TLevelReaderFFmpeg();
|
|
justburner |
64e039 |
TImageReaderP getFrameReader(TFrameId fid) override;
|
|
justburner |
64e039 |
|
|
justburner |
64e039 |
static TLevelReader *create(const TFilePath &f) {
|
|
justburner |
64e039 |
return new TLevelReaderFFmpeg(f);
|
|
justburner |
64e039 |
}
|
|
justburner |
64e039 |
|
|
justburner |
64e039 |
TLevelP loadInfo() override;
|
|
justburner |
64e039 |
TImageP load(int frameIndex);
|
|
justburner |
64e039 |
TDimension getSize();
|
|
justburner |
64e039 |
|
|
justburner |
64e039 |
private:
|
|
justburner |
64e039 |
Ffmpeg *ffmpegReader;
|
|
justburner |
64e039 |
bool ffmpegFramesCreated = false;
|
|
justburner |
64e039 |
TDimension m_size;
|
|
justburner |
64e039 |
int m_frameCount, m_lx, m_ly;
|
|
justburner |
64e039 |
};
|
|
justburner |
64e039 |
|
|
justburner |
64e039 |
//===========================================================================
|
|
justburner |
64e039 |
|
|
turtletooth |
04d8fd |
#endif
|