Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/LAVFilters.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2013-12-16 17:10:36 +0400
committerHendrik Leppkes <h.leppkes@gmail.com>2013-12-16 17:10:36 +0400
commitbdd028f8db704daf3359ce9fb35eb1da7f8552d0 (patch)
tree283172aa4cffedb61cf69d2e3c9a5003f195c25a /demuxer/Demuxers
parent210f2d6a4a99708be3b0809c5ca122a0dc34557f (diff)
Add support for parsing embeded Cue Sheets
Supports reading title/performer and tracks for chapters.
Diffstat (limited to 'demuxer/Demuxers')
-rw-r--r--demuxer/Demuxers/LAVFDemuxer.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/demuxer/Demuxers/LAVFDemuxer.cpp b/demuxer/Demuxers/LAVFDemuxer.cpp
index f8104a3a..cfee3928 100644
--- a/demuxer/Demuxers/LAVFDemuxer.cpp
+++ b/demuxer/Demuxers/LAVFDemuxer.cpp
@@ -37,6 +37,8 @@ typedef struct CodecMime{
#include "libavformat/mpegts.h"
#include "libavformat/matroska.h"
#include "libavutil/avstring.h"
+
+AVChapter *avpriv_new_chapter(AVFormatContext *s, int id, AVRational time_base, int64_t start, int64_t end, const char *title);
}
#ifdef DEBUG
@@ -47,6 +49,7 @@ extern "C" {
#endif
#include "BDDemuxer.h"
+#include "CueSheet.h"
#define AVFORMAT_OPEN_TIMEOUT 20
@@ -502,6 +505,27 @@ STDMETHODIMP CLAVFDemuxer::InitAVFormat(LPCOLESTR pszFileName, BOOL bForce)
}
}
+ if (AVDictionaryEntry *cue = av_dict_get(m_avFormat->metadata, "CUESHEET", nullptr, 0)) {
+ CCueSheet cueSheet;
+ if (SUCCEEDED(cueSheet.Parse(cue->value))) {
+ // Metadata
+ if (!cueSheet.m_Title.empty() && !av_dict_get(m_avFormat->metadata, "title", nullptr, 0))
+ av_dict_set(&m_avFormat->metadata, "title", cueSheet.m_Title.c_str(), 0);
+ if (!cueSheet.m_Performer.empty() && !av_dict_get(m_avFormat->metadata, "artist", nullptr, 0))
+ av_dict_set(&m_avFormat->metadata, "artist", cueSheet.m_Performer.c_str(), 0);
+ // Free old chapters
+ while (m_avFormat->nb_chapters--) {
+ av_dict_free(&m_avFormat->chapters[m_avFormat->nb_chapters]->metadata);
+ av_freep(&m_avFormat->chapters[m_avFormat->nb_chapters]);
+ }
+ av_freep(&m_avFormat->chapters);
+ m_avFormat->nb_chapters = 0;
+ for (CCueSheet::Track track : cueSheet.m_Tracks) {
+ avpriv_new_chapter(m_avFormat, track.index, AVRational{1, DSHOW_TIME_BASE}, track.Time, track.Time, track.Title.c_str());
+ }
+ }
+ }
+
CHECK_HR(hr = CreateStreams());
return S_OK;