encode the main encoding function. This in turn calls runFFMpeg, which is a private function inside this class.
50{
54 }
55
57
59
63
64
65 const QString exportDimensions =
66 QString("scale=w=")
67 .append(QString::number(options.
width))
68 .append(":h=")
69 .append(QString::number(options.
height))
70 .append(":flags=")
72
73
75 const QFileInfo resultFileInfo(resultFile);
76 const QDir videoDir(resultFileInfo.absolutePath());
77
78 const QString suffix = resultFileInfo.suffix().toLower();
79 const QString palettePath = videoDir.filePath("KritaTempPalettegen_\%06d.png");
80
82
84
85 {
90
91 args << "-y"
92 <<
"-r" << QString::number(options.
frameRate)
93 << "-start_number" << QString::number(sequenceStart) << "-start_number_range" << "1"
94 << "-i" << savedFilesMask;
95
96 const int lavfiOptionsIndex = additionalOptionsList.indexOf("-lavfi");
97
98 if ( lavfiOptionsIndex != -1 ) {
99 complexFilterArgs << additionalOptionsList.takeAt(lavfiOptionsIndex + 1);
100
101 additionalOptionsList.removeAt( lavfiOptionsIndex );
102 }
103
105 paletteArgs <<
"-r" << QString::number(options.
frameRate)
106 << "-start_number" << QString::number(sequenceStart) << "-start_number_range" << "1"
107 << "-i" << savedFilesMask;
108
109 const int paletteOptionsIndex = additionalOptionsList.indexOf("-palettegen");
110 QString palettegenString = "palettegen";
111
112 if ( paletteOptionsIndex != -1 ) {
113 palettegenString = additionalOptionsList.takeAt(paletteOptionsIndex + 1);
114
115 additionalOptionsList.removeAt( paletteOptionsIndex );
116 }
117
119 paletteArgs << "-vf" << (exportDimensions + "," + palettegenString );
120 } else {
121 paletteArgs << "-vf" << palettegenString;
122 }
123
124 paletteArgs << "-y" << palettePath;
125
127 ffmpegArgs << "-v" << "debug"
128 << paletteArgs;
129
131 ffmpegSettings.
args = ffmpegArgs;
133
135 ffmpegSettings.
progressMessage = i18nc(
"Animation export dialog for palette exporting. arg1: file-suffix",
136 "Creating palette for %1 file format.", "[suffix]");
137 ffmpegSettings.
logPath = QDir::tempPath() + QDir::separator() +
"krita" + QDir::separator() +
"ffmpeg.log";
138
140
141 if (!result.
isOk()) {
142 return result;
143 }
144
145 if (lavfiOptionsIndex == -1) {
146 complexFilterArgs << "[0:v][1:v] paletteuse";
147 }
148
149 args << "-i" << palettePath;
150
151
152 ffmpegWrapper->reset();
153 }
154
156 if (options.
includeAudio && audioFiles.count() > 0 && audioFiles.first().exists()) {
157 QFileInfo audioFileInfo = audioFiles.first();
158 const int msecPerFrame = (1000 / animation->
framerate());
159 const int msecStart = msecPerFrame * clipRange.
start();
160 const int msecDuration = msecPerFrame * clipRange.
duration();
161
162 const QTime startTime = QTime::fromMSecsSinceStartOfDay(msecStart);
163 const QTime durationTime = QTime::fromMSecsSinceStartOfDay(msecDuration);
164 const QString ffmpegTimeFormat = QStringLiteral("H:m:s.zzz");
165
166 args << "-ss" << QLocale::c().toString(startTime, ffmpegTimeFormat);
167 args << "-t" << QLocale::c().toString(durationTime, ffmpegTimeFormat);
168 args << "-i" << audioFileInfo.absoluteFilePath();
169 }
170
171
172
174 simpleFilterArgs << exportDimensions;
175 }
176
177 if ( !complexFilterArgs.isEmpty() ) {
178 args << "-lavfi" << (!simpleFilterArgs.isEmpty() ? simpleFilterArgs.join(",").append("[0:v];"):"") + complexFilterArgs.join(";");
179 } else if ( !simpleFilterArgs.isEmpty() ) {
180 args << "-vf" << simpleFilterArgs.join(",");
181 }
182
183 args << additionalOptionsList;
184
185 dbgFile <<
"savedFilesMask" << savedFilesMask
186 << "save files offset" << sequenceStart
187 <<
"start" << QString::number(clipRange.
start())
188 <<
"duration" << clipRange.
duration();
189
190
193 ffmpegSettings.
args = args;
196 ffmpegSettings.
logPath = QDir::tempPath() + QDir::separator() +
"krita" + QDir::separator() +
"ffmpeg.log";
197 ffmpegSettings.
progressMessage = i18nc(
"Animation export dialog for tracking ffmpeg progress. arg1: file-suffix, arg2: progress frame number, arg3: totalFrameCount.",
198 "Creating desired %1 file: %2/%3 frames.", "[suffix]", "[progress]", "[framecount]");
199
200 resultOuter = ffmpegWrapper->start(ffmpegSettings);
201 }
202
203
204 return resultOuter;
205}
QString resolveAbsoluteVideoFilePath(const QString &documentPath) const
QString customFFMpegOptions
void setErrorMessage(const QString &errMsg)
QVector< QFileInfo > getAudioTracks() const
KisImageAnimationInterface * animationInterface() const
static KisTimeSpan fromTimeToTime(int start, int end)
bool progressIndeterminate