【问题标题】:FileNotFoundError: [WinError 2] The system cannot find the file specified: exiftoolFileNotFoundError: [WinError 2] 系统找不到指定的文件:exiftool
【发布时间】:2019-08-10 15:31:24
【问题描述】:

我正在尝试从 mp4/jpg 文件中提取元数据。我正在使用 exiftool,但如果有更好的东西请说。我想从一个视频开始,将帧提取为 jpg 并将元数据添加到每个帧,图像的每个元数据应该略有不同,比如时间和焦距。

这是我尝试https://smarnach.github.io/pyexiftool/ 的开始。我不认为它甚至加载为 et,但我是新手,不知道可能是什么问题?

这里是 MWE(这几乎是文档中的内容) - 无论我使用 .jpg 还是 .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"]))

和错误:

---------------------------------------------------------------------------
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

【问题讨论】:

  • 您是否尝试过使用 MP4 文件的完整路径?
  • @StarGeek。是的,并将文件移动到文件夹以确保不是问题。

标签: python-3.x metadata file-not-found exiftool


【解决方案1】:

您使用pyexiftool 的方式要求exiftool$PATH 环境变量中列出的目录中可用。

打开cmd 窗口,输入命令exiftool 并点击enter。如果这也返回“找不到文件”错误,那么

  1. exiftool 未安装或
  2. 安装exiftool的目录不在路径中。

在情况 (2) 中,您可以在构造函数中提供 exiftool 可执行文件的完整路径。例如:

exiftool.ExifTool(r'C:\program files\exiftool\exiftool.exe')

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-05-21
  • 1970-01-01
  • 2020-01-02
  • 1970-01-01
  • 2017-08-01
  • 2019-07-29
  • 1970-01-01
相关资源
最近更新 更多