Re-enable transcoder and organiser, add transcoder for wavpack

This commit is contained in:
Jonas Kvinge
2019-01-06 14:34:50 +01:00
parent a11f43520e
commit 14cfd1a34e
25 changed files with 463 additions and 272 deletions

View File

@@ -106,8 +106,7 @@ TranscodeDialog::TranscodeDialog(QWidget *parent)
QString last_output_format = s.value("last_output_format", "audio/x-vorbis").toString();
for (int i = 0; i < ui_->format->count(); ++i) {
if (last_output_format ==
ui_->format->itemData(i).value<TranscoderPreset>().codec_mimetype_) {
if (last_output_format == ui_->format->itemData(i).value<TranscoderPreset>().codec_mimetype_) {
ui_->format->setCurrentIndex(i);
break;
}

View File

@@ -202,7 +202,9 @@ void Transcoder::JobState::PostFinished(bool success) {
}
Transcoder::Transcoder(QObject *parent, const QString &settings_postfix)
: QObject(parent), max_threads_(QThread::idealThreadCount()), settings_postfix_(settings_postfix) {
: QObject(parent),
max_threads_(QThread::idealThreadCount()),
settings_postfix_(settings_postfix) {
if (JobFinishedEvent::sEventType == -1)
JobFinishedEvent::sEventType = QEvent::registerEventType();
@@ -223,15 +225,16 @@ Transcoder::Transcoder(QObject *parent, const QString &settings_postfix)
QList<TranscoderPreset> Transcoder::GetAllPresets() {
QList<TranscoderPreset> ret;
ret << PresetForFileType(Song::FileType_FLAC);
ret << PresetForFileType(Song::FileType_MP4);
ret << PresetForFileType(Song::FileType_MPEG);
ret << PresetForFileType(Song::FileType_OggVorbis);
ret << PresetForFileType(Song::FileType_OggFlac);
ret << PresetForFileType(Song::FileType_OggSpeex);
ret << PresetForFileType(Song::FileType_ASF);
ret << PresetForFileType(Song::FileType_WAV);
ret << PresetForFileType(Song::FileType_FLAC);
ret << PresetForFileType(Song::FileType_WavPack);
ret << PresetForFileType(Song::FileType_OggFlac);
ret << PresetForFileType(Song::FileType_OggVorbis);
ret << PresetForFileType(Song::FileType_OggOpus);
ret << PresetForFileType(Song::FileType_OggSpeex);
ret << PresetForFileType(Song::FileType_MPEG);
ret << PresetForFileType(Song::FileType_MP4);
ret << PresetForFileType(Song::FileType_ASF);
return ret;
}
@@ -239,24 +242,26 @@ QList<TranscoderPreset> Transcoder::GetAllPresets() {
TranscoderPreset Transcoder::PresetForFileType(Song::FileType type) {
switch (type) {
case Song::FileType_FLAC:
return TranscoderPreset(type, tr("FLAC"), "flac", "audio/x-flac");
case Song::FileType_MP4:
return TranscoderPreset(type, tr("M4A AAC"), "mp4", "audio/mpeg, mpegversion=(int)4", "audio/mp4");
case Song::FileType_MPEG:
return TranscoderPreset(type, tr("MP3"), "mp3", "audio/mpeg, mpegversion=(int)1, layer=(int)3");
case Song::FileType_OggVorbis:
return TranscoderPreset(type, tr("Ogg Vorbis"), "ogg", "audio/x-vorbis", "application/ogg");
case Song::FileType_OggFlac:
return TranscoderPreset(type, tr("Ogg FLAC"), "ogg", "audio/x-flac", "application/ogg");
case Song::FileType_OggSpeex:
return TranscoderPreset(type, tr("Ogg Speex"), "spx", "audio/x-speex", "application/ogg");
case Song::FileType_OggOpus:
return TranscoderPreset(type, tr("Ogg Opus"), "opus", "audio/x-opus", "application/ogg");
case Song::FileType_ASF:
return TranscoderPreset(type, tr("Windows Media audio"), "wma", "audio/x-wma", "video/x-ms-asf");
case Song::FileType_WAV:
return TranscoderPreset(type, tr("Wav"), "wav", QString(), "audio/x-wav");
return TranscoderPreset(type, "Wav", "wav", QString(), "audio/x-wav");
case Song::FileType_FLAC:
return TranscoderPreset(type, "FLAC", "flac", "audio/x-flac");
case Song::FileType_WavPack:
return TranscoderPreset(type, "WavPack", "wv", "audio/x-wavpack");
case Song::FileType_OggFlac:
return TranscoderPreset(type, "Ogg FLAC", "ogg", "audio/x-flac", "application/ogg");
case Song::FileType_OggVorbis:
return TranscoderPreset(type, "Ogg Vorbis", "ogg", "audio/x-vorbis", "application/ogg");
case Song::FileType_OggOpus:
return TranscoderPreset(type, "Ogg Opus", "opus", "audio/x-opus", "application/ogg");
case Song::FileType_OggSpeex:
return TranscoderPreset(type, "Ogg Speex", "spx", "audio/x-speex", "application/ogg");
case Song::FileType_MPEG:
return TranscoderPreset(type, "MP3", "mp3", "audio/mpeg, mpegversion=(int)1, layer=(int)3");
case Song::FileType_MP4:
return TranscoderPreset(type, "M4A AAC", "mp4", "audio/mpeg, mpegversion=(int)4", "audio/mp4");
case Song::FileType_ASF:
return TranscoderPreset(type, "Windows Media audio", "wma", "audio/x-wma", "video/x-ms-asf");
default:
qLog(Warning) << "Unsupported format in PresetForFileType:" << type;
return TranscoderPreset();
@@ -269,9 +274,9 @@ Song::FileType Transcoder::PickBestFormat(QList<Song::FileType> supported) {
if (supported.isEmpty()) return Song::FileType_Unknown;
QList<Song::FileType> best_formats;
best_formats << Song::FileType_MPEG;
best_formats << Song::FileType_OggVorbis;
best_formats << Song::FileType_ASF;
best_formats << Song::FileType_FLAC;
best_formats << Song::FileType_OggFlac;
best_formats << Song::FileType_WavPack;
for (Song::FileType type : best_formats) {
if (supported.isEmpty() || supported.contains(type)) return type;
@@ -413,13 +418,13 @@ bool Transcoder::StartJob(const Job &job) {
if (!state->pipeline_) return false;
// Create all the elements
GstElement *src = CreateElement("filesrc", state->pipeline_);
GstElement *decode = CreateElement("decodebin", state->pipeline_);
GstElement *convert = CreateElement("audioconvert", state->pipeline_);
GstElement *src = CreateElement("filesrc", state->pipeline_);
GstElement *decode = CreateElement("decodebin", state->pipeline_);
GstElement *convert = CreateElement("audioconvert", state->pipeline_);
GstElement *resample = CreateElement("audioresample", state->pipeline_);
GstElement *codec = CreateElementForMimeType("Codec/Encoder/Audio", job.preset.codec_mimetype_, state->pipeline_);
GstElement *muxer = CreateElementForMimeType("Codec/Muxer", job.preset.muxer_mimetype_, state->pipeline_);
GstElement *sink = CreateElement("filesink", state->pipeline_);
GstElement *sink = CreateElement("filesink", state->pipeline_);
if (!src || !decode || !convert || !sink) return false;
@@ -558,7 +563,7 @@ void Transcoder::SetElementProperties(const QString &name, GObject *object) {
s.beginGroup("Transcoder/" + name + settings_postfix_);
guint properties_count = 0;
GParamSpec **properties = g_object_class_list_properties( G_OBJECT_GET_CLASS(object), &properties_count);
GParamSpec **properties = g_object_class_list_properties(G_OBJECT_GET_CLASS(object), &properties_count);
for (int i = 0; i < properties_count; ++i) {
GParamSpec *property = properties[i];

View File

@@ -48,7 +48,7 @@ void TranscoderOptionsAAC::Load() {
QSettings s;
s.beginGroup(kSettingsGroup + settings_postfix_);
ui_->bitrate_slider->setValue(s.value("bitrate", 128000).toInt() / 1000);
ui_->bitrate_slider->setValue(s.value("bitrate", 320000).toInt() / 1000);
ui_->profile->setCurrentIndex(s.value("profile", 2).toInt() - 1);
ui_->tns->setChecked(s.value("tns", false).toBool());
ui_->midside->setChecked(s.value("midside", true).toBool());

View File

@@ -28,30 +28,30 @@
#include <QSettings>
#include "transcoder/transcoderoptionsinterface.h"
#include "transcoderoptionswma.h"
#include "ui_transcoderoptionswma.h"
#include "transcoderoptionsasf.h"
#include "ui_transcoderoptionsasf.h"
const char *TranscoderOptionsWma::kSettingsGroup = "Transcoder/ffenc_wmav2";
const char *TranscoderOptionsASF::kSettingsGroup = "Transcoder/ffenc_wmav2";
TranscoderOptionsWma::TranscoderOptionsWma(QWidget *parent)
: TranscoderOptionsInterface(parent), ui_(new Ui_TranscoderOptionsWma) {
TranscoderOptionsASF::TranscoderOptionsASF(QWidget *parent)
: TranscoderOptionsInterface(parent), ui_(new Ui_TranscoderOptionsASF) {
ui_->setupUi(this);
}
TranscoderOptionsWma::~TranscoderOptionsWma() {
TranscoderOptionsASF::~TranscoderOptionsASF() {
delete ui_;
}
void TranscoderOptionsWma::Load() {
void TranscoderOptionsASF::Load() {
QSettings s;
s.beginGroup(kSettingsGroup + settings_postfix_);
ui_->bitrate_slider->setValue(s.value("bitrate", 128000).toInt() / 1000);
ui_->bitrate_slider->setValue(s.value("bitrate", 320000).toInt() / 1000);
}
void TranscoderOptionsWma::Save() {
void TranscoderOptionsASF::Save() {
QSettings s;
s.beginGroup(kSettingsGroup + settings_postfix_);

View File

@@ -18,8 +18,8 @@
*
*/
#ifndef TRANSCODEROPTIONSWMA_H
#define TRANSCODEROPTIONSWMA_H
#ifndef TRANSCODEROPTIONSASF_H
#define TRANSCODEROPTIONSASF_H
#include "config.h"
@@ -27,12 +27,12 @@
#include "transcoderoptionsinterface.h"
class Ui_TranscoderOptionsWma;
class Ui_TranscoderOptionsASF;
class TranscoderOptionsWma : public TranscoderOptionsInterface {
class TranscoderOptionsASF : public TranscoderOptionsInterface {
public:
TranscoderOptionsWma(QWidget *parent = nullptr);
~TranscoderOptionsWma();
TranscoderOptionsASF(QWidget *parent = nullptr);
~TranscoderOptionsASF();
void Load();
void Save();
@@ -40,7 +40,7 @@ class TranscoderOptionsWma : public TranscoderOptionsInterface {
private:
static const char *kSettingsGroup;
Ui_TranscoderOptionsWma *ui_;
Ui_TranscoderOptionsASF *ui_;
};
#endif // TRANSCODEROPTIONSWMA_H
#endif // TRANSCODEROPTIONSASF_H

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TranscoderOptionsWma</class>
<widget class="QWidget" name="TranscoderOptionsWma">
<class>TranscoderOptionsASF</class>
<widget class="QWidget" name="TranscoderOptionsASF">
<property name="geometry">
<rect>
<x>0</x>

View File

@@ -28,30 +28,34 @@
#include <QLayout>
#include "transcoderoptionsinterface.h"
#include "transcoderoptionsaac.h"
#include "transcoderoptionsdialog.h"
#include "transcoderoptionsflac.h"
#include "transcoderoptionsmp3.h"
#include "transcoderoptionswavpack.h"
#include "transcoderoptionsvorbis.h"
#include "transcoderoptionsopus.h"
#include "transcoderoptionsspeex.h"
#include "transcoderoptionsvorbis.h"
#include "transcoderoptionswma.h"
#include "transcoderoptionsasf.h"
#include "transcoderoptionsaac.h"
#include "transcoderoptionsmp3.h"
#include "ui_transcoderoptionsdialog.h"
TranscoderOptionsDialog::TranscoderOptionsDialog(Song::FileType type, QWidget *parent)
: QDialog(parent), ui_(new Ui_TranscoderOptionsDialog), options_(nullptr) {
: QDialog(parent),
ui_(new Ui_TranscoderOptionsDialog),
options_(nullptr) {
ui_->setupUi(this);
switch (type) {
case Song::FileType_FLAC:
case Song::FileType_OggFlac: options_ = new TranscoderOptionsFlac(this); break;
case Song::FileType_MP4: options_ = new TranscoderOptionsAAC(this); break;
case Song::FileType_MPEG: options_ = new TranscoderOptionsMP3(this); break;
case Song::FileType_OggVorbis: options_ = new TranscoderOptionsVorbis(this); break;
case Song::FileType_OggOpus: options_ = new TranscoderOptionsOpus(this); break;
case Song::FileType_OggSpeex: options_ = new TranscoderOptionsSpeex(this); break;
case Song::FileType_ASF: options_ = new TranscoderOptionsWma(this); break;
case Song::FileType_OggFlac: options_ = new TranscoderOptionsFLAC(this); break;
case Song::FileType_WavPack: options_ = new TranscoderOptionsWavPack(this); break;
case Song::FileType_OggVorbis: options_ = new TranscoderOptionsVorbis(this); break;
case Song::FileType_OggOpus: options_ = new TranscoderOptionsOpus(this); break;
case Song::FileType_OggSpeex: options_ = new TranscoderOptionsSpeex(this); break;
case Song::FileType_MP4: options_ = new TranscoderOptionsAAC(this); break;
case Song::FileType_MPEG: options_ = new TranscoderOptionsMP3(this); break;
case Song::FileType_ASF: options_ = new TranscoderOptionsASF(this); break;
default:
break;
}

View File

@@ -31,25 +31,25 @@
#include "transcoderoptionsflac.h"
#include "ui_transcoderoptionsflac.h"
const char *TranscoderOptionsFlac::kSettingsGroup = "Transcoder/flacenc";
const char *TranscoderOptionsFLAC::kSettingsGroup = "Transcoder/flacenc";
TranscoderOptionsFlac::TranscoderOptionsFlac(QWidget *parent)
: TranscoderOptionsInterface(parent), ui_(new Ui_TranscoderOptionsFlac) {
TranscoderOptionsFLAC::TranscoderOptionsFLAC(QWidget *parent)
: TranscoderOptionsInterface(parent), ui_(new Ui_TranscoderOptionsFLAC) {
ui_->setupUi(this);
}
TranscoderOptionsFlac::~TranscoderOptionsFlac() {
TranscoderOptionsFLAC::~TranscoderOptionsFLAC() {
delete ui_;
}
void TranscoderOptionsFlac::Load() {
void TranscoderOptionsFLAC::Load() {
QSettings s;
s.beginGroup(kSettingsGroup + settings_postfix_);
ui_->quality->setValue(s.value("quality", 5).toInt());
}
void TranscoderOptionsFlac::Save() {
void TranscoderOptionsFLAC::Save() {
QSettings s;
s.beginGroup(kSettingsGroup + settings_postfix_);

View File

@@ -27,12 +27,12 @@
#include "transcoderoptionsinterface.h"
class Ui_TranscoderOptionsFlac;
class Ui_TranscoderOptionsFLAC;
class TranscoderOptionsFlac : public TranscoderOptionsInterface {
class TranscoderOptionsFLAC : public TranscoderOptionsInterface {
public:
TranscoderOptionsFlac(QWidget *parent = nullptr);
~TranscoderOptionsFlac();
TranscoderOptionsFLAC(QWidget *parent = nullptr);
~TranscoderOptionsFLAC();
void Load();
void Save();
@@ -40,7 +40,7 @@ class TranscoderOptionsFlac : public TranscoderOptionsInterface {
private:
static const char *kSettingsGroup;
Ui_TranscoderOptionsFlac *ui_;
Ui_TranscoderOptionsFLAC *ui_;
};
#endif // TRANSCODEROPTIONSFLAC_H

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TranscoderOptionsFlac</class>
<widget class="QWidget" name="TranscoderOptionsFlac">
<class>TranscoderOptionsFLAC</class>
<widget class="QWidget" name="TranscoderOptionsFLAC">
<property name="geometry">
<rect>
<x>0</x>

View File

@@ -62,8 +62,8 @@ void TranscoderOptionsMP3::Load() {
ui_->target_bitrate->setChecked(true);
}
ui_->quality_spinbox->setValue(s.value("quality", 4.0).toFloat());
ui_->bitrate_slider->setValue(s.value("bitrate", 128).toInt());
ui_->quality_spinbox->setValue(s.value("quality", 10).toFloat());
ui_->bitrate_slider->setValue(s.value("bitrate", 320).toInt());
ui_->cbr->setChecked(s.value("cbr", true).toBool());
ui_->encoding_engine_quality->setCurrentIndex(s.value("encoding-engine-quality", 1).toInt());
ui_->mono->setChecked(s.value("mono", false).toBool());

View File

@@ -47,7 +47,7 @@ void TranscoderOptionsOpus::Load() {
QSettings s;
s.beginGroup(kSettingsGroup + settings_postfix_);
ui_->bitrate_slider->setValue(s.value("bitrate", 128000).toInt() / 1000);
ui_->bitrate_slider->setValue(s.value("bitrate", 320000).toInt() / 1000);
}
void TranscoderOptionsOpus::Save() {

View File

@@ -52,7 +52,7 @@ void TranscoderOptionsSpeex::Load() {
QSettings s;
s.beginGroup(kSettingsGroup + settings_postfix_);
ui_->quality_slider->setValue(s.value("quality", 8).toInt());
ui_->quality_slider->setValue(s.value("quality", 10).toInt());
ui_->bitrate_slider->setValue(s.value("bitrate", 0).toInt() / 1000);
ui_->mode->setCurrentIndex(s.value("mode", 0).toInt());
ui_->vbr->setChecked(s.value("vbr", false).toBool());

View File

@@ -59,7 +59,7 @@ void TranscoderOptionsVorbis::Load() {
GET_BITRATE(max_bitrate, "max-bitrate");
#undef GET_BITRATE
ui_->quality_slider->setValue(s.value("quality", 0.3).toDouble() * 10);
ui_->quality_slider->setValue(s.value("quality", 1.0).toDouble() * 10);
ui_->managed->setChecked(s.value("managed", false).toBool());
ui_->max_bitrate_slider->setValue(max_bitrate);
ui_->min_bitrate_slider->setValue(min_bitrate);

View File

@@ -0,0 +1,54 @@
/*
* Strawberry Music Player
* Copyright 2018, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry 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 3 of the License, or
* (at your option) any later version.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <QWidget>
#include <QVariant>
#include <QString>
#include <QStringBuilder>
#include <QSlider>
#include <QSettings>
#include "transcoderoptionsinterface.h"
#include "transcoderoptionswavpack.h"
#include "ui_transcoderoptionswavpack.h"
const char *TranscoderOptionsWavPack::kSettingsGroup = "Transcoder/wavpackenc";
TranscoderOptionsWavPack::TranscoderOptionsWavPack(QWidget *parent)
: TranscoderOptionsInterface(parent), ui_(new Ui_TranscoderOptionsWavPack) {
ui_->setupUi(this);
}
TranscoderOptionsWavPack::~TranscoderOptionsWavPack() {
delete ui_;
}
void TranscoderOptionsWavPack::Load() {
QSettings s;
s.beginGroup(kSettingsGroup + settings_postfix_);
s.endGroup();
}
void TranscoderOptionsWavPack::Save() {
QSettings s;
s.beginGroup(kSettingsGroup + settings_postfix_);
s.endGroup();
}

View File

@@ -0,0 +1,45 @@
/*
* Strawberry Music Player
* Copyright 2018, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry 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 3 of the License, or
* (at your option) any later version.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef TRANSCODEROPTIONSWAVPACK_H
#define TRANSCODEROPTIONSWAVPACK_H
#include "config.h"
#include <QWidget>
#include "transcoderoptionsinterface.h"
class Ui_TranscoderOptionsWavPack;
class TranscoderOptionsWavPack : public TranscoderOptionsInterface {
public:
TranscoderOptionsWavPack(QWidget *parent = nullptr);
~TranscoderOptionsWavPack();
void Load();
void Save();
private:
static const char *kSettingsGroup;
Ui_TranscoderOptionsWavPack *ui_;
};
#endif // TRANSCODEROPTIONSWAVPACK_H

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TranscoderOptionsWavPack</class>
<widget class="QWidget" name="TranscoderOptionsWavPack">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>102</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>