[tracker-miners/sam/libav-testing] tracker-extract-libav: Fix missing audio info
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker-miners/sam/libav-testing] tracker-extract-libav: Fix missing audio info
- Date: Wed, 31 Aug 2022 09:48:39 +0000 (UTC)
commit 5afd3ea0d7860f59fee36d2e99fe24095cceb5e8
Author: Sam Thursfield <sam thursfield codethink co uk>
Date: Wed Aug 31 11:43:49 2022 +0200
tracker-extract-libav: Fix missing audio info
The extractor tests were failing with the ffmpeg/libav backend as
nie:title wasn't extracted from Vorbis files. The issue is the TITLE
tag is part of the audio stream metadata, but the extractor only looked
on the container metadata.
Resolved, with a separate codepath for music vs video.
src/tracker-extract/tracker-extract-libav.c | 84 ++++++++++++++++++-----------
1 file changed, 54 insertions(+), 30 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-libav.c b/src/tracker-extract/tracker-extract-libav.c
index 61db416e5..085c780e2 100644
--- a/src/tracker-extract/tracker-extract-libav.c
+++ b/src/tracker-extract/tracker-extract-libav.c
@@ -54,12 +54,14 @@ extract_audio_info(TrackerResource *metadata,
}
static void
-extract_video_info(TrackerResource *metadata,
+extract_video_info(gchar *uri,
+ TrackerResource *metadata,
AVFormatContext *format,
AVStream *video_stream)
{
g_autofree char *content_created = NULL;
AVDictionaryEntry *tag = NULL;
+ const char *title = NULL;
tracker_resource_add_uri(metadata, "rdf:type", "nmm:Video");
@@ -108,16 +110,40 @@ extract_video_info(TrackerResource *metadata,
tracker_resource_set_string (metadata, "nie:contentCreated", content_created);
}
}
+
+ if ((tag = av_dict_get (format->metadata, "comment", NULL, 0))) {
+ tracker_resource_set_string (metadata, "nie:comment", tag->value);
+ }
+
+ if ((tag = av_dict_get (format->metadata, "copyright", NULL, 0))) {
+ tracker_resource_set_string (metadata, "nie:copyright", tag->value);
+ }
+
+ if ((tag = av_dict_get (format->metadata, "description", NULL, 0))) {
+ tracker_resource_set_string (metadata, "nie:description", tag->value);
+ }
+
+ if ((tag = av_dict_get (format->metadata, "genre", NULL, 0))) {
+ tracker_resource_set_string (metadata, "nfo:genre", tag->value);
+ }
+
+ if ((tag = av_dict_get (format->metadata, "title", NULL, 0))) {
+ title = tag->value;
+ }
+
+ tracker_guarantee_resource_title_from_file (metadata, "nie:title", title, uri, NULL);
}
static void
-extract_music_piece_info(TrackerResource *metadata,
+extract_music_piece_info(const gchar *uri,
+ TrackerResource *metadata,
AVFormatContext *format,
AVStream *audio_stream)
{
g_autoptr(TrackerResource) album_artist = NULL, artist = NULL, performer = NULL;
- char *album_artist_name = NULL;
- char *album_title = NULL;
+ const char *album_artist_name = NULL;
+ const char *album_title = NULL;
+ const char *title = NULL;
g_autofree char *content_created = NULL;
AVDictionaryEntry *tag = NULL;
@@ -188,6 +214,28 @@ extract_music_piece_info(TrackerResource *metadata,
tracker_resource_set_relation (metadata, "nmm:musicAlbumDisc", album_disc);
tracker_resource_set_relation (metadata, "nmm:musicAlbum",
tracker_resource_get_first_relation (album_disc, "nmm:albumDiscAlbum"));
}
+
+ if ((tag = find_tag (format, audio_stream, "comment"))) {
+ tracker_resource_set_string (metadata, "nie:comment", tag->value);
+ }
+
+ if ((tag = find_tag (format, audio_stream, "copyright"))) {
+ tracker_resource_set_string (metadata, "nie:copyright", tag->value);
+ }
+
+ if ((tag = find_tag (format, audio_stream, "description"))) {
+ tracker_resource_set_string (metadata, "nie:description", tag->value);
+ }
+
+ if ((tag = find_tag (format, audio_stream, "genre"))) {
+ tracker_resource_set_string (metadata, "nfo:genre", tag->value);
+ }
+
+ if ((tag = find_tag (format, audio_stream, "title"))) {
+ title = tag->value;
+ }
+
+ tracker_guarantee_resource_title_from_file (metadata, "nie:title", title, uri, NULL);
}
G_MODULE_EXPORT gboolean
@@ -203,8 +251,6 @@ tracker_extract_get_metadata (TrackerExtractInfo *info,
AVStream *video_stream = NULL;
int audio_stream_index;
int video_stream_index;
- AVDictionaryEntry *tag = NULL;
- const char *title = NULL;
file = tracker_extract_info_get_file (info);
@@ -245,37 +291,15 @@ tracker_extract_get_metadata (TrackerExtractInfo *info,
}
if (video_stream && !(video_stream->disposition & AV_DISPOSITION_ATTACHED_PIC)) {
- extract_video_info (metadata, format, video_stream);
+ extract_video_info (uri, metadata, format, video_stream);
} else if (audio_stream) {
- extract_music_piece_info (metadata, format, audio_stream);
+ extract_music_piece_info (uri, metadata, format, audio_stream);
}
if (format->bit_rate > 0) {
tracker_resource_set_int64 (metadata, "nfo:averageBitrate", format->bit_rate);
}
- if ((tag = av_dict_get (format->metadata, "comment", NULL, 0))) {
- tracker_resource_set_string (metadata, "nie:comment", tag->value);
- }
-
- if ((tag = av_dict_get (format->metadata, "copyright", NULL, 0))) {
- tracker_resource_set_string (metadata, "nie:copyright", tag->value);
- }
-
- if ((tag = av_dict_get (format->metadata, "description", NULL, 0))) {
- tracker_resource_set_string (metadata, "nie:description", tag->value);
- }
-
- if ((tag = av_dict_get (format->metadata, "genre", NULL, 0))) {
- tracker_resource_set_string (metadata, "nfo:genre", tag->value);
- }
-
- if ((tag = av_dict_get (format->metadata, "title", NULL, 0))) {
- title = tag->value;
- }
-
- tracker_guarantee_resource_title_from_file (metadata, "nie:title", title, uri, NULL);
-
g_free (uri);
avformat_close_input (&format);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]