Don't try to encode from source files that aren't supported by the encoder. No real support for upstream decoders yet.
This commit is contained in:
parent
9947e9c839
commit
a29780ef2a
@ -25,7 +25,7 @@
|
|||||||
#define VER_LAMEXP_MAJOR 4
|
#define VER_LAMEXP_MAJOR 4
|
||||||
#define VER_LAMEXP_MINOR_HI 0
|
#define VER_LAMEXP_MINOR_HI 0
|
||||||
#define VER_LAMEXP_MINOR_LO 0
|
#define VER_LAMEXP_MINOR_LO 0
|
||||||
#define VER_LAMEXP_BUILD 78
|
#define VER_LAMEXP_BUILD 79
|
||||||
#define VER_LAMEXP_SUFFIX TechPreview
|
#define VER_LAMEXP_SUFFIX TechPreview
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -264,13 +264,13 @@ void ProcessingDialog::doneEncoding(void)
|
|||||||
|
|
||||||
if(m_userAborted)
|
if(m_userAborted)
|
||||||
{
|
{
|
||||||
label_progress->setText("Process was aborted by the user!");
|
label_progress->setText(QString("Process was aborted by the user after %1 files!").arg(QString::number(m_succeededFiles)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(m_failedFiles)
|
if(m_failedFiles)
|
||||||
{
|
{
|
||||||
label_progress->setText(QString("Error: %1 of %2 files failed. See the log for details!").arg(QString::number(m_failedFiles), QString::number(m_failedFiles + m_succeededFiles)));
|
label_progress->setText(QString("Error: %1 of %2 files failed. Double-click failed items for detailed information!").arg(QString::number(m_failedFiles), QString::number(m_failedFiles + m_succeededFiles)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -282,6 +282,7 @@ void ProcessingDialog::doneEncoding(void)
|
|||||||
button_closeDialog->setEnabled(true);
|
button_closeDialog->setEnabled(true);
|
||||||
button_AbortProcess->setEnabled(false);
|
button_AbortProcess->setEnabled(false);
|
||||||
|
|
||||||
|
view_log->scrollToBottom();
|
||||||
m_progressIndicator->stop();
|
m_progressIndicator->stop();
|
||||||
progressBar->setValue(100);
|
progressBar->setValue(100);
|
||||||
}
|
}
|
||||||
|
@ -37,12 +37,16 @@ public:
|
|||||||
AbstractEncoder(void);
|
AbstractEncoder(void);
|
||||||
~AbstractEncoder(void);
|
~AbstractEncoder(void);
|
||||||
|
|
||||||
|
//Internal encoder API
|
||||||
virtual bool encode(const AudioFileModel &sourceFile, const QString &outputFile, volatile bool *abortFlag) = 0;
|
virtual bool encode(const AudioFileModel &sourceFile, const QString &outputFile, volatile bool *abortFlag) = 0;
|
||||||
|
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion) = 0;
|
||||||
virtual QString extension(void) = 0;
|
virtual QString extension(void) = 0;
|
||||||
|
|
||||||
|
//Common setter methods
|
||||||
void setBitrate(int bitrate);
|
void setBitrate(int bitrate);
|
||||||
void setRCMode(int mode);
|
void setRCMode(int mode);
|
||||||
|
|
||||||
|
//Auxiliary functions
|
||||||
bool startProcess(QProcess &process, const QString &program, const QStringList &args);
|
bool startProcess(QProcess &process, const QString &program, const QStringList &args);
|
||||||
static QString commandline2string(const QString &program, const QStringList &arguments);
|
static QString commandline2string(const QString &program, const QStringList &arguments);
|
||||||
|
|
||||||
|
@ -147,3 +147,29 @@ QString MP3Encoder::extension(void)
|
|||||||
{
|
{
|
||||||
return "mp3";
|
return "mp3";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MP3Encoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||||
|
{
|
||||||
|
if(containerType.compare("Wave", Qt::CaseInsensitive) == 0)
|
||||||
|
{
|
||||||
|
if(formatType.compare("PCM", Qt::CaseInsensitive) == 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(containerType.compare("MPEG Audio", Qt::CaseInsensitive) == 0)
|
||||||
|
{
|
||||||
|
if(formatType.compare("MPEG Audio", Qt::CaseInsensitive) == 0)
|
||||||
|
{
|
||||||
|
if(formatProfile.compare("Layer 3", Qt::CaseInsensitive) == 0 || formatProfile.compare("Layer 2", Qt::CaseInsensitive) == 0)
|
||||||
|
{
|
||||||
|
if(formatVersion.compare("Version 1", Qt::CaseInsensitive) == 0 || formatVersion.compare("Version 2", Qt::CaseInsensitive) == 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -34,6 +34,7 @@ public:
|
|||||||
~MP3Encoder(void);
|
~MP3Encoder(void);
|
||||||
|
|
||||||
virtual bool encode(const AudioFileModel &sourceFile, const QString &outputFile, volatile bool *abortFlag);
|
virtual bool encode(const AudioFileModel &sourceFile, const QString &outputFile, volatile bool *abortFlag);
|
||||||
|
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
|
||||||
virtual QString extension(void);
|
virtual QString extension(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -76,6 +76,15 @@ void ProcessThread::run()
|
|||||||
if(outFileName.isEmpty())
|
if(outFileName.isEmpty())
|
||||||
{
|
{
|
||||||
emit processStateChanged(m_jobId, "Not found!", ProgressModel::JobFailed);
|
emit processStateChanged(m_jobId, "Not found!", ProgressModel::JobFailed);
|
||||||
|
emit processStateFinished(m_jobId, outFileName, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!m_encoder->isFormatSupported(m_audioFile.formatContainerType(), m_audioFile.formatContainerProfile(), m_audioFile.formatAudioType(), m_audioFile.formatAudioProfile(), m_audioFile.formatAudioVersion()))
|
||||||
|
{
|
||||||
|
handleMessage(QString("The format of this file is NOT supported:\n%1\n\nContainer Format:\t%2\nAudio Format:\t%3").arg(m_audioFile.filePath(), m_audioFile.formatContainerInfo(), m_audioFile.formatAudioCompressInfo()));
|
||||||
|
emit processStateChanged(m_jobId, "Unsupported!", ProgressModel::JobFailed);
|
||||||
|
emit processStateFinished(m_jobId, outFileName, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,9 +129,21 @@ QString ProcessThread::generateOutFileName(void)
|
|||||||
QFileInfo sourceFile(m_audioFile.filePath());
|
QFileInfo sourceFile(m_audioFile.filePath());
|
||||||
if(!sourceFile.exists() || !sourceFile.isFile())
|
if(!sourceFile.exists() || !sourceFile.isFile())
|
||||||
{
|
{
|
||||||
|
handleMessage(QString("The source audio file could not be found:\n%1").arg(sourceFile.absoluteFilePath()));
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QFile readTest(sourceFile.canonicalFilePath());
|
||||||
|
if(!readTest.open(QIODevice::ReadOnly))
|
||||||
|
{
|
||||||
|
handleMessage(QString("The source audio file could not be opened for reading:\n%1").arg(readTest.fileName()));
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
readTest.close();
|
||||||
|
}
|
||||||
|
|
||||||
QString baseName = sourceFile.completeBaseName();
|
QString baseName = sourceFile.completeBaseName();
|
||||||
QDir targetDir(m_outputDirectory.isEmpty() ? sourceFile.canonicalPath() : m_outputDirectory);
|
QDir targetDir(m_outputDirectory.isEmpty() ? sourceFile.canonicalPath() : m_outputDirectory);
|
||||||
|
|
||||||
@ -131,10 +152,23 @@ QString ProcessThread::generateOutFileName(void)
|
|||||||
targetDir.mkpath(".");
|
targetDir.mkpath(".");
|
||||||
if(!targetDir.exists())
|
if(!targetDir.exists())
|
||||||
{
|
{
|
||||||
|
handleMessage(QString("The target output directory doesn't exist and could NOT be created:\n%1").arg(targetDir.absolutePath()));
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QFile writeTest(QString("%1/%2").arg(targetDir.canonicalPath(), QUuid::createUuid().toString()));
|
||||||
|
if(!writeTest.open(QIODevice::ReadWrite))
|
||||||
|
{
|
||||||
|
handleMessage(QString("The target output directory is NOT writable:\n%1").arg(targetDir.absolutePath()));
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writeTest.close();
|
||||||
|
writeTest.remove();
|
||||||
|
}
|
||||||
|
|
||||||
QString outFileName = QString("%1/%2.%3").arg(targetDir.canonicalPath(), baseName, "mp3");
|
QString outFileName = QString("%1/%2.%3").arg(targetDir.canonicalPath(), baseName, "mp3");
|
||||||
while(QFileInfo(outFileName).exists())
|
while(QFileInfo(outFileName).exists())
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user