mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-29 06:15:24 +00:00
File identification & track/file parsing
This commit is contained in:
parent
dd50fddb2f
commit
f1ae96bcb6
@ -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));
|
||||
|
@ -82,9 +82,9 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>-366</y>
|
||||
<y>0</y>
|
||||
<width>402</width>
|
||||
<height>757</height>
|
||||
<height>784</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
@ -95,6 +95,27 @@
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_35">
|
||||
<property name="text">
|
||||
<string>Mux this:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="muxThis">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>yes</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>no</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_16">
|
||||
<property name="text">
|
||||
<string>Track name:</string>
|
||||
@ -104,10 +125,10 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="trackName"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="text">
|
||||
<string>Language:</string>
|
||||
@ -117,10 +138,10 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="trackLanguage"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="text">
|
||||
<string>"Default track" flag:</string>
|
||||
@ -130,7 +151,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="defaultTrackFlag">
|
||||
<item>
|
||||
<property name="text">
|
||||
@ -149,7 +170,7 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_19">
|
||||
<property name="text">
|
||||
<string>"Forced track" flag:</string>
|
||||
@ -159,7 +180,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="forcedTrackFlag">
|
||||
<item>
|
||||
<property name="text">
|
||||
@ -173,7 +194,7 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_31">
|
||||
<property name="text">
|
||||
<string>Compression:</string>
|
||||
@ -183,7 +204,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<item row="5" column="1">
|
||||
<widget class="QComboBox" name="compression">
|
||||
<item>
|
||||
<property name="text">
|
||||
@ -202,7 +223,7 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_20">
|
||||
<property name="text">
|
||||
<string>Tags:</string>
|
||||
@ -212,7 +233,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="6" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="trackTacks"/>
|
||||
@ -383,6 +404,11 @@
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">4/3</string>
|
||||
@ -1280,6 +1306,7 @@
|
||||
<tabstop>files</tabstop>
|
||||
<tabstop>tracks</tabstop>
|
||||
<tabstop>scrollArea</tabstop>
|
||||
<tabstop>muxThis</tabstop>
|
||||
<tabstop>trackName</tabstop>
|
||||
<tabstop>trackLanguage</tabstop>
|
||||
<tabstop>defaultTrackFlag</tabstop>
|
||||
|
@ -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());
|
||||
}
|
||||
|
53
src/mmg-qt/source_file.cpp
Normal file
53
src/mmg-qt/source_file.cpp
Normal file
@ -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;
|
||||
}
|
37
src/mmg-qt/source_file.h
Normal file
37
src/mmg-qt/source_file.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef MTX_MMGQT_SOURCE_FILE_H
|
||||
#define MTX_MMGQT_SOURCE_FILE_H
|
||||
|
||||
#include "common/common_pch.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include "common/file_types.h"
|
||||
#include "common/qt.h"
|
||||
|
||||
#include "mmg-qt/track.h"
|
||||
|
||||
class SourceFile;
|
||||
typedef std::shared_ptr<SourceFile> SourceFilePtr;
|
||||
|
||||
class SourceFile: public QObject {
|
||||
Q_OBJECT;
|
||||
public:
|
||||
QHash<QString, QString> m_properties;
|
||||
QString m_fileName, m_container;
|
||||
QList<TrackPtr> 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
|
121
src/mmg-qt/track.cpp
Normal file
121
src/mmg-qt/track.cpp
Normal file
@ -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);
|
||||
}
|
68
src/mmg-qt/track.h
Normal file
68
src/mmg-qt/track.h
Normal file
@ -0,0 +1,68 @@
|
||||
#ifndef MTX_MMGQT_TRACK_H
|
||||
#define MTX_MMGQT_TRACK_H
|
||||
|
||||
#include "common/common_pch.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include "common/qt.h"
|
||||
|
||||
class SourceFile;
|
||||
|
||||
class Track;
|
||||
typedef std::shared_ptr<Track> TrackPtr;
|
||||
|
||||
class Track: public QObject {
|
||||
Q_OBJECT;
|
||||
public:
|
||||
enum Type {
|
||||
Audio,
|
||||
Video,
|
||||
Subtitles,
|
||||
Buttons,
|
||||
Chapters,
|
||||
GlobalTags,
|
||||
Tags,
|
||||
Attachment,
|
||||
};
|
||||
|
||||
enum Compression {
|
||||
CompDefault,
|
||||
CompNone,
|
||||
CompZlib,
|
||||
};
|
||||
|
||||
QHash<QString, QString> 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
|
@ -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<SourceFile>(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<Track>(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<QString, QString>
|
||||
FileIdentifier::parseProperties(QString const &line)
|
||||
const {
|
||||
QHash<QString, QString> 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;
|
||||
}
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include <QStringList>
|
||||
#include <QWidget>
|
||||
|
||||
#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<QString, QString> 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
|
||||
|
@ -7,6 +7,8 @@ Settings Settings::s_settings;
|
||||
Settings::Settings()
|
||||
: m_mkvmergeExe("mkvmerge")
|
||||
, m_priority(priority_normal)
|
||||
, m_setAudioDelayFromFileName(true)
|
||||
, m_disableAVCompression(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ public:
|
||||
QString m_mkvmergeExe;
|
||||
process_priority_e m_priority;
|
||||
QDir m_lastOpenDir;
|
||||
bool m_setAudioDelayFromFileName, m_disableAVCompression;
|
||||
|
||||
public:
|
||||
Settings();
|
||||
|
Loading…
Reference in New Issue
Block a user