Commit 70e78ef2 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Import: Provide transcoding for unusable files.

parent 4afe35be
......@@ -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
......
......@@ -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,16 +221,45 @@ 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()
{
......
......@@ -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;
......
......@@ -29,7 +29,7 @@ Instance::Instance( QObject* parent /*= NULL*/ ) : QObject( parent )
{
char const *argv[] =
{
// "-vvvvv",
"-vvvvv",
"--no-skip-frames",
// "--intf", "dummy",
"--text-renderer", "dummy",
......
/*****************``************************************************************
/*****************************************************************************
* Media.cpp: Represents a basic container for media informations.
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
......
/*****************************************************************************
* Transcoder.cpp: Handle file transcoding.
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzee-Luyssen <hugo@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();
}
/*****************************************************************************
* Transcoder.h: Handle file transcoding.
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzee-Luyssen <hugo@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
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