diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/raytracer/raytracer.cpp | 15 | ||||
-rw-r--r-- | src/raytracer/raytracer.h | 3 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/raytracer/raytracer.cpp b/src/raytracer/raytracer.cpp index 38ed2e1..94e928d 100644 --- a/src/raytracer/raytracer.cpp +++ b/src/raytracer/raytracer.cpp @@ -1,6 +1,7 @@ #include <QList> #include <QtConcurrent> #include <iostream> +#include <cstdlib> #include "raytracer.h" #include "raytracescene.h" #include "settings.h" @@ -40,6 +41,11 @@ void RayTracer::render(RGBA *imageData, const RayTraceScene &scene) { // render the next frame settings.currentTime++; emit settingsChanged(m_imageLabel); // emit to allow the UI to update then render the next frame + } else { // done rendering + // assemble the video + saveFFMPEGVideo(settings.bulkOutputFolderPath); + settings.currentTime = 0; + settings.bulkOutputFolderPath = ""; } } } @@ -268,3 +274,12 @@ void RayTracer::saveViewportImage(std::string filePath) { QImage image = QImage((uchar *) m_imageData, 576, 432, QImage::Format_RGBX8888); image.save(QString::fromStdString(filePath)); } + +void RayTracer::saveFFMPEGVideo(std::string filePath) { + std::string directory = filePath + QDir::separator().toLatin1(); + std::string command = "ffmpeg -framerate 30 -pattern_type glob -i '" + directory + "*.png' -c:v libx264 -pix_fmt yuv420p '" + directory + "video.mp4'"; + int result = std::system(command.c_str()); + if (result != 0) { + std::cerr << "Failed to assemble video." << std::endl; + } +} diff --git a/src/raytracer/raytracer.h b/src/raytracer/raytracer.h index 52fc05a..fdceaab 100644 --- a/src/raytracer/raytracer.h +++ b/src/raytracer/raytracer.h @@ -37,7 +37,7 @@ struct Config { class RayTracer : public QWidget { - Q_OBJECT + Q_OBJECT public: // constructor for the config RayTracer(QWidget *parent = nullptr); @@ -178,6 +178,7 @@ public: QImage m_image; void saveViewportImage(std::string filename); + void saveFFMPEGVideo(std::string filename); void wSliderChanged(QLabel* imageLabel); signals: void xyRotationChanged(float value); |