All Classes Namespaces Functions Variables Enumerations Properties Pages
movieimporter.h
1 /*
2 
3 Pencil2D - Traditional Animation Software
4 Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5 Copyright (C) 2012-2020 Matthew Chiawen Chang
6 
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; version 2 of the License.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 */
17 #ifndef MOVIEIMPORTER_H
18 #define MOVIEIMPORTER_H
19 
20 #include "pencilerror.h"
21 
22 #include <QObject>
23 #include <functional>
24 #include "filetype.h"
25 
26 class Editor;
27 class QTemporaryDir;
28 
29 class MovieImporter : public QObject
30 {
31  Q_OBJECT
32 public:
34  virtual ~MovieImporter();
35 
36  void setCore(Editor* editor) { mEditor = editor; }
37 
48  Status estimateFrames(const QString& filePath, int fps, int* frameEstimate);
49 
59  Status run(const QString& filePath, int fps, FileType type,
60  std::function<void(int)> progress,
61  std::function<void(QString)> progressMessage,
62  std::function<bool()> askPermission);
63 
64  void cancel() { mCanceled = true; }
65 
66 private:
67 
68  Status verifyFFmpegExists();
69  Status importMovieVideo(const QString& filePath, int fps, int frameEstimate,
70  std::function<bool(int)> progress,
71  std::function<void(QString)> progressMessage);
72  Status importMovieAudio(const QString& filePath, std::function<bool(int)> progress);
73 
74  Status generateFrames(std::function<bool(int)> progress);
75 
76  Editor* mEditor = nullptr;
77 
78  QTemporaryDir* mTempDir = nullptr;
79 
80  bool mCanceled = false;
81 };
82 
83 #endif // MOVIEIMPORTER_H
Status run(const QString &filePath, int fps, FileType type, std::function< void(int)> progress, std::function< void(QString)> progressMessage, std::function< bool()> askPermission)
Q_OBJECTQ_OBJECT
Status estimateFrames(const QString &filePath, int fps, int *frameEstimate)
Attempts to load a video and determine it's duration.
Definition: editor.h:55
QObject * parent() const const