Has anyone wrote a script that writes any info to sidecar?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Has anyone wrote a script that writes any info to sidecar?

AndriusWild
Hello,

I am thinking of writing a script that would read GPS coordinates from a video
file using mediainfo and paste them to xmp sidecar for digiKam to be able to
read.
I am looking for a starting point. Does anyone have a script that writes
something in a text file?

I will probably be using MediaInfo to read the coordinates.

mediainfo FILE | grep "©xyz" | head -n 1

Thank you in advance for any ideas.

Reply | Threaded
Open this post in threaded view
|

Re: Has anyone wrote a script that writes any info to sidecar?

hajo

On Tue, May 16, 2017 at 6:14 AM, <[hidden email]> wrote:
Hello,

I am thinking of writing a script that would read GPS coordinates from a video
file using mediainfo and paste them to xmp sidecar for digiKam to be able to
read.
I am looking for a starting point. Does anyone have a script that writes
something in a text file?

I will probably be using MediaInfo to read the coordinates.

mediainfo FILE | grep "©xyz" | head -n 1

Thank you in advance for any ideas.


The good old awk, maybe?
Reply | Threaded
Open this post in threaded view
|

Re: Has anyone wrote a script that writes any info to sidecar?

Remco Viëtor
On mardi 16 mai 2017 03:55:25 CEST HaJo Schatz wrote:

> On Tue, May 16, 2017 at 6:14 AM, <[hidden email]> wrote:
> > Hello,
> >
> > I am thinking of writing a script that would read GPS coordinates from a
> > video
> > file using mediainfo and paste them to xmp sidecar for digiKam to be able
> > to
> > read.
> > I am looking for a starting point. Does anyone have a script that writes
> > something in a text file?
> >
> > I will probably be using MediaInfo to read the coordinates.
> >
> > mediainfo FILE | grep "©xyz" | head -n 1
> >
> > Thank you in advance for any ideas.
>
> The good old awk, maybe?
And the shell echo works fine as well for writing to a text file.  I'm sure
scripting languages like Perl Python also can write to text files :P. It all
depends on what language will beused for the script.

But the main problem is not writing to the text file. You'll have to format the
data correctly as well: XML is rather touchy wrt. syntax errors, those result
in either a rejection of the complete file (as the readar bails out w/o giving
any data to caller) or at best a missing tag (and having all your videos on
the equator or the Greenwich meridian is perhaps not what you want).

A quick look at one of my digikam xmp files shows 11 lines with GPS info, all
as attributes to a <rdf:Description ...> tag. Which means that you can't just
tack an extra element at the end of an existing xmp file.

I suppose you did see the --Inform and --Output options for mediainfo? Those
might get you some of the required formatting. Transforming one form of XML in
another might be easier than go through text (see XSLT).
disclaimer: I never used mediainfo.

Remco
Reply | Threaded
Open this post in threaded view
|

Re: Has anyone wrote a script that writes any info to sidecar?

Mica Semrick
In reply to this post by AndriusWild
I'd be happy to help with the XML/XMP part of this; XML startlet is your friend.

Find the tags you need using mediainfo and which XMP tags you want to write and let us know.

-m

On May 15, 2017 3:14:38 PM PDT, [hidden email] wrote:
Hello,

I am thinking of writing a script that would read GPS coordinates from a video
file using mediainfo and paste them to xmp sidecar for digiKam to be able to
read.
I am looking for a starting point. Does anyone have a script that writes
something in a text file?

I will probably be using MediaInfo to read the coordinates.

mediainfo FILE | grep "©xyz" | head -n 1

Thank you in advance for any ideas.

Reply | Threaded
Open this post in threaded view
|

Re: Has anyone wrote a script that writes any info to sidecar?

AndriusWild
Hello,

Thank you all for your earlier responses.

Here is how I transfer xyz(c) coordinates writen into video files to digiKam database so far:
https://youtu.be/QpBJaSIPMCk

The "Copy GPS to clipboard script" reads the coordinates using mediainfo and converts them from something like this:
©xyz                                     : +50.9003-114.0125/
to something like this:
geo:50.900300000,-114.012500000
Then I select the video in digikam, press Ctrl + Shift + G (for some reason you can only see "G" on the video) and paste the coordinates.
Works as a charm but it is not automated.

Next step would to automate this process which means the scipt would read the xyz(c) tag using mediainfo and write it to the sidecarfile.

Sidecar looks like this:

<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 4.4.0-Exiv2">
 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <rdf:Description rdf:about=""
    xmlns:xmp="http://ns.adobe.com/xap/1.0/"
    xmlns:exif="http://ns.adobe.com/exif/1.0/"
    xmlns:tiff="http://ns.adobe.com/tiff/1.0/"
   xmp:CreatorTool="digiKam-5.6.0"
   exif:GPSLatitudeRef="N"
   exif:GPSLongitudeRef="W"
   exif:GPSVersionID="2.0.0.0"
   exif:GPSLatitude="50,54.0180000N"
   exif:GPSLongitude="114,0.7500000W"
   exif:GPSMapDatum="WGS-84"
   tiff:Software="digiKam-5.6.0"/>
 </rdf:RDF>
</x:xmpmeta>
<?xpacket end="w"?>

As you see, the coordinates will need to be converted again.

Actually exiftool is able to see more GPS tags written to file and they look more similar to what digiKam is expecting to see in XMP:
...
[QuickTime]     GPSCoordinates                  : 50 deg 54' 1.08" N, 114 deg 0' 45.00" W
...
[Composite]     GPSLatitude                     : 50 deg 54' 1.08" N
[Composite]     GPSLongitude                    : 114 deg 0' 45.00" W
...
[Composite]     GPSPosition                     : 50 deg 54' 1.08" N, 114 deg 0' 45.00" W
...

Do you think that will be easy to accomplish?

So far  tried inserting:
   exif:GPSLatitudeRef="N"
   exif:GPSLongitudeRef="W"
   exif:GPSVersionID="2.0.0.0"
   exif:GPSLatitude="50,54.0180000N"
   exif:GPSLongitude="114,0.7500000W"
   exif:GPSMapDatum="WGS-84"
to an XMP file but digiKam did not recognize it.


Best regards,

On Tue, May 16, 2017 at 1:10 AM, Mica Semrick <[hidden email]> wrote:
I'd be happy to help with the XML/XMP part of this; XML startlet is your friend.

Find the tags you need using mediainfo and which XMP tags you want to write and let us know.

-m

On May 15, 2017 3:14:38 PM PDT, [hidden email] wrote:
Hello,

I am thinking of writing a script that would read GPS coordinates from a video
file using mediainfo and paste them to xmp sidecar for digiKam to be able to
read.
I am looking for a starting point. Does anyone have a script that writes
something in a text file?

I will probably be using MediaInfo to read the coordinates.

mediainfo FILE | grep "©xyz" | head -n 1

Thank you in advance for any ideas.