I am trying to extract the metadata from an mp4/jpg file. I am using exiftool, but if there is something better out there please say. I would like to begin with a video, extract the frames as jpgs and add the metadata to each frame, there should be slight differences in each of the metadata for the images like time and maybe focal length.
Here is the start of my attempt with https://smarnach.github.io/pyexiftool/. I don't think its even loading as et, but I am new at this and do not know what could be the problem?
Here is the MWE (which is pretty much what is in the documentation) - it does the same whether I use .jpg or .mp4
import exiftool
files = ['file.MP4', 'file.MP4']
with exiftool.ExifTool() as et:
metadata = et.get_metadata_batch(files)
for d in metadata:
print("{:20.20} {:20.20}".format(d["SourceFile"],
d["EXIF:DateTimeOriginal"]))
and the error:
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-4-2bf611f4ab6b> in <module>
9 files = ['file.MP4', 'file1.MP4']
10
---> 11 with exiftool.ExifTool() as et:
12 metadata = et.get_metadata_batch(files)
13 for d in metadata:
C:\ProgramData\Anaconda3\lib\site-packages\exiftool.py in __enter__(self)
189
190 def __enter__(self):
--> 191 self.start()
192 return self
193
C:\ProgramData\Anaconda3\lib\site-packages\exiftool.py in start(self)
172 "-common_args", "-G", "-n"],
173 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
--> 174 stderr=devnull)
175 self.running = True
176
C:\ProgramData\Anaconda3\lib\subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors)
727 c2pread, c2pwrite,
728 errread, errwrite,
--> 729 restore_signals, start_new_session)
730 except:
731 # Cleanup if the child failed starting.
C:\ProgramData\Anaconda3\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session)
1015 env,
1016 os.fspath(cwd) if cwd is not None else None,
-> 1017 startupinfo)
1018 finally:
1019 # Child is launched. Close the parent's copy of those pipe
FileNotFoundError: [WinError 2] The system cannot find the file specified
The way you use pyexiftool
requires that exiftool
is available in a directory listed in the $PATH
environment variable.
Open a cmd
window, type in the command exiftool
and hit enter
. If that also returns a "file not found" error, then either
exiftool
is not installed or exiftool
is installed is not in the path.In case (2) you can give the full path to the exiftool
executable in the constructor. For example:
exiftool.ExifTool(r'C:\program files\exiftool\exiftool.exe')