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 save the global metadata to a text file using the -f ffmetadata
option as follows:
ffmpeg -i in.mp4 -f ffmetadata in.txt
If you also need metadata from the video and audio streams (for example if the global metadata does not contain the creation time) use:
ffmpeg -i in.mp4 -c copy -map_metadata 0 -map_metadata:s:v 0:s:v -map_metadata:s:a 0:s:a -f ffmetadata in.txt
For details, see Metadata section in ffmpeg documentation.
For restoring metadata from a file see https://stackoverflow.com/a/50580239/2235831.