mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 07:51:19 +02:00
driver/audiodec/ffmpegdec.cpp: fix ogg; get metadata also from streams,
ie some ogg dont have global metadata
This commit is contained in:
@@ -139,7 +139,7 @@ bool CFfmpegDec::Init(void *_in, const CFile::FileType ft)
|
|||||||
|
|
||||||
switch (ft) {
|
switch (ft) {
|
||||||
case CFile::FILE_OGG:
|
case CFile::FILE_OGG:
|
||||||
input_format = av_find_input_format("vorbis");
|
input_format = av_find_input_format("ogg");
|
||||||
break;
|
break;
|
||||||
case CFile::FILE_MP3:
|
case CFile::FILE_MP3:
|
||||||
input_format = av_find_input_format("mp3");
|
input_format = av_find_input_format("mp3");
|
||||||
@@ -383,42 +383,23 @@ bool CFfmpegDec::SetMetaData(FILE *_in, CFile::FileType ft, CAudioMetaData* m)
|
|||||||
if (!Init(_in, ft))
|
if (!Init(_in, ft))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!is_stream) {
|
|
||||||
AVDictionaryEntry *tag = NULL;
|
|
||||||
while ((tag = av_dict_get(avc->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
|
|
||||||
if(!strcasecmp(tag->key,"Title")) {
|
|
||||||
title = isUTF8(tag->value) ? tag->value : convertLatin1UTF8(tag->value);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(!strcasecmp(tag->key,"Artist")) {
|
|
||||||
artist = isUTF8(tag->value) ? tag->value : convertLatin1UTF8(tag->value);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(!strcasecmp(tag->key,"Year")) {
|
|
||||||
date = isUTF8(tag->value) ? tag->value : convertLatin1UTF8(tag->value);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(!strcasecmp(tag->key,"Album")) {
|
|
||||||
album = isUTF8(tag->value) ? tag->value : convertLatin1UTF8(tag->value);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(!strcasecmp(tag->key,"Genre")) {
|
|
||||||
genre = isUTF8(tag->value) ? tag->value : convertLatin1UTF8(tag->value);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
if (avformat_find_stream_info(avc, NULL)) {
|
int ret = avformat_find_stream_info(avc, NULL);
|
||||||
|
if (ret < 0) {
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
DeInit();
|
DeInit();
|
||||||
|
printf("avformat_find_stream_info error %d\n", ret);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
if (!is_stream) {
|
||||||
|
GetMeta(avc->metadata);
|
||||||
|
for(unsigned int i = 0; i < avc->nb_streams; i++)
|
||||||
|
GetMeta(avc->streams[i]->metadata);
|
||||||
|
}
|
||||||
|
|
||||||
// fseek((FILE *) in, 0, SEEK_SET);
|
// fseek((FILE *) in, 0, SEEK_SET);
|
||||||
// av_dump_format(avc, 0, "", 0);
|
av_dump_format(avc, 0, "", 0);
|
||||||
|
|
||||||
codec = NULL;
|
codec = NULL;
|
||||||
best_stream = av_find_best_stream(avc, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
|
best_stream = av_find_best_stream(avc, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
|
||||||
@@ -477,3 +458,35 @@ bool CFfmpegDec::SetMetaData(FILE *_in, CFile::FileType ft, CAudioMetaData* m)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CFfmpegDec::GetMeta(AVDictionary * metadata)
|
||||||
|
{
|
||||||
|
AVDictionaryEntry *tag = NULL;
|
||||||
|
while ((tag = av_dict_get(metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
|
||||||
|
if(!strcasecmp(tag->key,"Title")) {
|
||||||
|
if (title.empty())
|
||||||
|
title = isUTF8(tag->value) ? tag->value : convertLatin1UTF8(tag->value);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(!strcasecmp(tag->key,"Artist")) {
|
||||||
|
if (artist.empty())
|
||||||
|
artist = isUTF8(tag->value) ? tag->value : convertLatin1UTF8(tag->value);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(!strcasecmp(tag->key,"Year")) {
|
||||||
|
if (date.empty())
|
||||||
|
date = isUTF8(tag->value) ? tag->value : convertLatin1UTF8(tag->value);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(!strcasecmp(tag->key,"Album")) {
|
||||||
|
if (album.empty())
|
||||||
|
album = isUTF8(tag->value) ? tag->value : convertLatin1UTF8(tag->value);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(!strcasecmp(tag->key,"Genre")) {
|
||||||
|
if (genre.empty())
|
||||||
|
genre = isUTF8(tag->value) ? tag->value : convertLatin1UTF8(tag->value);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -59,6 +59,7 @@ private:
|
|||||||
void *in;
|
void *in;
|
||||||
bool Init(void *_in, const CFile::FileType ft);
|
bool Init(void *_in, const CFile::FileType ft);
|
||||||
void DeInit(void);
|
void DeInit(void);
|
||||||
|
void GetMeta(AVDictionary * metadata);
|
||||||
|
|
||||||
std::string title;
|
std::string title;
|
||||||
std::string artist;
|
std::string artist;
|
||||||
|
Reference in New Issue
Block a user