shift datetimeoriginal from mts files is not possible

Started by DeltaTango, February 14, 2017, 01:13:18 PM

Previous topic - Next topic

DeltaTango

Hello,

first thank you for the nice programm. I use it to sort and rename my photos and videos. It works perfectly. But I have one problem. Unfortunately the time of the camera was not switched to summertime and many photos and videos has one hour difference from the photos/videos of my mobile. To change the photos is no problem but the mts files don't work.

The mts file included a tag datetimeoriginal in H264 section see below:

D:\Bilder\Transfer\test>exiftool -a -u -g1 *.*
======== 20160813(061729).MTS
---- ExifTool ----
ExifTool Version Number         : 10.07
---- System ----
File Name                       : 20160813(061729).MTS
Directory                       : .
File Size                       : 102 MB
File Modification Date/Time     : 2016:08:28 18:51:56+02:00
File Access Date/Time           : 2017:02:14 18:21:55+01:00
File Creation Date/Time         : 2017:02:14 18:21:55+01:00
File Permissions                : rw-rw-rw-
---- File ----
File Type                       : M2TS
File Type Extension             : mts
MIME Type                       : video/m2ts
---- M2TS ----
Video Stream Type               : H.264 Video
Audio Stream Type               : A52/AC-3 Audio
Duration                        : 0:00:32
---- AC3 ----
Audio Bitrate                   : 256 kbps
Surround Mode                   : Not indicated
Audio Channels                  : 2
Audio Sample Rate               : 48000
---- H264 ----
Image Width                     : 1920
Image Height                    : 1080
Date/Time Original              : 2016:08:13 06:17:29+01:00
Aperture Setting                : Auto
Gain                            : 3 dB
Exposure Program                : Program AE
White Balance                   : Auto
Focus                           : Auto (3.15)
Image Stabilization             : On (0x3f)
MDPM 0x0073                     : 0x7fffffd3
Exposure Time                   : 1/50
F Number                        : 2.8
Make                            : Sony
MDPM 0x00e1                     : 0x01000990
MDPM 0x00e2                     : 0x01010000
Camera Model Name               : DSC-RX100
---- Composite ----
Aperture                        : 2.8
Image Size                      : 1920x1080
Megapixels                      : 2.1
Shutter Speed                   : 1/50

But to change the datetimeoriginal is not supported? Why I can rename the mts files? And is there a chance to support them? Is there an other way to change the datetimeoriginal value? Thank you for your support!

D:\Bilder\Transfer\test>exiftool -ext mts "-datetimeoriginal+=1"  *.mts
Error: Writing of MTS files is not yet supported - 20160813(061729).MTS
    0 image files updated
    1 files weren't updated due to errors

Phil Harvey

Unfortunately MTS files are a complete disaster as far as file formats go, and it is unlikely that they will ever be supported by ExifTool for writing.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Hayo Baan

You may have some luck with the matchDateTime script I wrote. It has some support for mts date updating that may work for you too. If not, please let me know and perhaps I can find a way to extend the script.
Hayo Baan – Photography
Web: www.hayobaan.nl

DeltaTango

That is really too bad that there is no support of exiftool. But thank you  HayoBaan for your idea. But unfortunately I don't unterstand how is your tool used? What is the command for shift the datetimeoriginal one hour. Please can you give my advice?

Greetings

Dirk

Hayo Baan

Hi Dirk,

For MTS/M2TS file my script works by updating the DateTimeOriginal in the video stream to what the FileModification datetime is (if necessary you can specify a timezone as well). So in order for it to work you must first have gotten the modification date of the file to exactly what you want, then you can run my script and it will update the DateTimeOriginal metadata accordingly.

Full help of the command:
NAME
    matchDateTime -- matches date/time info in movie files where ExifTool is
    unable to.

VERSION
    version 0.009

