Commit 287a3f77 authored by Halla Rempt's avatar Halla Rempt
Browse files

Let the video saver work when called with a configuration

The video saver no longer is a real import/export filter, but
a video filter, and won't show the dialog on its own anymore.
parent 36550e85
......@@ -57,7 +57,6 @@ KisVideoExport::~KisVideoExport()
KisImportExportFilter::ConversionStatus KisVideoExport::convert(const QByteArray &from, const QByteArray &to, KisPropertiesConfigurationSP configuration)
{
Q_UNUSED(to);
Q_UNUSED(configuration);
if (from != "application/x-krita")
return KisImportExportFilter::NotImplemented;
......@@ -65,8 +64,6 @@ KisImportExportFilter::ConversionStatus KisVideoExport::convert(const QByteArray
KisDocument *input = inputDocument();
QString filename = outputFile();
qDebug() << "inputDocument" << input << "output filename" << filename;
if (!input)
return KisImportExportFilter::NoDocumentCreated;
......@@ -97,6 +94,9 @@ KisImportExportFilter::ConversionStatus KisVideoExport::convert(const QByteArray
else if (res == KisImageBuilder_RESULT_CANCEL) {
return KisImportExportFilter::ProgressCancelled;
}
else {
input->setErrorMessage(i18n("FFMpeg failed to convert the image sequence. Check the logfile in your output directory for more information."));
}
return KisImportExportFilter::InternalError;
}
......
......@@ -189,11 +189,17 @@ QStringList VideoExportOptionsDialog::customUserOptions() const
void VideoExportOptionsDialog::setConfiguration(const KisPropertiesConfigurationSP cfg)
{
m_d->defaultPreset = cfg->getInt("h264PresetIndex", 5);
ui->cmbPreset->setCurrentIndex(m_d->defaultPreset);
m_d->defaultConstantRateFactor = cfg->getInt("h264ConstantRateFactor", 23);
ui->intConstantRateFactor->setValue(m_d->defaultConstantRateFactor);
m_d->defaultProfile = cfg->getInt("h264ProfileIndex", 4);
ui->cmbProfile->setCurrentIndex(m_d->defaultProfile);
m_d->defaultTune = cfg->getInt("h264TuneIndex", 1);
ui->cmbTune->setCurrentIndex(m_d->defaultTune);
m_d->defaultBitrate = cfg->getInt("TheoraBitrate", 5000);
ui->intBitrate->setValue(m_d->defaultBitrate);
m_d->defaultCustomLine = cfg->getString("CustomLineValue", "");
ui->txtCustomLine->setText(m_d->defaultCustomLine);
if (cfg->hasProperty("CodecIndex")) {
setCodec((VideoExportOptionsDialog::CodecIndex)cfg->getInt("CodecIndex"));
}
......@@ -210,7 +216,7 @@ QStringList VideoExportOptionsDialog::generateCustomLine() const
options << "-crf" << QString::number(ui->intConstantRateFactor->value());
const int presetIndex = ui->cmbPreset->currentIndex();
qDebug() << "presetIndex" << presetIndex << m_d->presets;
//qDebug() << "presetIndex" << presetIndex << m_d->presets;
options << "-preset" << m_d->presets[presetIndex].id();
const int profileIndex = ui->cmbProfile->currentIndex();
......
......@@ -61,8 +61,6 @@ public:
private Q_SLOTS:
void slotFileChanged() {
//qDebug() << "=== progress changed ===";
int currentFrame = -1;
bool isEnded = false;
......@@ -75,7 +73,6 @@ private Q_SLOTS:
} else if (var[0] == "progress") {
isEnded = var[1] == "end";
}
//qDebug() << var;
}
if (isEnded) {
......@@ -107,7 +104,12 @@ public:
KisImageBuilder_Result runFFMpeg(const QStringList &specialArgs,
const QString &actionName,
const QString &logPath,
int totalFrames) {
int totalFrames)
{
// qDebug() << "runFFMpeg: specialArgs" << specialArgs
// << "actionName" << actionName
// << "logPath" << logPath
// << "totalFrames" << totalFrames;
QTemporaryFile progressFile("KritaFFmpegProgress.XXXXXX");
progressFile.open();
......@@ -134,7 +136,8 @@ private:
KisImageBuilder_Result waitForFFMpegProcess(const QString &message,
QFile &progressFile,
QProcess &ffmpegProcess,
int totalFrames) {
int totalFrames)
{
KisFFMpegProgressWatcher watcher(progressFile, totalFrames);
......@@ -183,7 +186,6 @@ VideoSaver::VideoSaver(KisDocument *doc, bool batchMode)
, m_ffmpegPath(findFFMpeg())
, m_runner(new KisFFMpegRunner(m_ffmpegPath))
{
}
VideoSaver::~VideoSaver()
......@@ -237,29 +239,28 @@ QString VideoSaver::findFFMpeg()
KisImageBuilder_Result VideoSaver::encode(const QString &filename, KisPropertiesConfigurationSP configuration)
{
qDebug() << "ffmpeg" << m_ffmpegPath << "filename" << filename << "configuration";
configuration->dump();
//qDebug() << "ffmpeg" << m_ffmpegPath << "filename" << filename << "configuration" << configuration->toXML();
if (m_ffmpegPath.isEmpty()) return KisImageBuilder_RESULT_FAILURE;
KisImageBuilder_Result retval = KisImageBuilder_RESULT_OK;
KisImageBuilder_Result result = KisImageBuilder_RESULT_OK;
KisImageAnimationInterface *animation = m_image->animationInterface();
const KisTimeRange fullRange = animation->fullClipRange();
const KisTimeRange clipRange(configuration->getInt("firstframe", fullRange.start()), configuration->getInt("lastFrame"), fullRange.end());
const int frameRate = animation->framerate();
const QString resultFile = filename;
const QDir framesDir(configuration->getString("directory"));
const QString resultFile = framesDir.absolutePath() + "/" + filename;
const QFileInfo info(resultFile);
const QString suffix = info.suffix().toLower();
const QDir framesDir(configuration->getString("directory"));
const QString palettePath = framesDir.filePath("palette.png");
const QString savedFilesMask = configuration->getString("savedFilesMask");
const QStringList additionalOptionsList = configuration->getString("customUserOptions").split(' ');
const QStringList additionalOptionsList = configuration->getString("customUserOptions").split(' ', QString::SkipEmptyParts);
if (suffix == "gif") {
{
......@@ -304,17 +305,12 @@ KisImageBuilder_Result VideoSaver::encode(const QString &filename, KisProperties
<< additionalOptionsList
<< "-y" << resultFile;
KisImageBuilder_Result result =
m_runner->runFFMpeg(args, i18n("Encoding frames..."),
framesDir.filePath("log_encode.log"),
clipRange.duration());
if (result) {
return result;
}
result = m_runner->runFFMpeg(args, i18n("Encoding frames..."),
framesDir.filePath("log_encode.log"),
clipRange.duration());
}
return retval;
return result;
}
void VideoSaver::cancel()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment