From f1ae96bcb6afa482704d992b340bf0fd7e4b54ca Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 9 Apr 2012 23:26:28 +0200 Subject: [PATCH] File identification & track/file parsing --- src/mmg-qt/forms/main_window.h | 68 ++++++++++------ src/mmg-qt/forms/main_window.ui | 53 +++++++++--- src/mmg-qt/main_window.cpp | 4 +- src/mmg-qt/source_file.cpp | 53 ++++++++++++ src/mmg-qt/source_file.h | 37 +++++++++ src/mmg-qt/track.cpp | 121 ++++++++++++++++++++++++++++ src/mmg-qt/track.h | 68 ++++++++++++++++ src/mmg-qt/util/file_identifier.cpp | 111 ++++++++++++++++++++++++- src/mmg-qt/util/file_identifier.h | 13 +++ src/mmg-qt/util/settings.cpp | 2 + src/mmg-qt/util/settings.h | 1 + 11 files changed, 488 insertions(+), 43 deletions(-) create mode 100644 src/mmg-qt/source_file.cpp create mode 100644 src/mmg-qt/source_file.h create mode 100644 src/mmg-qt/track.cpp create mode 100644 src/mmg-qt/track.h diff --git a/src/mmg-qt/forms/main_window.h b/src/mmg-qt/forms/main_window.h index b3654e603..2f8d89ab5 100644 --- a/src/mmg-qt/forms/main_window.h +++ b/src/mmg-qt/forms/main_window.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'main_window.ui' ** -** Created: Mon Apr 9 19:48:41 2012 +** Created: Mon Apr 9 23:10:51 2012 ** by: Qt User Interface Compiler version 4.7.4 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! @@ -73,6 +73,8 @@ public: QVBoxLayout *verticalLayout_9; QGroupBox *groupBox_7; QGridLayout *gridLayout_5; + QLabel *label_35; + QComboBox *muxThis; QLabel *label_16; QLineEdit *trackName; QLabel *label_17; @@ -301,7 +303,7 @@ public: scrollArea->setWidgetResizable(true); scrollAreaWidgetContents = new QWidget(); scrollAreaWidgetContents->setObjectName(QString::fromUtf8("scrollAreaWidgetContents")); - scrollAreaWidgetContents->setGeometry(QRect(0, -366, 402, 757)); + scrollAreaWidgetContents->setGeometry(QRect(0, 0, 402, 784)); verticalLayout_9 = new QVBoxLayout(scrollAreaWidgetContents); verticalLayout_9->setSpacing(6); verticalLayout_9->setContentsMargins(11, 11, 11, 11); @@ -312,50 +314,60 @@ public: gridLayout_5->setSpacing(6); gridLayout_5->setContentsMargins(11, 11, 11, 11); gridLayout_5->setObjectName(QString::fromUtf8("gridLayout_5")); + label_35 = new QLabel(groupBox_7); + label_35->setObjectName(QString::fromUtf8("label_35")); + + gridLayout_5->addWidget(label_35, 0, 0, 1, 1); + + muxThis = new QComboBox(groupBox_7); + muxThis->setObjectName(QString::fromUtf8("muxThis")); + + gridLayout_5->addWidget(muxThis, 0, 1, 1, 1); + label_16 = new QLabel(groupBox_7); label_16->setObjectName(QString::fromUtf8("label_16")); - gridLayout_5->addWidget(label_16, 0, 0, 1, 1); + gridLayout_5->addWidget(label_16, 1, 0, 1, 1); trackName = new QLineEdit(groupBox_7); trackName->setObjectName(QString::fromUtf8("trackName")); - gridLayout_5->addWidget(trackName, 0, 1, 1, 1); + gridLayout_5->addWidget(trackName, 1, 1, 1, 1); label_17 = new QLabel(groupBox_7); label_17->setObjectName(QString::fromUtf8("label_17")); - gridLayout_5->addWidget(label_17, 1, 0, 1, 1); + gridLayout_5->addWidget(label_17, 2, 0, 1, 1); trackLanguage = new QComboBox(groupBox_7); trackLanguage->setObjectName(QString::fromUtf8("trackLanguage")); - gridLayout_5->addWidget(trackLanguage, 1, 1, 1, 1); + gridLayout_5->addWidget(trackLanguage, 2, 1, 1, 1); label_18 = new QLabel(groupBox_7); label_18->setObjectName(QString::fromUtf8("label_18")); - gridLayout_5->addWidget(label_18, 2, 0, 1, 1); + gridLayout_5->addWidget(label_18, 3, 0, 1, 1); defaultTrackFlag = new QComboBox(groupBox_7); defaultTrackFlag->setObjectName(QString::fromUtf8("defaultTrackFlag")); - gridLayout_5->addWidget(defaultTrackFlag, 2, 1, 1, 1); + gridLayout_5->addWidget(defaultTrackFlag, 3, 1, 1, 1); label_19 = new QLabel(groupBox_7); label_19->setObjectName(QString::fromUtf8("label_19")); - gridLayout_5->addWidget(label_19, 3, 0, 1, 1); + gridLayout_5->addWidget(label_19, 4, 0, 1, 1); forcedTrackFlag = new QComboBox(groupBox_7); forcedTrackFlag->setObjectName(QString::fromUtf8("forcedTrackFlag")); - gridLayout_5->addWidget(forcedTrackFlag, 3, 1, 1, 1); + gridLayout_5->addWidget(forcedTrackFlag, 4, 1, 1, 1); label_31 = new QLabel(groupBox_7); label_31->setObjectName(QString::fromUtf8("label_31")); - gridLayout_5->addWidget(label_31, 4, 0, 1, 1); + gridLayout_5->addWidget(label_31, 5, 0, 1, 1); compression = new QComboBox(groupBox_7); compression->addItem(QString()); @@ -363,12 +375,12 @@ public: compression->addItem(QString::fromUtf8("ZLIB")); compression->setObjectName(QString::fromUtf8("compression")); - gridLayout_5->addWidget(compression, 4, 1, 1, 1); + gridLayout_5->addWidget(compression, 5, 1, 1, 1); label_20 = new QLabel(groupBox_7); label_20->setObjectName(QString::fromUtf8("label_20")); - gridLayout_5->addWidget(label_20, 5, 0, 1, 1); + gridLayout_5->addWidget(label_20, 6, 0, 1, 1); horizontalLayout_11 = new QHBoxLayout(); horizontalLayout_11->setSpacing(6); @@ -384,7 +396,7 @@ public: horizontalLayout_11->addWidget(browseTrackTags); - gridLayout_5->addLayout(horizontalLayout_11, 5, 1, 1, 1); + gridLayout_5->addLayout(horizontalLayout_11, 6, 1, 1, 1); verticalLayout_9->addWidget(groupBox_7); @@ -476,15 +488,14 @@ public: gridLayout_7->addWidget(setAspectRatio, 0, 0, 1, 1); aspectRatio = new QComboBox(groupBox_9); - aspectRatio->insertItems(0, QStringList() - << QString::fromUtf8("4/3") - << QString::fromUtf8("1.66") - << QString::fromUtf8("16/9") - << QString::fromUtf8("1.85") - << QString::fromUtf8("2.00") - << QString::fromUtf8("2.21") - << QString::fromUtf8("2.35") - ); + aspectRatio->addItem(QString()); + aspectRatio->addItem(QString::fromUtf8("4/3")); + aspectRatio->addItem(QString::fromUtf8("1.66")); + aspectRatio->addItem(QString::fromUtf8("16/9")); + aspectRatio->addItem(QString::fromUtf8("1.85")); + aspectRatio->addItem(QString::fromUtf8("2.00")); + aspectRatio->addItem(QString::fromUtf8("2.21")); + aspectRatio->addItem(QString::fromUtf8("2.35")); aspectRatio->setObjectName(QString::fromUtf8("aspectRatio")); aspectRatio->setEditable(true); @@ -1086,7 +1097,8 @@ public: QWidget::setTabOrder(mainTab, files); QWidget::setTabOrder(files, tracks); QWidget::setTabOrder(tracks, scrollArea); - QWidget::setTabOrder(scrollArea, trackName); + QWidget::setTabOrder(scrollArea, muxThis); + QWidget::setTabOrder(muxThis, trackName); QWidget::setTabOrder(trackName, trackLanguage); QWidget::setTabOrder(trackLanguage, defaultTrackFlag); QWidget::setTabOrder(defaultTrackFlag, forcedTrackFlag); @@ -1203,6 +1215,12 @@ public: label_2->setText(QApplication::translate("MainWindow", "Tracks, chapters, tags and attachments:", 0, QApplication::UnicodeUTF8)); label_3->setText(QApplication::translate("MainWindow", "Properties:", 0, QApplication::UnicodeUTF8)); groupBox_7->setTitle(QApplication::translate("MainWindow", "General options", 0, QApplication::UnicodeUTF8)); + label_35->setText(QApplication::translate("MainWindow", "Mux this:", 0, QApplication::UnicodeUTF8)); + muxThis->clear(); + muxThis->insertItems(0, QStringList() + << QApplication::translate("MainWindow", "yes", 0, QApplication::UnicodeUTF8) + << QApplication::translate("MainWindow", "no", 0, QApplication::UnicodeUTF8) + ); label_16->setText(QApplication::translate("MainWindow", "Track name:", 0, QApplication::UnicodeUTF8)); label_17->setText(QApplication::translate("MainWindow", "Language:", 0, QApplication::UnicodeUTF8)); label_18->setText(QApplication::translate("MainWindow", "\"Default track\" flag:", 0, QApplication::UnicodeUTF8)); @@ -1232,6 +1250,8 @@ public: browseTimecodes->setText(QApplication::translate("MainWindow", "Browse", 0, QApplication::UnicodeUTF8)); groupBox_9->setTitle(QApplication::translate("MainWindow", "Picture properties", 0, QApplication::UnicodeUTF8)); setAspectRatio->setText(QApplication::translate("MainWindow", "Set aspect ratio:", 0, QApplication::UnicodeUTF8)); + aspectRatio->setItemText(0, QString()); + setDisplayWidthHeight->setText(QApplication::translate("MainWindow", "Display width/height:", 0, QApplication::UnicodeUTF8)); label_25->setText(QApplication::translate("MainWindow", "x", 0, QApplication::UnicodeUTF8)); label_26->setText(QApplication::translate("MainWindow", "Stereoscopy:", 0, QApplication::UnicodeUTF8)); diff --git a/src/mmg-qt/forms/main_window.ui b/src/mmg-qt/forms/main_window.ui index debf9c602..71ffb33ad 100644 --- a/src/mmg-qt/forms/main_window.ui +++ b/src/mmg-qt/forms/main_window.ui @@ -82,9 +82,9 @@ 0 - -366 + 0 402 - 757 + 784 @@ -95,6 +95,27 @@ + + + Mux this: + + + + + + + + yes + + + + + no + + + + + Track name: @@ -104,10 +125,10 @@ - + - + Language: @@ -117,10 +138,10 @@ - + - + "Default track" flag: @@ -130,7 +151,7 @@ - + @@ -149,7 +170,7 @@ - + "Forced track" flag: @@ -159,7 +180,7 @@ - + @@ -173,7 +194,7 @@ - + Compression: @@ -183,7 +204,7 @@ - + @@ -202,7 +223,7 @@ - + Tags: @@ -212,7 +233,7 @@ - + @@ -383,6 +404,11 @@ true + + + + + 4/3 @@ -1280,6 +1306,7 @@ files tracks scrollArea + muxThis trackName trackLanguage defaultTrackFlag diff --git a/src/mmg-qt/main_window.cpp b/src/mmg-qt/main_window.cpp index 24f1d78d9..cd13aafac 100644 --- a/src/mmg-qt/main_window.cpp +++ b/src/mmg-qt/main_window.cpp @@ -50,7 +50,5 @@ void MainWindow::addFile(QString const &fileName, bool /*append*/) { FileIdentifier identifier{ this, fileName }; - if (!identifier.identify()) - return; - + mxinfo(boost::format("res; %1%\n") % identifier.identify()); } diff --git a/src/mmg-qt/source_file.cpp b/src/mmg-qt/source_file.cpp new file mode 100644 index 000000000..67b88abda --- /dev/null +++ b/src/mmg-qt/source_file.cpp @@ -0,0 +1,53 @@ +#include "common/common_pch.h" + +#include "common/qt.h" +#include "mmg-qt/source_file.h" + +SourceFile::SourceFile(QString const &fileName) + : m_fileName(fileName) + , m_type(FILE_TYPE_IS_UNKNOWN) + , m_appended(false) +{ +} + +SourceFile::~SourceFile() { +} + +bool +SourceFile::isValid() + const { + return !m_container.isEmpty(); +} + +void +SourceFile::setContainer(QString const &container) { + m_container = container; + m_type = container == "AAC" ? FILE_TYPE_AAC + : container == "AC3" ? FILE_TYPE_AC3 + : container == "AVC/h.264" ? FILE_TYPE_AVC_ES + : container == "AVI" ? FILE_TYPE_AVI + : container == "Dirac" ? FILE_TYPE_DIRAC + : container == "DTS" ? FILE_TYPE_DTS + : container == "FLAC" ? FILE_TYPE_FLAC + : container == "IVF (VP8)" ? FILE_TYPE_IVF + : container == "Matroska" ? FILE_TYPE_MATROSKA + : container == "MP2/MP3" ? FILE_TYPE_MP3 + : container == "MPEG video elementary stream" ? FILE_TYPE_MPEG_ES + : container == "MPEG program stream" ? FILE_TYPE_MPEG_PS + : container == "MPEG transport stream" ? FILE_TYPE_MPEG_TS + : container == "Ogg/OGM" ? FILE_TYPE_OGM + : container == "PGSSUP" ? FILE_TYPE_PGSSUP + : container == "QuickTime/MP4" ? FILE_TYPE_QTMP4 + : container == "RealMedia" ? FILE_TYPE_REAL + : container == "SRT subtitles" ? FILE_TYPE_SRT + : container == "SSA/ASS subtitles" ? FILE_TYPE_SSA + : container == "TrueHD" ? FILE_TYPE_TRUEHD + : container == "TTA" ? FILE_TYPE_TTA + : container == "USF subtitles" ? FILE_TYPE_USF + : container == "VC1 elementary stream" ? FILE_TYPE_VC1 + : container == "VobBtn" ? FILE_TYPE_VOBBTN + : container == "VobSub" ? FILE_TYPE_VOBSUB + : container == "WAV" ? FILE_TYPE_WAV + : container == "WAVPACK" ? FILE_TYPE_WAVPACK4 + : FILE_TYPE_IS_UNKNOWN; +} diff --git a/src/mmg-qt/source_file.h b/src/mmg-qt/source_file.h new file mode 100644 index 000000000..ed64d99fa --- /dev/null +++ b/src/mmg-qt/source_file.h @@ -0,0 +1,37 @@ +#ifndef MTX_MMGQT_SOURCE_FILE_H +#define MTX_MMGQT_SOURCE_FILE_H + +#include "common/common_pch.h" + +#include +#include +#include +#include + +#include "common/file_types.h" +#include "common/qt.h" + +#include "mmg-qt/track.h" + +class SourceFile; +typedef std::shared_ptr SourceFilePtr; + +class SourceFile: public QObject { + Q_OBJECT; +public: + QHash m_properties; + QString m_fileName, m_container; + QList m_tracks; + + file_type_e m_type; + bool m_appended; + +public: + explicit SourceFile(QString const &fileName); + virtual ~SourceFile(); + + virtual void setContainer(QString const &container); + virtual bool isValid() const; +}; + +#endif // MTX_MMGQT_SOURCE_FILE_H diff --git a/src/mmg-qt/track.cpp b/src/mmg-qt/track.cpp new file mode 100644 index 000000000..66da3f536 --- /dev/null +++ b/src/mmg-qt/track.cpp @@ -0,0 +1,121 @@ +#include "common/common_pch.h" + +#include "common/iso639.h" +#include "mmg-qt/source_file.h" +#include "mmg-qt/track.h" +#include "mmg-qt/util/settings.h" + +Track::Track(Track::Type type) + : m_file(nullptr) + , m_type(type) + , m_id(-1) + , m_muxThis(true) + , m_setAspectRatio(true) + , m_aacIsSBR(false) + , m_defaultTrackFlagWasSet(false) + , m_defaultTrackFlag(0) + , m_forcedTrackFlag(0) + , m_stereoscopy(0) + , m_cues(0) + , m_compression(CompDefault) +{ +} + +Track::~Track() { +} + +bool +Track::isType(Type type) + const { + return type == m_type; +} + +bool +Track::isAudio() + const { + return Audio == m_type; +} + +bool +Track::isVideo() + const { + return Video == m_type; +} + +bool +Track::isSubtitles() + const { + return Subtitles == m_type; +} + +bool +Track::isButtons() + const { + return Buttons == m_type; +} + +bool +Track::isChapters() + const { + return Chapters == m_type; +} + +bool +Track::isGlobalTags() + const { + return GlobalTags == m_type; +} + +bool +Track::isTags() + const { + return Tags == m_type; +} + +bool +Track::isAttachment() + const { + return Attachment == m_type; +} + +bool +Track::isAppended() + const { + return nullptr == m_file ? false : m_file->m_appended; +} + +void +Track::setDefaults() { + auto &settings = Settings::get(); + + if (isAudio() && settings.m_setAudioDelayFromFileName) + m_delay = extractAudioDelayFromFileName(); + + if (settings.m_disableAVCompression && (isVideo() || isAudio())) + m_compression = CompNone; + + m_forcedTrackFlag = m_properties[Q("forced_track")] == "1"; + m_defaultTrackFlagWasSet = m_properties[Q("default_track")] == "1"; + m_name = m_properties[Q("track_name")]; + m_cropping = m_properties[Q("cropping")]; + // m_stereoscopy = mapToStereoMode(m_properties[Q("stereo_mode")]; + + auto idx = map_to_iso639_2_code(to_utf8(m_language), true); + if (0 <= idx) + m_language = to_qs(iso639_languages[idx].iso639_2_code); + + QRegExp re_displayDimensions{"^(\\d+)x(\\d+)$"}; + if (-1 != re_displayDimensions.indexIn(m_properties[Q("display_dimensions")])) { + m_displayWidth = re_displayDimensions.cap(1); + m_displayHeight = re_displayDimensions.cap(1); + } +} + +QString +Track::extractAudioDelayFromFileName() + const { + QRegExp re{"delay\\s+(-?\\d+)", Qt::CaseInsensitive}; + if (-1 == re.indexIn(m_file->m_fileName)) + return ""; + return re.cap(1); +} diff --git a/src/mmg-qt/track.h b/src/mmg-qt/track.h new file mode 100644 index 000000000..5bae4fd71 --- /dev/null +++ b/src/mmg-qt/track.h @@ -0,0 +1,68 @@ +#ifndef MTX_MMGQT_TRACK_H +#define MTX_MMGQT_TRACK_H + +#include "common/common_pch.h" + +#include +#include +#include + +#include "common/qt.h" + +class SourceFile; + +class Track; +typedef std::shared_ptr TrackPtr; + +class Track: public QObject { + Q_OBJECT; +public: + enum Type { + Audio, + Video, + Subtitles, + Buttons, + Chapters, + GlobalTags, + Tags, + Attachment, + }; + + enum Compression { + CompDefault, + CompNone, + CompZlib, + }; + + QHash m_properties; + + SourceFile *m_file; + + Type m_type; + int64_t m_id; + + bool m_muxThis, m_setAspectRatio, m_aacIsSBR, m_defaultTrackFlagWasSet; + QString m_name, m_codec, m_language, m_tags, m_delay, m_strechBy, m_defaultDuration, m_timecodes, m_aspectRatio, m_displayWidth, m_displayHeight, m_cropping, m_characterSet, m_userDefinedOptions; + unsigned int m_defaultTrackFlag, m_forcedTrackFlag, m_stereoscopy, m_cues; + Compression m_compression; + +public: + explicit Track(Type type); + virtual ~Track(); + + virtual bool isType(Type type) const; + virtual bool isAudio() const; + virtual bool isVideo() const; + virtual bool isSubtitles() const; + virtual bool isButtons() const; + virtual bool isChapters() const; + virtual bool isGlobalTags() const; + virtual bool isTags() const; + virtual bool isAttachment() const; + virtual bool isAppended() const; + + virtual void setDefaults(); + virtual QString extractAudioDelayFromFileName() const; +}; + +#endif // MTX_MMGQT_TRACK_H diff --git a/src/mmg-qt/util/file_identifier.cpp b/src/mmg-qt/util/file_identifier.cpp index 62839d43a..80d0db8a8 100644 --- a/src/mmg-qt/util/file_identifier.cpp +++ b/src/mmg-qt/util/file_identifier.cpp @@ -1,6 +1,7 @@ #include "common/common_pch.h" #include "common/qt.h" +#include "common/strings/editing.h" #include "mmg-qt/util/file_identifier.h" #include "mmg-qt/util/process.h" #include "mmg-qt/util/settings.h" @@ -31,10 +32,8 @@ FileIdentifier::identify() { auto exitCode = process->process().exitCode(); m_output = process->output(); - mxinfo(boost::format("oh yeah, code %2%: %1%\n") % to_utf8(m_output.join(":::")) % exitCode); - if (0 == exitCode) - return true; + return parseOutput(); if (3 == exitCode) { auto pos = m_output.isEmpty() ? -1 : m_output[0].indexOf("container:"); @@ -72,3 +71,109 @@ FileIdentifier::output() const { return m_output; } + +SourceFilePtr const & +FileIdentifier::file() + const { + return m_file; +} + +bool +FileIdentifier::parseOutput() { + m_file = std::make_shared(m_fileName); + + for (auto &line : m_output) { + if (line.startsWith("File")) + parseContainerLine(line); + + else if (line.startsWith("Track")) + parseTrackLine(line); + + else if (line.startsWith("Attachment")) + parseAttachmentLine(line); + + else if (line.startsWith("Chapters")) + parseChaptersLine(line); + + else if (line.startsWith("Global tags")) + parseGlobalTagsLine(line); + + else if (line.startsWith("Track")) + parseTrackLine(line); + } + + return m_file->isValid(); +} + +// Attachment ID 1: type 'cue', size 1844 bytes, description 'dummy', file name 'cuewithtags2.cue' +void +FileIdentifier::parseAttachmentLine(QString const &line) { +} + +// Chapters: 27 entries +void +FileIdentifier::parseChaptersLine(QString const &line) { +} + +// File 'complex.mkv': container: Matroska [duration:106752000000 segment_uid:00000000000000000000000000000000] +void +FileIdentifier::parseContainerLine(QString const &line) { + QRegExp re{"^File\\s.*container:\\s+([^\\[]+)"}; + + if (-1 == re.indexIn(line)) + return; + + m_file->setContainer(re.cap(1)); + m_file->m_properties = parseProperties(line); +} + +// Global tags: 3 entries +void +FileIdentifier::parseGlobalTagsLine(QString const &line) { +} + +void +FileIdentifier::parseTagsLine(QString const &line) { +} + +// Track ID 0: video (V_MS/VFW/FOURCC, DIV3) [number:1 ...] +// Track ID 7: audio (A_PCM/INT/LIT) [number:8 uid:289972206 codec_id:A_PCM/INT/LIT codec_private_length:0 language:und default_track:0 forced_track:0 enabled_track:1 default_duration:31250000 audio_sampling_frequency:48000 audio_channels:2] +// Track ID 8: subtitles (S_TEXT/UTF8) [number:9 ...] +void +FileIdentifier::parseTrackLine(QString const &line) { + QRegExp re{"Track\\s+ID\\s+(\\d+):\\s+(audio|video|subtitles|buttons)\\s+\\(([^\\)]+)\\)", Qt::CaseInsensitive}; + if (-1 == re.indexIn(line)) + return; + + auto type = re.cap(2) == "audio" ? Track::Audio + : re.cap(2) == "video" ? Track::Video + : re.cap(2) == "subtitles" ? Track::Subtitles + : Track::Buttons; + auto track = std::make_shared(type); + track->m_file = m_file.get(); + track->m_id = re.cap(1).toLongLong(); + track->m_codec = re.cap(3); + track->m_properties = parseProperties(line); + + m_file->m_tracks << track; + + track->setDefaults(); +} + +QHash +FileIdentifier::parseProperties(QString const &line) + const { + QHash properties; + + QRegExp re{"\\[(.+)\\]"}; + if (-1 == re.indexIn(line)) + return properties; + + for (auto &pair : re.cap(1).split(QRegExp{"\\s+"}, QString::SkipEmptyParts)) { + QRegExp re{"(.+):(.+)"}; + if (-1 != re.indexIn(pair)) + properties[to_qs(unescape(to_utf8(re.cap(1))))] = to_qs(unescape(to_utf8(re.cap(2)))); + } + + return properties; +} diff --git a/src/mmg-qt/util/file_identifier.h b/src/mmg-qt/util/file_identifier.h index a04917f0a..519002610 100644 --- a/src/mmg-qt/util/file_identifier.h +++ b/src/mmg-qt/util/file_identifier.h @@ -6,6 +6,8 @@ #include #include +#include "mmg-qt/source_file.h" + class FileIdentifier: public QObject { Q_OBJECT; @@ -14,18 +16,29 @@ private: int m_exitCode; QStringList m_output; QString m_fileName; + SourceFilePtr m_file; public: FileIdentifier(QWidget *parent = nullptr, QString const &fileName = QString{}); virtual ~FileIdentifier(); virtual bool identify(); + virtual bool parseOutput(); + virtual QHash parseProperties(QString const &line) const; + virtual void parseAttachmentLine(QString const &line); + virtual void parseChaptersLine(QString const &line); + virtual void parseContainerLine(QString const &line); + virtual void parseGlobalTagsLine(QString const &line); + virtual void parseTagsLine(QString const &line); + virtual void parseTrackLine(QString const &line); virtual QString const &fileName() const; virtual void setFileName(QString const &fileName); virtual int exitCode() const; virtual QStringList const &output() const; + + virtual SourceFilePtr const &file() const; }; #endif // MTX_MMGQT_FILE_IDENTIFIER_H diff --git a/src/mmg-qt/util/settings.cpp b/src/mmg-qt/util/settings.cpp index cfb2cd5cd..a6fcdd155 100644 --- a/src/mmg-qt/util/settings.cpp +++ b/src/mmg-qt/util/settings.cpp @@ -7,6 +7,8 @@ Settings Settings::s_settings; Settings::Settings() : m_mkvmergeExe("mkvmerge") , m_priority(priority_normal) + , m_setAudioDelayFromFileName(true) + , m_disableAVCompression(true) { } diff --git a/src/mmg-qt/util/settings.h b/src/mmg-qt/util/settings.h index ee5b2e434..4b5dae35e 100644 --- a/src/mmg-qt/util/settings.h +++ b/src/mmg-qt/util/settings.h @@ -20,6 +20,7 @@ public: QString m_mkvmergeExe; process_priority_e m_priority; QDir m_lastOpenDir; + bool m_setAudioDelayFromFileName, m_disableAVCompression; public: Settings();