DESCRIPTION
    "matchDateTime" updates the date/time info in (movie) files where ExifTool
    is unable to.

    For "normal" movie files, the maker note DateTimeOriginal and QuickTime
    CreationDate dates (and any other matching dates) are updated with the
    date as set in the QuickTime CreateDate.

    MTS and M2TS movie files are handled specially, in that here we take the
    file modification date as the new target date and update all occurrences
    of the DateTimeOriginal with this. All sequential timestamps are updated
    as well.

    Important: No other date/time tags than as described will get updated. So
    if you want any other tags to change as well, you will need to
    additionally use "exiftool". This also means that if you use the file
    modification time to specify the date/time to set, you will need to update
    the QuickTime CreateDate to reflect this (e.g. by using "exiftool -api
    QuickTimeUTC "-QuickTime:CreateDate<FileModifyDate" FILE").

    By default, the timezone information is left as was recorded by the
    camera, but you can change this by specifying a different timzezone (and,
    for MTS and M2TS files, a different daylight savings flag).

    The tool works by replacing any sequence of bytes that exactly match the
    original value by the (correctly formatted) QuickTime CreateDate. Note
    that with this approach it is possible that actual movie data is changed
    as well. This, however, is extremely unlikely: the chance of this occuring
    is less than 1/256^20 (1/256^10 for MTS/M2TS files).

SYNOPSIS
      matchDateTime [-recurse] [-overwrite] [-modtime] [-utc] [-tz TZ [-dst]] <Files>

OPTIONS
    The following options are available.

    Note: option names can be abbreviated so e.g. "-r" or "-rec" can be used
    instead of the full option name "-recurse".

    -recurse
        Recurse directories. This will have matchDateTime process all files in
        those directories, so use with care!

    -overwrite
        Overwrites the original file instead of renaming it to "_original".

    -modtime
        Instructs matchDateTime to use the file modification time instead of
        the QuickTime CreateDate.

        Note: This option is always in effect when matching the date times of
        MTS and M2TS files.

    -utc
        Indicates that QuickTime times are in UTC. This will convert the
        QuickTime time back to the local time, so any updates to the maker
        notes DateTimeOriginal and the CreationDate will also be in this time.

        With this option, if the file was recorded in a different timezone
        from your local, you should (temporarily) set the timezone to the
        timezone at the location of the recording. In Unix or on a Mac, this
        can be done by setting the TZ variable for the duration of the
        "matchDateTime" command like so: "TZ="America/New_York" matchDateTime
        -utc FILE".

    -tz TZ
        Use TZ as the new time zone. Specify the time zone in hours.

    -dst
        Indicates the daylight savings flag should be set when writing the new
        timezone information (only used when the "-tz" option is also
        specified).

PREREQUISITES
    matchDateTime requires both Perl <https://www.perl.org/> and ExifTool
    <http://www.exiftool.org/> to be installed.

INSTALLATION
    No installation is required, the script can be called directly. Optionally
    you can put the script in a directory on your path so it can be run from
    anywhere. On windows you may need to give the file an extension that is
    recognized as perl command (e.g., `.PL`).

AUTHOR
    Hayo Baan <info@hayobaan.com>

COPYRIGHT AND LICENSE
    This software is copyright (c) 2016 by Hayo Baan.

    This is free software; you can redistribute it and/or modify it under the
    same terms as the Perl 5 programming language system itself.


If you provide me with some more info on what needs to be done with your files, I can give you the exact command line(s) that are required.
Hayo Baan – Photography
Web: www.hayobaan.nl

DeltaTango

Hi Hayo,

I have installed perl and put your script in an textfile and named it matchdatetime.pl. Following testfile I have used 20160813(071729).MTS . Extract from exiftollgui show this:

2016:08:13 07:17:29+02:00 filemodifydate
2016:08:13 06:17:29+01:00 datetimeoriginal

first try
matchdatetime.pl *.mts
File does not exist: *.mts

second try
matchdatetime.pl 20160813(071729).MTS
Updated 2016:08:13 06:17:29 +01:00 => 2016:08:13 07:17:29 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:30 +01:00 => 2016:08:13 07:17:30 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:31 +01:00 => 2016:08:13 07:17:31 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:32 +01:00 => 2016:08:13 07:17:32 +01:00 in 20160813(071729).MTS (3 times)
Updated 2016:08:13 06:17:33 +01:00 => 2016:08:13 07:17:33 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:34 +01:00 => 2016:08:13 07:17:34 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:35 +01:00 => 2016:08:13 07:17:35 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:36 +01:00 => 2016:08:13 07:17:36 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:37 +01:00 => 2016:08:13 07:17:37 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:38 +01:00 => 2016:08:13 07:17:38 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:39 +01:00 => 2016:08:13 07:17:39 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:40 +01:00 => 2016:08:13 07:17:40 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:41 +01:00 => 2016:08:13 07:17:41 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:42 +01:00 => 2016:08:13 07:17:42 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:43 +01:00 => 2016:08:13 07:17:43 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:44 +01:00 => 2016:08:13 07:17:44 +01:00 in 20160813(071729).MTS (3 times)
Updated 2016:08:13 06:17:45 +01:00 => 2016:08:13 07:17:45 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:46 +01:00 => 2016:08:13 07:17:46 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:47 +01:00 => 2016:08:13 07:17:47 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:48 +01:00 => 2016:08:13 07:17:48 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:49 +01:00 => 2016:08:13 07:17:49 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:50 +01:00 => 2016:08:13 07:17:50 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:51 +01:00 => 2016:08:13 07:17:51 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:52 +01:00 => 2016:08:13 07:17:52 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:53 +01:00 => 2016:08:13 07:17:53 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:54 +01:00 => 2016:08:13 07:17:54 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:55 +01:00 => 2016:08:13 07:17:55 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:56 +01:00 => 2016:08:13 07:17:56 +01:00 in 20160813(071729).MTS (3 times)
Updated 2016:08:13 06:17:57 +01:00 => 2016:08:13 07:17:57 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:58 +01:00 => 2016:08:13 07:17:58 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:17:59 +01:00 => 2016:08:13 07:17:59 +01:00 in 20160813(071729).MTS (2 times)
Updated 2016:08:13 06:18:00 +01:00 => 2016:08:13 07:18:00 +01:00 in 20160813(071729).MTS (2 times)
OK: Changed date 67 times in 20160813(071729).MTS

I have stopped with escape. It runs and runs and runs.But it was created a new file

13.08.2016  06:18       106.561.536 20160813(071729).MTS
13.08.2016  06:17       106.561.536 20160813(071729).MTS_original

Exiftoolgui shows following after operation

2016:08:13 07:18:01+02:00 filemodifydate
2016:08:13 07:17:29+01:00 datetimeoriginal

The datetimeoriginal has changed :-) it works. But why the script don't stop and how can I use wildcards to proceed more as one mts?


Greetings

Dirk

Hayo Baan

Excellent! It works for you as I had hoped. That it runs on and on is quite normal; long video files have MANY dates to changes (possibly hundreds), and this may take a LONG time. Just let it run and eventually it will have processed all files. If you want you can inhibit writing the _original files by adding -overwrite to the command line, but other than that everything looks good 😊
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

I don't think the script handles wildcards in Windows (there is no automatic globbing of command-line arguments in Windows so the script would have to do this itself), so specify a directory name instead to process an entire directory of files.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).