4 #include <libavformat/avformat.h>
5 #include <libavcodec/avcodec.h>
78 std::chrono::milliseconds length = 0ms;
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())
127 length = duration_cast<std::chrono::milliseconds>(av_duration(p_context->duration));
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)
185 std::chrono::milliseconds rv =
186 duration_cast<std::chrono::milliseconds>(av_duration(p_context->duration));
188 avformat_close_input(&p_context);
202 QString *title, QString *genre)
204 if (artist->isEmpty())
205 artist->append(
"Unknown Artist");
207 if (album->isEmpty())
208 album->append(
"Unknown Album");
210 if (title->isEmpty())
211 title->append(
"Unknown Title");
213 if (genre->isEmpty())
214 genre->append(
"Unknown Genre");