This Python script is designed to extract metadata from an SRT file and write it to the frames of a video. It utilizes the ffmpeg
and exiftool
command-line tools to split the video into frames and write the metadata, respectively.
- Python 3.x
ffmpeg
command-line toolexiftool
command-line tool
-
Ensure that you have Python 3.x installed on your system.
-
Install the required Python dependencies by running the following command:
pip install argparse
-
Install
ffmpeg
andexiftool
on your system. Instructions for installation can be found on the official websites of the respective tools. -
Download or clone the script to your local machine.
-
Open a terminal or command prompt and navigate to the directory containing the script.
-
Run the following command to execute the script:
python tagger.py --video <path_to_video> --srt <path_to_srt> [--framerate <framerate>] [--framerate-video <framerate_video>] [--frames_dir <frames_dir>] [--metadata-file <metadata_file>]
Replace
tagger.py
with the actual name of the script file.--video
: (required) Path to the video file.--srt
: (required) Path to the SRT file containing metadata.--framerate
: (optional) Framerate at which to output the frames. Default is1
.--framerate-video
: (optional) Framerate of the input video. Default is30
.--frames_dir
: (optional) Path to the directory where the frames will be saved. Default is'frames/'
.--metadata-file
: (optional) Path to the metadata image file. Default is'metadata.jpg'
.
Note: Make sure to replace
<path_to_video>
,<path_to_srt>
, and other parameters with the actual paths and values. -
The script will perform the following actions:
- Parse the SRT file to extract frame numbers, timestamps, and metadata.
- Split the video into frames using
ffmpeg
. - Write the metadata from the metadata image file to the frames using
exiftool
. - Write the extracted metadata to the frames using
exiftool
.
-
After the script finishes executing, you will find the frames with the embedded metadata in the specified
--frames_dir
directory.
Here is an example command to run the script:
python tagger.py --video input_video.mp4 --srt input_metadata.srt --framerate 2 --framerate-video 30 --frames_dir output_frames --metadata-file metadata.jpg
In this example, the script will extract metadata from the input_metadata.srt
file and embed it into the frames of the input_video.mp4
video. The frames will be saved in the output_frames
directory, and the metadata will be written using the metadata.jpg
file.
The metadata.jpg
file should be a photo you have taken with the device that captured the video. This allows the tagged images to be uploaded to DroneDeploy without issue.
Feel free to adjust the parameters according to your specific requirements.