[tracker-miners: 1/3] tracker-extract: ignore subtrack titles for videos
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker-miners: 1/3] tracker-extract: ignore subtrack titles for videos
- Date: Fri, 4 Mar 2022 18:14:39 +0000 (UTC)
commit 47b13910d6075bef7e23dc458399d5a1f493ab21
Author: Ignacy KuchciĆski <ignacykuchcinski gmail com>
Date: Tue Feb 22 10:13:45 2022 +0100
tracker-extract: ignore subtrack titles for videos
Currently, the resulting nie:title includes titles from the individual
tracks due to both gstreamer not differentiating between
global/container tags and track tags until introducing
gst_discoverer_container_info_get_tags() as new API and tracker-extract
gstreamer backend looping through available tracks and collecting all
tags it could find.
As a result, in cases where there is no title tag in the container, but
there are some title tags in subtitle or audio tracks, they are included
in the nie:title and prevent the file name based fallback title in grilo
and cause the video to show up with nonsense titles in totem.
To fix this, replace gst_discoverer_info_get_tags() with the new API,
and ignore title tags from subtracks if the file is a video.
Fixes https://gitlab.gnome.org/GNOME/tracker-miners/-/issues/202
config-miners.h.meson.in | 3 +++
meson.build | 1 +
src/tracker-extract/tracker-extract-gstreamer.c | 21 +++++++++++++++++++--
3 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/config-miners.h.meson.in b/config-miners.h.meson.in
index 863b50631..402d432b9 100644
--- a/config-miners.h.meson.in
+++ b/config-miners.h.meson.in
@@ -32,6 +32,9 @@
/* Define if we have GStreamer */
#mesondefine HAVE_GSTREAMER
+/* Define if we have Gstreamer version 1.20.0 or up */
+#mesondefine HAVE_GSTREAMER_1_20
+
/* Define if we have HAL */
#mesondefine HAVE_HAL
diff --git a/meson.build b/meson.build
index 9432f19db..1270e2512 100644
--- a/meson.build
+++ b/meson.build
@@ -368,6 +368,7 @@ conf.set('GIO_SUPPORTS_CREATION_TIME', glib.version().version_compare('>=2.70.0'
conf.set('HAVE_ENCA', charset_library_name == 'enca')
conf.set('HAVE_EXEMPI', exempi.found())
conf.set('HAVE_GSTREAMER', generic_media_handler_name == 'gstreamer')
+conf.set('HAVE_GSTREAMER_1_20', gstreamer.version() >= '1.20.0')
conf.set('GSTREAMER_BACKEND_DISCOVERER', gstreamer_backend_name == 'Discoverer')
conf.set('GSTREAMER_BACKEND_GUPNP_DLNA', gstreamer_backend_name == 'GUPnP-DLNA')
conf.set('HAVE_HAL', battery_detection_library_name == 'hal')
diff --git a/src/tracker-extract/tracker-extract-gstreamer.c b/src/tracker-extract/tracker-extract-gstreamer.c
index f5bd24d3e..f64413f72 100644
--- a/src/tracker-extract/tracker-extract-gstreamer.c
+++ b/src/tracker-extract/tracker-extract-gstreamer.c
@@ -1244,7 +1244,12 @@ discoverer_init_and_run (MetadataExtractor *extractor,
extractor->duration = gst_discoverer_info_get_duration (info) / GST_SECOND;
/* Retrieve global tags */
+#if defined(HAVE_GSTREAMER_1_20)
+ GstDiscovererStreamInfo *sinfo = gst_discoverer_info_get_stream_info (info);
+ discoverer_tags = gst_discoverer_container_info_get_tags ((GstDiscovererContainerInfo *)sinfo);
+#else
discoverer_tags = gst_discoverer_info_get_tags (info);
+#endif
if (discoverer_tags) {
gst_tag_list_insert (extractor->tagcache,
@@ -1256,7 +1261,6 @@ discoverer_init_and_run (MetadataExtractor *extractor,
extractor->streams = gst_discoverer_info_get_stream_list (info);
for (l = extractor->streams; l; l = g_list_next (l)) {
GstDiscovererStreamInfo *stream = l->data;
- const GstTagList *stream_tags;
if (G_TYPE_CHECK_INSTANCE_TYPE (stream, GST_TYPE_DISCOVERER_AUDIO_INFO)) {
GstDiscovererAudioInfo *audio = (GstDiscovererAudioInfo*)stream;
@@ -1285,17 +1289,30 @@ discoverer_init_and_run (MetadataExtractor *extractor,
} else {
/* Unknown type - do nothing */
}
+ }
- stream_tags = gst_discoverer_stream_info_get_tags (stream);
+ for (l = extractor->streams; l; l = g_list_next (l)) {
+ GstDiscovererStreamInfo *stream = l->data;
+ GstTagList *stream_tags;
+
+ stream_tags = gst_tag_list_copy (gst_discoverer_stream_info_get_tags (stream));
+ if (extractor->has_video &&
+ gst_tag_list_get_tag_size (extractor->tagcache, "title") > 0)
+ gst_tag_list_remove_tag (stream_tags, "title");
if (stream_tags) {
gst_tag_list_insert (extractor->tagcache,
stream_tags,
GST_TAG_MERGE_APPEND);
}
+
+ gst_tag_list_unref (stream_tags);
}
gst_discoverer_info_unref (info);
+#if defined(HAVE_GSTREAMER_1_20)
+ gst_discoverer_stream_info_unref (sinfo);
+#endif
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]