Pencil2D Animation
Download Community News Docs Contribute
  • Overview
  • Articles
  • Code
  •  
  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • File List
Loading...
Searching...
No Matches
  • core_lib
  • src
movieexporter.h
1/*
2
3Pencil2D - Traditional Animation Software
4Copyright (C) 2012-2020 Matthew Chiawen Chang
5
6This program is free software; you can redistribute it and/or
7modify it under the terms of the GNU General Public License
8as published by the Free Software Foundation; version 2 of the License.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15*/
16
17#ifndef MOVIEEXPORTER_H
18#define MOVIEEXPORTER_H
19
20#include <functional>
21#include <QCoreApplication>
22#include <QString>
23#include <QSize>
24#include <QTemporaryDir>
25#include "pencilerror.h"
26
27class Object;
28class QProcess;
29
30struct ExportMovieDesc
31{
32 QString strFileName;
33 int startFrame = 0;
34 int endFrame = 0;
35 //int videoFps = 30;
36 int fps = 12;
37 QSize exportSize{ 0, 0 };
38 QString strCameraName;
39 bool loop = false;
40 bool alpha = false;
41};
42
43class MovieExporter
44{
45 Q_DECLARE_TR_FUNCTIONS(MovieExporter)
46public:
47 MovieExporter();
48 ~MovieExporter();
49
50 Status run(const Object* obj,
51 const ExportMovieDesc& desc,
52 std::function<void(float, float)> majorProgress,
53 std::function<void(float)> minorProgress,
54 std::function<void(QString)> progressMessage);
55 QString error();
56
57 void cancel() { mCanceled = true; }
58
59 // The maximum number of sound frames that can be successfully rendered
60 static const int MAX_SOUND_FRAMES = 63;
61
62 static Status executeFFmpeg(const QString& cmd, const QStringList& args, std::function<bool(int)> progress);
63private:
64 Status assembleAudio(const Object* obj, QString ffmpegPath, std::function<void(float)> progress);
65 Status generateMovie(const Object *obj, QString ffmpegPath, QString strOutputFile, std::function<void(float)> progress);
66 Status generateGif(const Object *obj, QString ffmpeg, QString strOut, std::function<void(float)> progress);
67
68 Status executeFFMpegPipe(const QString& cmd, const QStringList& args, std::function<void(float)> progress, std::function<bool(QProcess&,int)> writeFrame);
69 Status checkInputParameters(const ExportMovieDesc&);
70
71private:
72 QTemporaryDir mTempDir;
73 QString mTempWorkDir;
74 ExportMovieDesc mDesc;
75 bool mCanceled = false;
76};
77
78#endif // MOVIEEXPORTER_H
MovieExporter
Definition: movieexporter.h:44
MovieExporter::run
Status run(const Object *obj, const ExportMovieDesc &desc, std::function< void(float, float)> majorProgress, std::function< void(float)> minorProgress, std::function< void(QString)> progressMessage)
Begin exporting the movie described by exportDesc.
Definition: movieexporter.cpp:78
MovieExporter::assembleAudio
Status assembleAudio(const Object *obj, QString ffmpegPath, std::function< void(float)> progress)
Combines all audio tracks in obj into a single file.
Definition: movieexporter.cpp:162
MovieExporter::generateMovie
Status generateMovie(const Object *obj, QString ffmpegPath, QString strOutputFile, std::function< void(float)> progress)
Exports obj to a movie image at strOut using FFmpeg.
Definition: movieexporter.cpp:270
MovieExporter::generateGif
Status generateGif(const Object *obj, QString ffmpeg, QString strOut, std::function< void(float)> progress)
Exports obj to a gif image at strOut using FFmpeg.
Definition: movieexporter.cpp:419
MovieExporter::executeFFMpegPipe
Status executeFFMpegPipe(const QString &cmd, const QStringList &args, std::function< void(float)> progress, std::function< bool(QProcess &, int)> writeFrame)
Runs the specified command (should be ffmpeg), and lets writeFrame pipe data into it 1 frame at a tim...
Definition: movieexporter.cpp:657
MovieExporter::executeFFmpeg
static Status executeFFmpeg(const QString &cmd, const QStringList &args, std::function< bool(int)> progress)
Runs the specified command (should be ffmpeg) and allows for progress feedback.
Definition: movieexporter.cpp:541
Object
Definition: object.h:42
Status
Definition: pencilerror.h:40
QProcess
QSize
QString
QStringList
QTemporaryDir
ExportMovieDesc
Definition: movieexporter.h:31
Generated on Thu May 8 2025 04:47:53 for Pencil2D by doxygen 1.9.6 based on revision 4513250b1d5b1a3676ec0e67b06b7a885ceaae39