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>
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,
turtletooth 04d8fd
                 bool includesInPath, bool includesOutPath,
turtletooth 04d8fd
                 bool overWriteFiles);
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 checkFfmpeg();
turtletooth 04d8fd
  static bool checkFfprobe();
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();
turtletooth 04d8fd
turtletooth 04d8fd
private:
turtletooth 04d8fd
  QString m_intermediateFormat, m_ffmpegPath, m_audioPath, m_audioFormat;
turtletooth 04d8fd
  int m_frameCount    = 0, m_lx, m_ly, m_bpp, m_bitsPerSample, m_channelCount,
shun-iwasawa 27b0cf
      m_ffmpegTimeout = 30000;
turtletooth 04d8fd
  double m_frameRate  = 24.0;
turtletooth 04d8fd
  bool m_ffmpegExists = false, m_ffprobeExists = false, 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;
turtletooth 04d8fd
};
turtletooth 04d8fd
turtletooth 04d8fd
#endif