I want to read the metadata in media files and then save that metadata in a text/xml file, so that I can later insert that data in my database. I would prefer to use ffmpeg.
Also is the same thing possible with MediaInfo?? I know I can get the metadata for individual tracks using MediaInfo, but I would want to automate it; as in whenever a new media file is found, read its metadata and then store it in a txt/xml file.
Or, is there any other tool/utility/API that I can use for this?
You can use
ffprobe
(which comes withffmpeg
) for gathering information about multimedia files. For information about overall content of a multimedia file useand for information about each single frame in a video file use
However,
ffprobe
does not retrieve as much information as my favorite tool, Mediainfo, does, e.g., 'ffprobe' does not display the time code of first frame of the video (although the man page claims otherwise) or the recording date.If you run
mediainfo
on the command line, you can even request output in XML format:In my example the output is:
Adding the optional parameter
-f
will produce even more detailed information.You can set the metadata on video, below mention set album_artist
And retreive the meta tag as:
Use this on command line .
You can save the global metadata to a text file using the
-f ffmetadata
option as follows:If you also need metadata from the video and audio streams (for example if the global metadata does not contain the creation time) use:
For details, see Metadata section in ffmpeg documentation.
For restoring metadata from a file see https://stackoverflow.com/a/50580239/2235831.
I prefer using exiftool which offers me more outputs than ffmpeg. take a example (a file from iphone):
the output is
while if i use ffmpeg
the output is
There's also atomicparsley for MPEG-4 files.