wang-bin / QtAV

A cross-platform multimedia framework based on Qt and FFmpeg. 基于Qt和FFmpeg的跨平台高性能音视频播放框架. Recommand to use new sdk https://github.com/wang-bin/mdk-sdk
http://qtav.org
3.98k stars 1.5k forks source link

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

Open AndriusWild opened 7 years ago

AndriusWild commented 7 years ago

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

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

--- 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).
wang-bin commented 7 years ago

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

AndriusWild commented 7 years ago

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

AndriusWild commented 7 years ago

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

This is one is more for metadata reading not writing.

wang-bin commented 7 years ago

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

AndriusWild commented 7 years ago

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 commented 7 years ago

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) ?

cgilles commented 7 years ago

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

javlada commented 7 years ago

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".

wang-bin commented 7 years ago

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

javlada commented 7 years ago

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.

uellue commented 6 years ago

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.

cgilles commented 6 years ago

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

alijafari97 commented 4 years ago

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"