This script updates the metadata of media files (images and videos) using associated JSON files containing timestamp and geolocation data.
Before running the script, ensure you have the following installed:
- Python 3.x
- Pillow (PIL Fork) Library
- Piexif Library
- FFmpeg
- ImageMagick
You can install the required Python libraries using pip:
pip install pillow piexifFFmpeg and ImageMagick need to be installed and available in your system's PATH. Refer to the respective documentation for installation instructions:
The script supports the following media file formats:
- Images: JPEG, PNG, GIF, HEIC
- Videos: MOV, MP4
- Place the script in a directory containing your media files and the corresponding JSON files.
- The JSON files should have the same base name as the media files, with an additional
.jsonextension. - Open the script in a text editor and modify the
directoryvariable to the path containing your media and JSON files. - Run the script from the terminal:
python3 media_metadata_updater.py- The script reads the
photoTakenTimeandgeoDatafrom the JSON files and updates the media files' metadata accordingly. - For images, it updates the EXIF data (for JPEG and HEIC) and adds textual information (for PNG and GIF).
- For videos, it embeds the timestamp and geolocation into the video metadata.
- The script converts HEIC images to JPEG to update the EXIF data and then converts them back to HEIC.
- Ensure that all dependencies are correctly installed and configured.
- Verify that the JSON files are correctly formatted and contain the necessary fields for the script to function.
- If the metadata does not appear updated, use dedicated metadata viewers to verify the changes, as operating system file properties may not reflect all metadata updates.
- The script overwrites the original media files with the updated metadata. It is recommended to back up your media files before running the script.
- Ensure that FFmpeg and ImageMagick commands are allowed to execute by your system's security settings.