Bug 374453 - Extract right video date from MP4 files metadata
Summary: Extract right video date from MP4 files metadata
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Metadata-Video (show other bugs)
Version: 5.4.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-01-02 10:14 UTC by Dav
Modified: 2018-02-28 10:51 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.0.0


Attachments
Suprising displayed dates in metadata panel for video files (197.41 KB, image/png)
2017-01-02 10:14 UTC, Dav
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dav 2017-01-02 10:14:20 UTC
Created attachment 103142 [details]
Suprising displayed dates in metadata panel for video files

Hello,

Digikam allow to manage both pictures and movies files and metadata are displayed for both these 2 kind of files.

But Date metadatas are displayed in a very uncommon way in the right panel which display the embedded metadata (see screenshot).

It seems this is an issue in digikam: if I use an different software like exiftool to fetch metadata dates, they are displayed correctly:
$: exiftool /home/marc/pictures/GOPR0022.MP4 | grep Date
File Modification Date/Time     : 2013:01:02 12:23:11+01:00
File Access Date/Time           : 2017:01:01 19:52:08+01:00
File Inode Change Date/Time     : 2017:01:01 19:45:55+01:00
Modify Date                     : 2013:01:02 18:23:11
Track Create Date               : 2013:01:02 18:23:11
Track Modify Date               : 2013:01:02 18:23:11
Media Create Date               : 2013:01:02 18:23:11
Media Modify Date               : 2013:01:02 18:23:11
Date/Time Original              : 2013:01:02 12:23:11
Create Date                     : 2013:01:02 12:23:11

This issue seems related to #316882 which is marked as fixed, but I'm still encounter this problem with 5.3 coming from ppa.


Regards
Comment 1 caulier.gilles 2017-01-02 10:57:27 UTC
First, digiKam do not use Exiftool to extract metadata. It use Exiv2 instead.

Second, Exiv2 0.26 support better video metadata. We include this version of library (not yet released), in universal Linux AppImage bundle. Please try with this digiKam 5.4.0 pre-release available here :

https://drive.google.com/drive/folders/0BzeiVr-byqt5Y0tIRWVWelRJenM

Gilles Caulier
Comment 2 Dav 2017-01-02 11:32:44 UTC
Hello Gilles,

First, thanks for your quick answer.

I haven't the required knowledge to judge which is the better API to process metadata: exiftool example was just to identify which component is responsible of this display.

I'll give you a feedback with the 5.4 version.

Regards
Comment 3 Andrius 2017-01-31 03:14:08 UTC
Confirmed on 5.4.0. For all mp4 files digiKam used a file modification date instead of any content create date from metadata. Looks like exiv2 does not read any metadata from mp4 files yet.
Comment 4 Andrius 2017-02-06 18:07:35 UTC
I am wondering if this might help:
https://discuss.pixls.us/t/organize-images-videos-in-folders-by-month-date-taken/3156/10?u=andrius
There is a link to a piece of code of Rapid Photo Downloader responsible for reading video files' creation date in the post. I tested it on my machine and it worked well, all video files went to correct date folders
Comment 5 Andrius 2017-02-06 18:08:56 UTC
Mediainfo reads the date well:

mediainfo FILE.mp4 | grep "Encoded date" | head -n 1

Example output:
Encoded date : UTC 2012-01-08 11:16:19
Comment 6 Andrius 2017-03-18 15:11:16 UTC
Hello Gilles,

This message also applicable to:
https://bugs.kde.org/show_bug.cgi?id=377072
https://bugs.kde.org/show_bug.cgi?id=377177

It turned out that ffmpeg is already able to read a lot of metadata we could use.

Here is an output of an ffmeg -i command on a sample file:
---
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/mnt/data/FamilyPictures/2016/2016-10/20161008/20161007_190516.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2016-10-08T01:10:04.000000Z
    location        : +50.8893-114.0159/
    location-eng    : +50.8893-114.0159/
    com.android.version: 6.0.1
  Duration: 00:00:43.20, start: 0.000000, bitrate: 16947 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 16876 kb/s, 29.78 fps, 29.92 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      rotate          : 90
      creation_time   : 2016-10-08T01:10:04.000000Z
      handler_name    : VideoHandle
    Side data:
      displaymatrix: rotation of -90.00 degrees
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default)
    Metadata:
      creation_time   : 2016-10-08T01:10:04.000000Z
      handler_name    : SoundHandle
---

Reading just these three fields

creation_time   : 2016-10-08T01:10:04.000000Z
location        : +50.8893-114.0159/
rotate          : 90 (or displaymatrix: rotation of -90.00 degrees)

will allow digiKam to:

1. Import video files in correct folders, rename them correctly on import
2. Show video files in chronological order when sort by date
3. Show video files on the map, add GPS information to the database
4. Preview video correctly per the rotation tag, create correct video thumbnails

Is that possible to add the support of this on your roadmap? Let me know your thoughts.

https://github.com/wang-bin/QtAV/issues/820#issuecomment-287545695
Comment 7 caulier.gilles 2017-03-18 15:16:41 UTC
yes, we can do it through QtAV.

Try to use stand alone QtAv Player. Load a video and go to Info pannel. These ffmpeg metadata are there. So i'm sure more and less that QtAV can provide all these kind of data to client application as digiKam, without to use directly ffmpeg (and add direct ffpmeg dependencies to digiKam.

Gilles Caulier
Comment 8 Andrius 2017-03-18 15:26:44 UTC
(In reply to caulier.gilles from comment #7)
> yes, we can do it through QtAV.
> 
> Try to use stand alone QtAv Player. Load a video and go to Info pannel.
> These ffmpeg metadata are there. So i'm sure more and less that QtAV can
> provide all these kind of data to client application as digiKam, without to
> use directly ffmpeg (and add direct ffpmeg dependencies to digiKam.
> 
> Gilles Caulier

It can write too. I just wrote GPS location into mp4 file using this command
ffmpeg -i inputfile -metadata location="+50.8893-114.0159/" outputfile
Comment 9 caulier.gilles 2017-03-18 17:06:23 UTC
Very interesting. Do you know if there is already somewhere a c++ interface to ffmpeg to read/write metadata on video ?
Comment 10 Andrius 2017-03-18 17:34:05 UTC
(In reply to caulier.gilles from comment #9)
> Very interesting. Do you know if there is already somewhere a c++ interface
> to ffmpeg to read/write metadata on video ?

Is this close to what you are looking for?

https://ffmpeg.org/doxygen/2.0/doc_2examples_2metadata_8c-example.html
Comment 11 caulier.gilles 2018-02-28 10:51:14 UTC
With 6.0.0, we have now a FFMpeg low level metadata parser based on libav C API
for video files database registration.

The Exiv2 video support is not used anymore as this code is buggous and nobody
sound motivated in Exiv2 to finalize the code.

The original post for this file must be fixed now and video metadata support
with ffmpeg must be enough to populate database entries.

Gilles Caulier