QtAV icon indicating copy to clipboard operation
QtAV copied to clipboard

Feauture request - Read/write metadata video files (avi/mov/mp4/mkv)

Open AndriusWild opened this issue 8 years ago • 13 comments

Hello, Is there a chance to have that option released in future?

I am particularly interested in reading/writing the following metadata:

  • Creation date (Encoded Date)
  • Rating
  • Keywords (tags)
  • People (if possible)
  • Geolocation (exiftool can do that see: http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=5977.0 )
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/41727016-feauture-request-read-write-metadata-video-files-avi-mov-mp4-mkv?utm_campaign=plugin&utm_content=tracker%2F307703&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F307703&utm_medium=issues&utm_source=github).

AndriusWild avatar Feb 06 '17 18:02 AndriusWild

Editing metadata is not in my plan if there is no tool can be used

wang-bin avatar Feb 07 '17 03:02 wang-bin

Can this SDK be considered as a tool? https://www.bento4.com/

AndriusWild avatar Mar 11 '17 01:03 AndriusWild

Here is one more: https://sourceforge.net/projects/mediainfo/?source=navbar

This is one is more for metadata reading not writing.

AndriusWild avatar Mar 11 '17 01:03 AndriusWild

What metadata do you want to read? ffmpeg already supports reading metadata. You can use ffprobe to see the video information

wang-bin avatar Mar 18 '17 13:03 wang-bin

What metadata do you want to read? ffmpeg already supports reading metadata. You can use ffprobe to see the video information You are actually correct. Ffmpeg is already able to read a lot of metadata.

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

Is there a way to pull these via API call directly from QtAV?

AndriusWild avatar Mar 18 '17 15:03 AndriusWild

ffmpeg can write metadata too. Example: 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

Is that possible to do that via QtAV without adding ffmpeg as dependency to an application (digiKam) ?

AndriusWild avatar Mar 18 '17 15:03 AndriusWild

I vote for this feature too, for digiKam video metadata support. We don't need something complicated, but at least to be able to get main metadata from video file as QString (comments, date-time, camera model, etc).

In digiKam, the plan since a very long time is to see this feature implemented through Exiv2 shared library. Even if video file support is implemented in this lib, the code is full of bugs and crash quickly because nobody want to fix the code...

So we need a simple alternative, at least to populate the collection database from digiKam, in goal to search video items registered.

Gilles Caulier

cgilles avatar Jul 09 '17 14:07 cgilles

Also is there any possibility to get chapters (for example menu from MKV files)? I saw some initial support in the code but the current functions only return "undefined".

javlada avatar Sep 13 '17 14:09 javlada

090ebb2 this commit add chapters property and seekChapter() for AVPlayer

wang-bin avatar Sep 13 '17 14:09 wang-bin

Great, could you also in addition to the chapters() function provide chapterNames() and chapterTimes()? Or is it already possible to somehow obtain these values?

Thanks a lot.

javlada avatar Sep 14 '17 10:09 javlada

Writing metadata to video files would be high on my wish list in order to support that in Digikam. http://digikam.1695700.n4.nabble.com/REad-write-metadata-video-files-avi-mov-mp4-mkv-td4692739.html

My collection has both images and videos, and I would like to use both the same way.

uellue avatar Apr 30 '18 11:04 uellue

I personalty implemented the video metadata support with ffmpeg in next digiKam 6.0.0.

It's in Read only and i re-route the video tags reported by ffmpeg to Exiv2 container that we use everywhere in digiKam. It's not perfect as Exiftool can do, but at least this permit to extract the most important tags from video files to register data in digiKam database. The write process is not suitable with ffmpeg. So to write metadata, you need to use XMP sidecar.

For more info, look this code :

https://cgit.kde.org/digikam.git/tree/core/libs/dmetadata/dmetadata_ffmpeg.cpp

Note : using Exiv2 to read/write wideo metadata crash digiKam in few seconds to use. Exiv2 code to handle video file is bugous, and nobody want to patch, hack, stabilize the code (at least to read data). So my solution is the best way as digiKam already depends of ffmpeg and is stable.

Gilles Caulier

cgilles avatar Apr 30 '18 11:04 cgilles

for reading metadata you can add these lines of code to QtAV source code from ffmpeg examples and rebuild it AVDictionaryEntry *tag = NULL; while ((tag = av_dict_get(d->format_ctx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) qDebug("metadata: %s=%s\n", tag->key, tag->value); i put them in AVDemuxer.cpp and it works: Debug: "metadata: title=El Cid 1961 720p TInyMoviez\n" Debug: "metadata: encoder=libebml v1.3.0 + libmatroska v1.4.0\n" Debug: "metadata: creation_time=2013-07-26T13:50:54.000000Z\n"

alijafari97 avatar Aug 24 '20 04:08 alijafari97