[vlmc-devel] commit: Import: Provide transcoding for unusable files. ( Hugo Beauzée-Luyssen )
git at videolan.org
git at videolan.org
Sat Jul 3 17:21:49 CEST 2010
vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Sat Jul 3 17:10:44 2010 +0200| [70e78ef2ccef73879014bb5f107cc1dde11927b0] | committer: Hugo Beauzée-Luyssen
Import: Provide transcoding for unusable files.
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=70e78ef2ccef73879014bb5f107cc1dde11927b0
---
src/CMakeLists.txt | 2 +
src/Gui/import/ImportController.cpp | 31 ++++++++++++++++++
src/Gui/import/ImportController.h | 2 +
src/LibVLCpp/VLCInstance.cpp | 2 +-
src/Media/Media.cpp | 2 +-
src/Media/Transcoder.cpp | 59 +++++++++++++++++++++++++++++++++++
src/Media/Transcoder.h | 49 +++++++++++++++++++++++++++++
7 files changed, 145 insertions(+), 2 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 08fa60d..00b0b9d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -136,6 +136,7 @@ ELSE(NOT WITH_GUI)
LIST( APPEND VLMC_SRCS
Commands/KeyboardShortcutHelper.cpp
Main/guimain.cpp
+ Media/Transcoder.cpp #Won't be needed without the import, so let's put it in GUI list
Gui/About.cpp
Gui/AudioSpectrumDrawer.cpp
Gui/ClickableLabel.cpp
@@ -194,6 +195,7 @@ ELSE(NOT WITH_GUI)
LIST( APPEND VLMC_HDRS
Commands/KeyboardShortcutHelper.h
+ Media/Transcoder.h #Won't be needed without the import, so let's put it in GUI list
Gui/About.h
Gui/ClickableLabel.h
Gui/ClipProperty.h
diff --git a/src/Gui/import/ImportController.cpp b/src/Gui/import/ImportController.cpp
index e4cd19d..6af9033 100644
--- a/src/Gui/import/ImportController.cpp
+++ b/src/Gui/import/ImportController.cpp
@@ -35,8 +35,10 @@
#include "MetaDataManager.h"
#include "PreviewWidget.h"
#include "TagWidget.h"
+#include "Transcoder.h"
#include <QFileSystemModel>
+#include <QMessageBox>
#include <QPalette>
#include <QSettings>
#include <QTime>
@@ -219,17 +221,46 @@ ImportController::reject()
void
ImportController::accept()
{
+ bool invalidMedias = false;
+
m_mediaListView->clear();
m_clipRenderer->stop();
collapseAllButCurrentPath();
foreach ( Clip* clip, m_temporaryMedias->clips().values() )
+ {
+ if ( clip->getMedia()->lengthMS() == 0 && clip->getMedia()->inputType() == Media::File )
+ invalidMedias = true;
Library::getInstance()->addClip( clip );
+ }
+ if ( invalidMedias == true )
+ handleInvalidMedias();
m_temporaryMedias->removeAll();
m_clipRenderer->setClip( NULL );
done( Accepted );
}
void
+ImportController::handleInvalidMedias()
+{
+ QMessageBox::StandardButton res = QMessageBox::question( NULL, tr( "Invalid medias" ),
+ tr( "Some of the medias you loaded can't be used for video editing. Do you want VLMC to convert them"
+ " so you can use them in your project?" ),
+ QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes );
+ if ( res == QMessageBox::Yes )
+ {
+ foreach ( Clip* clip, m_temporaryMedias->clips().values() )
+ {
+ if ( clip->getMedia()->lengthMS() == 0 && clip->getMedia()->inputType() == Media::File )
+ {
+ Transcoder *transcoder = new Transcoder( clip->getMedia() );
+ connect( transcoder, SIGNAL( done() ), transcoder, SLOT( deleteLater() ) );
+ transcoder->transcodeToPs();
+ }
+ }
+ }
+}
+
+void
ImportController::collapseAllButCurrentPath()
{
m_ui->treeView->collapseAll();
diff --git a/src/Gui/import/ImportController.h b/src/Gui/import/ImportController.h
index 5c4a8e1..f5858e7 100644
--- a/src/Gui/import/ImportController.h
+++ b/src/Gui/import/ImportController.h
@@ -73,6 +73,8 @@ class ImportController : public QDialog
void collapseAllButCurrentPath();
void importMedia( const QString &filePath );
void importDir( const QString &path );
+ void handleInvalidMedias();
+ private:
Ui::ImportController* m_ui;
StackViewController* m_stackNav;
// TagWidget* m_tag;
diff --git a/src/LibVLCpp/VLCInstance.cpp b/src/LibVLCpp/VLCInstance.cpp
index ddea119..24c9539 100644
--- a/src/LibVLCpp/VLCInstance.cpp
+++ b/src/LibVLCpp/VLCInstance.cpp
@@ -29,7 +29,7 @@ Instance::Instance( QObject* parent /*= NULL*/ ) : QObject( parent )
{
char const *argv[] =
{
-// "-vvvvv",
+ "-vvvvv",
"--no-skip-frames",
// "--intf", "dummy",
"--text-renderer", "dummy",
diff --git a/src/Media/Media.cpp b/src/Media/Media.cpp
index 14ea7a9..9eaf446 100644
--- a/src/Media/Media.cpp
+++ b/src/Media/Media.cpp
@@ -1,4 +1,4 @@
-/*****************``************************************************************
+/*****************************************************************************
* Media.cpp: Represents a basic container for media informations.
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
diff --git a/src/Media/Transcoder.cpp b/src/Media/Transcoder.cpp
new file mode 100644
index 0000000..420fc3c
--- /dev/null
+++ b/src/Media/Transcoder.cpp
@@ -0,0 +1,59 @@
+/*****************************************************************************
+ * Transcoder.cpp: Handle file transcoding.
+ *****************************************************************************
+ * Copyright (C) 2008-2010 VideoLAN
+ *
+ * Authors: Hugo Beauzee-Luyssen <hugo at vlmc.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#include "Transcoder.h"
+
+#include "LibVLCpp/VLCMedia.h"
+#include "LibVLCpp/VLCMediaPlayer.h"
+#include "Media.h"
+#include "SettingsManager.h"
+
+#include <QFileInfo>
+
+Transcoder::Transcoder( Media* media ) :
+ m_media( media )
+{
+}
+
+void
+Transcoder::transcodeToPs()
+{
+ QString outputDir = VLMC_PROJECT_GET_STRING( "general/Workspace" );
+ LibVLCpp::Media *media = new LibVLCpp::Media( m_media->fileInfo()->absoluteFilePath() );
+
+ if ( outputDir.length() == 0 )
+ outputDir = m_media->fileInfo()->absolutePath();
+ m_destinationFile = outputDir + '/' + m_media->fileInfo()->baseName() + ".ps";
+ QString option = ":sout=file://" + m_destinationFile;
+ media->addOption( option.toStdString().c_str() );
+ LibVLCpp::MediaPlayer *mp = new LibVLCpp::MediaPlayer( media );
+ connect( mp, SIGNAL( positionChanged( float ) ), this, SIGNAL( progress( float ) ) );
+ connect( mp, SIGNAL( endReached() ), this, SLOT( transcodeFinished() ) );
+ mp->play();
+}
+
+void
+Transcoder::transcodeFinished()
+{
+ m_media->setFilePath( m_destinationFile );
+ emit done();
+}
diff --git a/src/Media/Transcoder.h b/src/Media/Transcoder.h
new file mode 100644
index 0000000..dcfd622
--- /dev/null
+++ b/src/Media/Transcoder.h
@@ -0,0 +1,49 @@
+/*****************************************************************************
+ * Transcoder.h: Handle file transcoding.
+ *****************************************************************************
+ * Copyright (C) 2008-2010 VideoLAN
+ *
+ * Authors: Hugo Beauzee-Luyssen <hugo at vlmc.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifndef TRANSCODER_H
+#define TRANSCODER_H
+
+#include <QObject>
+
+#include "Media.h"
+
+class Transcoder : public QObject
+{
+ Q_OBJECT
+ public:
+ explicit Transcoder( Media *media );
+ void transcodeToPs();
+
+ private:
+ Media *m_media;
+ QString m_destinationFile;
+
+ private slots:
+ void transcodeFinished();
+
+ signals:
+ void progress( float pos );
+ void done();
+};
+
+#endif // TRANSCODER_H
More information about the Vlmc-devel
mailing list