Navigation Menu

Skip to content

Commit

Permalink
Make code compatible with Qt 5.6 again
Browse files Browse the repository at this point in the history
  • Loading branch information
scribblemaniac committed May 8, 2020
1 parent 0247ea2 commit 789d7f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
8 changes: 5 additions & 3 deletions core_lib/src/movieexporter.cpp
Expand Up @@ -166,7 +166,7 @@ Status MovieExporter::assembleAudio(const Object* obj,
QDir dir(mTempWorkDir);
Q_ASSERT(dir.exists());

QString tempAudioPath = mTempWorkDir + "/tmpaudio0.wav";
QString tempAudioPath = QDir(mTempWorkDir).filePath("tmpaudio.wav");
qDebug() << "TempAudio=" << tempAudioPath;

std::vector< SoundClip* > allSoundClips;
Expand All @@ -180,6 +180,8 @@ Status MovieExporter::assembleAudio(const Object* obj,
});
}

if (allSoundClips.empty()) return Status::SAFE;

int clipCount = 0;

QString strCmd, filterComplex, amergeInput, panChannelLayout;
Expand Down Expand Up @@ -218,7 +220,7 @@ Status MovieExporter::assembleAudio(const Object* obj,
strCmd += QString(" -ss %1").arg((startFrame - 1) / static_cast<double>(fps));
strCmd += QString(" -to %1").arg(endFrame / static_cast<double>(fps));
// Output path
strCmd += " " + mTempWorkDir + "/tmpaudio.wav";
strCmd += " " + tempAudioPath;

STATUS_CHECK(MovieExporter::executeFFmpeg(strCmd, [&progress, this] (int frame) { progress(frame / static_cast<float>(mDesc.endFrame - mDesc.startFrame)); return !mCanceled; }))
qDebug() << "audio file: " + tempAudioPath;
Expand Down Expand Up @@ -299,7 +301,7 @@ Status MovieExporter::generateMovie(
// Build FFmpeg command

//int exportFps = mDesc.videoFps;
const QString tempAudioPath = mTempWorkDir + "/tmpaudio.wav";
const QString tempAudioPath = QDir(mTempWorkDir).filePath("tmpaudio.wav");

QString strCmd = QString("\"%1\"").arg(ffmpegPath);
strCmd += QString(" -f rawvideo -pixel_format bgra");
Expand Down
13 changes: 7 additions & 6 deletions core_lib/src/movieimporter.cpp
Expand Up @@ -219,7 +219,7 @@ Status MovieImporter::importMovieVideo(const QString &filePath, int fps, int fra
QString strCmd = QString("\"%1\"").arg(ffmpegPath);
strCmd += QString(" -i \"%1\"").arg(filePath);
strCmd += QString(" -r %1").arg(fps);
strCmd += QString(" \"%1\"").arg(mTempDir->filePath("%05d.png"));
strCmd += QString(" \"%1\"").arg(QDir(mTempDir->path()).filePath("%05d.png"));

status = MovieExporter::executeFFmpeg(strCmd, [&progress, frameEstimate, this] (int frame) {
progress(qFloor(qMin(frame / static_cast<double>(frameEstimate), 1.0) * 50)); return !mCanceled; }
Expand All @@ -243,8 +243,9 @@ Status MovieImporter::generateFrames(std::function<void (int)> progress)
Layer* layer = mEditor->layers()->currentLayer();
Status status = Status::OK;
int i = 1;
auto amountOfFrames = QDir(mTempDir->path()).count();
QString currentFile(mTempDir->filePath(QString("%1.png").arg(i, 5, 10, QChar('0'))));
QDir tempDir(mTempDir->path());
auto amountOfFrames = tempDir.count();
QString currentFile(tempDir.filePath(QString("%1.png").arg(i, 5, 10, QChar('0'))));
QPoint imgTopLeft;

ViewManager* viewMan = mEditor->view();
Expand All @@ -269,10 +270,10 @@ Status MovieImporter::generateFrames(std::function<void (int)> progress)
if (mCanceled) return Status::CANCELED;
progress(qFloor(50 + i / static_cast<qreal>(amountOfFrames) * 50));
i++;
currentFile = mTempDir->filePath(QString("%1.png").arg(i, 5, 10, QChar('0')));
currentFile = tempDir.filePath(QString("%1.png").arg(i, 5, 10, QChar('0')));
}

if (!QFileInfo::exists(mTempDir->filePath("00001.png"))) {
if (!QFileInfo::exists(tempDir.filePath("00001.png"))) {
status = Status::FAIL;
status.setTitle(tr("Failed import"));
status.setDescription(tr("Was unable to find internal files, import unsucessful."));
Expand Down Expand Up @@ -309,7 +310,7 @@ Status MovieImporter::importMovieAudio(const QString& filePath, std::function<vo
}
}

QString audioPath = mTempDir->filePath("audio.wav");
QString audioPath = QDir(mTempDir->path()).filePath("audio.wav");

QString ffmpegPath = ffmpegLocation();
QString strCmd = QString("\"%1\"").arg(ffmpegPath);
Expand Down

0 comments on commit 789d7f2

Please sign in to comment.