python - 从 python 脚本调用 ExifTool 在 Mac 中挂起,但在 Windows 中有效
问题描述
我正在使用这个答案中的脚本。我做了一个小的修改,如下所示。
修改1
sentinel = "{ready}\n"
def __init__(self, executable="/usr/local/bin/"):
self.executable = executable
def __enter__(self):
app = "exiftool"
command_line = [app, "stay_open", "True", "-@", "-"]
self.process = subprocess.Popen(command_line, executable=app, universal_newlines=True,
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
return self
原始链接中发布的其余答案完全不变。
我把上面的调用如下,
def main():
filename = r"/Volumes/backup/2017/MOV_0004.mp4"
with ExifTool.ExifTool() as e:
metadata = e.get_metadata(*filename)
json_str = json.dumps(metadata, indent=2)
print (json_str)
出于某种奇怪的原因,这在 Windows 上运行良好,但我无法让它在 Mac 上运行。
为了让它在 Windows 上运行,我更改了一行sentinel = "{ready}\n"
. 我在 Mac 上使用 python 3.7.1,在 Windows 上使用 python 3.6.1。
将不胜感激任何建议。
解决方案
推荐阅读
- vhdl - Xilinx ISE 14.5 不要求提供 .ucf 文件,并且可能不会读取它
- json - NestJS - 在请求正文中接受多种 MIME 类型
- excel - 清除特定选定列表视图行的内容?
- google-apps-script - 什么会导致 Google Apps 脚本挂在 GetSheetByName 上?
- tsql - TSQL - PIVOT 但连接字段
- kubernetes - Kubernetes 部署文件中的 SAML 配置
- c# - 条纹 webhook 签名不存在
- java - 将JSON键值映射到java中的类
- python - 轴 = 3 用于 numpy 中的 3D 数组?
- python - 运行此程序时出现递归错误