12 #include <libavformat/avformat.h>
13 #include <libavcodec/avcodec.h>
79 bool compilation =
false;
81 AVFormatContext* p_context =
nullptr;
82 AVInputFormat* p_inputformat =
nullptr;
84 QByteArray local8bit =
filename.toLocal8Bit();
85 if ((avformat_open_input(&p_context, local8bit.constData(),
86 p_inputformat,
nullptr) < 0))
91 if (avformat_find_stream_info(p_context,
nullptr) < 0)
97 AVDictionaryEntry *tag = av_dict_get(p_context->metadata,
"\0",
nullptr,
98 AV_METADATA_IGNORE_SUFFIX);
99 while (tag !=
nullptr)
101 LOG(VB_GENERAL, LOG_DEBUG, QString(
"Tag: %1 Value: %2")
102 .
arg(tag->key) .arg(QString::fromUtf8(tag->value)));
103 tag = av_dict_get(p_context->metadata,
"\0", tag,
104 AV_METADATA_IGNORE_SUFFIX);
120 if (artist.isEmpty())
133 compilation ? artist :
"",
134 album,
title, genre, year,
137 retdata->setCompilation(compilation);
139 avformat_close_input(&p_context);
153 AVDictionaryEntry *tag = av_dict_get(context->metadata, tagname,
nullptr, 0);
158 value = QString::fromUtf8(tag->value);
171 AVFormatContext* p_context =
nullptr;
172 AVInputFormat* p_inputformat =
nullptr;
175 QByteArray local8bit =
filename.toLocal8Bit();
176 if ((avformat_open_input(&p_context, local8bit.constData(),
177 p_inputformat,
nullptr) < 0))
182 if (avformat_find_stream_info(p_context,
nullptr) < 0)
187 avformat_close_input(&p_context);
203 av_estimate_timings(pContext, 0);
205 return (pContext->duration / AV_TIME_BASE) * 1000;
217 QString *
title, QString *genre)
219 if (artist->isEmpty())
220 artist->append(
"Unknown Artist");
222 if (album->isEmpty())
223 album->append(
"Unknown Album");
225 if (
title->isEmpty())
226 title->append(
"Unknown Title");
228 if (genre->isEmpty())
229 genre->append(
"Unknown Genre");