diff --git a/platform/qt/Info.plist b/platform/qt/Info.plist index 7a597c47..74c1ac42 100644 --- a/platform/qt/Info.plist +++ b/platform/qt/Info.plist @@ -15,7 +15,7 @@ CFBundleExecutable MLV App CFBundleIdentifier - 1234.MLV App + magiclantern.MLV App NOTE This file was generated by Qt/QMake. CFBundleTypeExtensions @@ -25,6 +25,6 @@ CFBundleTypeRole Viewer CFBundleShortVersionString - 0.1 alpha + 0.2 alpha diff --git a/platform/qt/MLVApp.pro b/platform/qt/MLVApp.pro index 7ed05a67..a5ae428c 100644 --- a/platform/qt/MLVApp.pro +++ b/platform/qt/MLVApp.pro @@ -39,7 +39,8 @@ SOURCES += \ ../../src/mlv/video_mlv.c \ ../../src/processing/processing.c \ ../../src/processing/raw_processing.c \ - InfoDialog.cpp + InfoDialog.cpp \ + StatusDialog.cpp HEADERS += \ @@ -58,12 +59,14 @@ HEADERS += \ ../../src/processing/raw_processing.h \ ../../src/mlv_include.h \ InfoDialog.h \ - MyApplication.h + MyApplication.h \ + StatusDialog.h FORMS += \ MainWindow.ui \ - InfoDialog.ui + InfoDialog.ui \ + StatusDialog.ui RESOURCES += \ ressources.qrc @@ -71,4 +74,5 @@ RESOURCES += \ QMAKE_INFO_PLIST = Info.plist DISTFILES += \ - Info.plist + Info.plist \ + FFmpeg/ffmpeg diff --git a/platform/qt/MainWindow.cpp b/platform/qt/MainWindow.cpp index 2c434973..b5447ca3 100644 --- a/platform/qt/MainWindow.cpp +++ b/platform/qt/MainWindow.cpp @@ -7,7 +7,7 @@ #include #include -#define VERSION "0.1 alpha" +#define VERSION "0.2 alpha" #define MAX_RAM 2048 @@ -18,8 +18,9 @@ MainWindow::MainWindow(QWidget *parent) : { ui->setupUi(this); - //Init the Info Dialog + //Init the Dialogs m_pInfoDialog = new InfoDialog( this ); + m_pStatusDialog = new StatusDialog( this ); //Dont show the Faithful combobox ui->comboBox->setVisible( false ); @@ -86,6 +87,7 @@ MainWindow::~MainWindow() { killTimer( m_timerId ); killTimer( m_timerCacheId ); + delete m_pStatusDialog; delete m_pInfoDialog; delete ui; } @@ -423,24 +425,33 @@ void MainWindow::on_actionGoto_First_Frame_triggered() } //Export clip +//Making a ProRes file: +/* +$ ffmpeg -r 25 -i frame%04d.png -c:v prores_ks -profile:v 4444 output.mov + ...or... -c:v prores_ks -profile:v hq output.mov + ...or... -c:v prores output.mov +*/ void MainWindow::on_actionExport_triggered() { //Stop playback if active ui->actionPlay->setChecked( false ); QString saveFileName = m_lastSaveFileName.left( m_lastSaveFileName.lastIndexOf( "." ) ); - saveFileName.append( ".bmp" ); + saveFileName.append( ".mov" ); //File Dialog QString fileName = QFileDialog::getSaveFileName( this, tr("Export..."), saveFileName, - tr("Images (*.bmp *.png *.jpg)") ); + tr("Movie (*.mov)") ); - //Exit if not an BMP file or aborted + //Exit if not an MOV file or aborted if( fileName == QString( "" ) - && ( !fileName.endsWith( ".bmp", Qt::CaseInsensitive ) - || !fileName.endsWith( ".png", Qt::CaseInsensitive ) - || !fileName.endsWith( ".jpg", Qt::CaseInsensitive ) ) ) return; + && ( !fileName.endsWith( ".mov", Qt::CaseInsensitive ) ) ) return; + + //Delete file if exists + QFile *file = new QFile( fileName ); + if( file->exists() ) file->remove(); + delete file; //Disable GUI drawing m_dontDraw = true; @@ -448,32 +459,29 @@ void MainWindow::on_actionExport_triggered() // we always get amaze frames for exporting setMlvAlwaysUseAmaze( m_pMlvObject ); + //StatusDialog + m_pStatusDialog->ui->progressBar->setMaximum( getMlvFrames( m_pMlvObject ) ); + m_pStatusDialog->ui->progressBar->setValue( 0 ); + m_pStatusDialog->show(); + + //Create temp pngs for( uint32_t i = 0; i < getMlvFrames( m_pMlvObject ); i++ ) { //Append frame number QString numberedFileName = fileName.left( fileName.lastIndexOf( "." ) ); numberedFileName.append( QString( "_%1" ).arg( (uint)i, 5, 10, QChar( '0' ) ) ); - numberedFileName.append( fileName.right( 4 ) ); + numberedFileName.append( QString( ".png" ) ); //Get frame from library getMlvProcessedFrame8( m_pMlvObject, i, m_pRawImage ); //Write file - if( fileName.endsWith( ".bmp", Qt::CaseInsensitive ) ) - { - QImage( ( unsigned char *) m_pRawImage, getMlvWidth(m_pMlvObject), getMlvHeight(m_pMlvObject), QImage::Format_RGB888 ) - .save( numberedFileName, "bmp", -1 ); - } - else if( fileName.endsWith( ".png", Qt::CaseInsensitive ) ) - { - QImage( ( unsigned char *) m_pRawImage, getMlvWidth(m_pMlvObject), getMlvHeight(m_pMlvObject), QImage::Format_RGB888 ) + QImage( ( unsigned char *) m_pRawImage, getMlvWidth(m_pMlvObject), getMlvHeight(m_pMlvObject), QImage::Format_RGB888 ) .save( numberedFileName, "png", -1 ); - } - else if( fileName.endsWith( ".jpg", Qt::CaseInsensitive ) ) - { - QImage( ( unsigned char *) m_pRawImage, getMlvWidth(m_pMlvObject), getMlvHeight(m_pMlvObject), QImage::Format_RGB888 ) - .save( numberedFileName, "jpg", 100 ); - } + + m_pStatusDialog->ui->progressBar->setValue( i ); + m_pStatusDialog->ui->progressBar->repaint(); + qApp->processEvents(); } //If we don't like amaze we switch it off again @@ -481,4 +489,46 @@ void MainWindow::on_actionExport_triggered() //Enable GUI drawing m_dontDraw = false; + + QString numberedFileName = fileName.left( fileName.lastIndexOf( "." ) ); + QString output = numberedFileName; + numberedFileName.append( QString( "_\%05d" ) ); + numberedFileName.append( QString( ".png" ) ); + output.append( QString( ".mov" ) ); + + QString program = QCoreApplication::applicationDirPath(); + program.append( QString( "/ffmpeg\"" ) ); + program.prepend( QString( "\"" ) ); + program.append( QString( " -r 25 -i %1 -c:v prores_ks -profile:v 4444 %2" ).arg( numberedFileName ).arg( output ) ); + qDebug() << program; + QProcess::execute( program ); + + //Update Status + m_pStatusDialog->ui->progressBar->setValue( m_pStatusDialog->ui->progressBar->maximum() ); + m_pStatusDialog->ui->progressBar->repaint(); + qApp->processEvents(); + + //Clean up + for( uint32_t i = 0; i < getMlvFrames( m_pMlvObject ); i++ ) + { + //Append frame number + QString numberedFileName = fileName.left( fileName.lastIndexOf( "." ) ); + numberedFileName.append( QString( "_%1" ).arg( (uint)i, 5, 10, QChar( '0' ) ) ); + numberedFileName.append( QString( ".png" ) ); + + //Delete file + QFile *file = new QFile( numberedFileName ); + if( file->exists() ) file->remove(); + delete file; + } + + //Hide Status Dialog + m_pStatusDialog->hide(); +} + +void MainWindow::on_checkBoxHighLightReconstruction_toggled(bool checked) +{ + if( checked ) processingEnableHighlightReconstruction( m_pProcessingObject ); + else processingDisableHighlightReconstruction( m_pProcessingObject ); + m_frameChanged = true; } diff --git a/platform/qt/MainWindow.h b/platform/qt/MainWindow.h index 58286bd2..c4b9b9d0 100644 --- a/platform/qt/MainWindow.h +++ b/platform/qt/MainWindow.h @@ -11,6 +11,7 @@ #include #include "../../src/mlv_include.h" #include "InfoDialog.h" +#include "StatusDialog.h" namespace Ui { class MainWindow; @@ -47,9 +48,12 @@ private slots: void on_actionGoto_First_Frame_triggered(); void on_actionExport_triggered(); + void on_checkBoxHighLightReconstruction_toggled(bool checked); + private: Ui::MainWindow *ui; InfoDialog *m_pInfoDialog; + StatusDialog *m_pStatusDialog; mlvObject_t *m_pMlvObject; processingObject_t *m_pProcessingObject; QLabel *m_pRawImageLabel; diff --git a/platform/qt/MainWindow.ui b/platform/qt/MainWindow.ui index b8d64fc0..84977c12 100644 --- a/platform/qt/MainWindow.ui +++ b/platform/qt/MainWindow.ui @@ -6,8 +6,8 @@ 0 0 - 1194 - 765 + 1197 + 792 @@ -790,6 +790,13 @@ + + + + Highlight reconstruction + + + @@ -822,7 +829,7 @@ 0 0 - 1194 + 1197 22 diff --git a/platform/qt/StatusDialog.cpp b/platform/qt/StatusDialog.cpp new file mode 100644 index 00000000..6d7be595 --- /dev/null +++ b/platform/qt/StatusDialog.cpp @@ -0,0 +1,13 @@ +#include "StatusDialog.h" + +StatusDialog::StatusDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::StatusDialog) +{ + ui->setupUi(this); +} + +StatusDialog::~StatusDialog() +{ + delete ui; +} diff --git a/platform/qt/StatusDialog.h b/platform/qt/StatusDialog.h new file mode 100644 index 00000000..f9377714 --- /dev/null +++ b/platform/qt/StatusDialog.h @@ -0,0 +1,21 @@ +#ifndef STATUSDIALOG_H +#define STATUSDIALOG_H + +#include +#include "ui_StatusDialog.h" + +namespace Ui { +class StatusDialog; +} + +class StatusDialog : public QDialog +{ + Q_OBJECT + +public: + explicit StatusDialog(QWidget *parent = 0); + ~StatusDialog(); + Ui::StatusDialog *ui; +}; + +#endif // STATUSDIALOG_H diff --git a/platform/qt/StatusDialog.ui b/platform/qt/StatusDialog.ui new file mode 100644 index 00000000..4abd8a2e --- /dev/null +++ b/platform/qt/StatusDialog.ui @@ -0,0 +1,28 @@ + + + StatusDialog + + + + 0 + 0 + 369 + 40 + + + + Export... + + + + + + 24 + + + + + + + +