12 #include <libavformat/avformat.h> 13 #include <libavcodec/avcodec.h> 72 QString title, artist, album, genre;
73 int year = 0, tracknum = 0, length = 0;
74 bool compilation =
false;
76 AVFormatContext* p_context =
nullptr;
77 AVInputFormat* p_inputformat =
nullptr;
79 QByteArray local8bit =
filename.toLocal8Bit();
80 if ((avformat_open_input(&p_context, local8bit.constData(),
81 p_inputformat,
nullptr) < 0))
86 if (avformat_find_stream_info(p_context,
nullptr) < 0)
92 AVDictionaryEntry *tag = av_dict_get(p_context->metadata,
"\0",
nullptr,
93 AV_METADATA_IGNORE_SUFFIX);
94 while (tag !=
nullptr)
96 LOG(VB_GENERAL, LOG_DEBUG, QString(
"Tag: %1 Value: %2")
97 .arg(tag->key) .arg(QString::fromUtf8(tag->value)));
98 tag = av_dict_get(p_context->metadata,
"\0", tag,
99 AV_METADATA_IGNORE_SUFFIX);
115 if (artist.isEmpty())
128 compilation ? artist :
"",
129 album, title, genre, year,
132 retdata->setCompilation(compilation);
134 avformat_close_input(&p_context);
148 AVDictionaryEntry *tag = av_dict_get(context->metadata, tagname,
nullptr, 0);
153 value = QString::fromUtf8(tag->value);
166 AVFormatContext* p_context =
nullptr;
167 AVInputFormat* p_inputformat =
nullptr;
170 QByteArray local8bit =
filename.toLocal8Bit();
171 if ((avformat_open_input(&p_context, local8bit.constData(),
172 p_inputformat,
nullptr) < 0))
177 if (avformat_find_stream_info(p_context,
nullptr) < 0)
182 avformat_close_input(&p_context);
198 av_estimate_timings(pContext, 0);
200 return (pContext->duration / AV_TIME_BASE) * 1000;
212 QString *title, QString *genre)
214 if (artist->isEmpty())
215 artist->append(
"Unknown Artist");
217 if (album->isEmpty())
218 album->append(
"Unknown Album");
220 if (title->isEmpty())
221 title->append(
"Unknown Title");
223 if (genre->isEmpty())
224 genre->append(
"Unknown Genre");
#define LOG(_MASK_, _LEVEL_, _STRING_)