3#include <libavformat/avformat.h>
4#include <libavcodec/avcodec.h>
26 QString compilation_artist;
33 AVFormatContext* p_context =
nullptr;
34 AVInputFormat* p_inputformat =
nullptr;
36 QByteArray local8bit =
filename.toLocal8Bit();
37 if ((avformat_open_input(&p_context, local8bit.constData(),
38 p_inputformat,
nullptr) < 0))
43 if (avformat_find_stream_info(p_context,
nullptr) < 0)
46 AVDictionaryEntry *tag = av_dict_get(p_context->metadata,
"title",
nullptr, 0);
55 tag = av_dict_get(p_context->metadata,
"author",
nullptr, 0);
60 tag = av_dict_get(p_context->metadata,
"album",
nullptr, 0);
64 tag = av_dict_get(p_context->metadata,
"genre",
nullptr, 0);
68 tag = av_dict_get(p_context->metadata,
"year",
nullptr, 0);
70 year = atoi(tag->value);
72 tag = av_dict_get(p_context->metadata,
"tracknum",
nullptr, 0);
74 tracknum = atoi(tag->value);
80 title, genre, year, tracknum, length);
82 retdata->determineIfCompilation();
84 avformat_close_input(&p_context);
97 AVFormatContext* p_context =
nullptr;
98 AVInputFormat* p_inputformat =
nullptr;
101 QByteArray local8bit =
filename.toLocal8Bit();
102 if ((avformat_open_input(&p_context, local8bit.constData(),
103 p_inputformat,
nullptr) < 0))
108 if (avformat_find_stream_info(p_context,
nullptr) < 0)
113 avformat_close_input(&p_context);
129 auto time = av_duration(pContext->duration);
130 return duration_cast<std::chrono::milliseconds>(time);