summaryrefslogtreecommitdiff
path: root/src/video-support/VideoMetadataReaderProcess.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2023-06-14 20:36:17 +0200
committerJörg Frings-Fürst <debian@jff.email>2023-06-14 20:36:17 +0200
commit31804433d72460cbe0a39f9f8ea5e76058d84cda (patch)
tree2084a84c39f159c6aea254775dc0880d52579d45 /src/video-support/VideoMetadataReaderProcess.vala
parenta9898fb3f39c44a85876930ef6b2558052569ae6 (diff)
parentd443a3c2509889533ca812c163056bace396b586 (diff)
Update upstream source from tag 'upstream/0.32.1'
Update to upstream version '0.32.1' with Debian dir c460ad6e13d3c39eaa2d5399059385e64e6fba4c
Diffstat (limited to 'src/video-support/VideoMetadataReaderProcess.vala')
-rw-r--r--src/video-support/VideoMetadataReaderProcess.vala66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/video-support/VideoMetadataReaderProcess.vala b/src/video-support/VideoMetadataReaderProcess.vala
new file mode 100644
index 0000000..26d61a6
--- /dev/null
+++ b/src/video-support/VideoMetadataReaderProcess.vala
@@ -0,0 +1,66 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+using Gst;
+using Gst.PbUtils;
+
+int main(string[] args) {
+ Intl.setlocale(GLib.LocaleCategory.NUMERIC, "C");
+
+ var option_context = new OptionContext("- shotwell video metadata reader helper binary");
+ option_context.set_help_enabled(true);
+ option_context.add_group(Gst.init_get_option_group());
+
+ double clip_duration;
+ GLib.DateTime timestamp = null;
+
+ try {
+ option_context.parse(ref args);
+
+ if (args.length < 2)
+ throw new IOError.INVALID_ARGUMENT("Missing URI");
+
+ var f = File.new_for_commandline_arg (args[1]);
+
+ Gst.PbUtils.Discoverer d = new Gst.PbUtils.Discoverer((Gst.ClockTime) (Gst.SECOND * 5));
+ Gst.PbUtils.DiscovererInfo info = d.discover_uri(f.get_uri());
+
+ clip_duration = ((double) info.get_duration()) / 1000000000.0;
+
+ // Get creation time.
+ // TODO: Note that TAG_DATE can be changed to TAG_DATE_TIME in the future
+ // (and the corresponding output struct) in order to implement #2836.
+ Gst.DateTime? video_date = null;
+
+ Gst.TagList? tags = null;
+
+ var stream_info = info.get_stream_info();
+ if (stream_info is Gst.PbUtils.DiscovererContainerInfo) {
+ tags = ((Gst.PbUtils.DiscovererContainerInfo)stream_info).get_tags();
+ }
+ else if (stream_info is Gst.PbUtils.DiscovererStreamInfo) {
+ tags = ((Gst.PbUtils.DiscovererStreamInfo)stream_info).get_tags();
+ }
+
+ if (tags != null && tags.get_date_time(Gst.Tags.DATE_TIME, out video_date)) {
+ // possible for get_date() to return true and a null Date
+ if (video_date != null) {
+ timestamp = video_date.to_g_date_time().to_local();
+ }
+ }
+
+ print("%.3f\n", clip_duration);
+ if (timestamp != null) {
+ print("%s\n", timestamp.format_iso8601());
+ } else {
+ print("none\n");
+ }
+ } catch (Error error) {
+ critical("Failed to parse options: %s", error.message);
+
+ return 1;
+ }
+
+ return 0;
+}