这让我发疯了。我正在使用织物通过 SSH 在远程服务器上执行一些视频处理任务。
在我们进入这个函数之前,我在远程机器上调用 ffprobe 来获取我将发送到该服务器的视频信息。我正在尝试从 ffprobe 的输出中解析出有关 Duration: 的信息,以便我可以以秒为单位获得视频的长度。这是函数的麻烦部分,我似乎无法将字符串转换为整数。
with cd("~/videos"):
command = "ffprobe "
command += videoNameOnly
output = run(command)
durationIndex = output.find("Duration:")
durationIndex = durationIndex + 10
duration = output[durationIndex:]
durationFrags = duration.split(":")
print "====================================="
print durationFrags[0].strip()
print durationFrags[1].strip()
print durationFrags[2].strip()
hours = int(durationFrags[0].strip())
输出如下
00
00
52.90, start
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/fabric/main.py", line 712, in main
*args, **kwargs
File "/usr/local/lib/python2.7/dist-packages/fabric/tasks.py", line 298, in execute
multiprocessing
File "/usr/local/lib/python2.7/dist-packages/fabric/tasks.py", line 197, in _execute
return task.run(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/fabric/tasks.py", line 112, in run
return self.wrapped(*args, **kwargs)
File "/home/amyface/fabfile.py", line 26, in main
encode();
File "/home/amyface/fabfile.py", line 34, in encode
runJobs(jobs,cursor)
File "/home/amyface/fabfile.py", line 60, in runJobs
getMiddleFrame(sourceVideo,videoNameOnly,cursor)
File "/home/amyface/fabfile.py", line 96, in getMiddleFrame
hours = int(durationFrags[0].strip())
ValueError: invalid literal for int() with base 10: '\x1b[0m\x1b[0;39m\x1b[0m\x1b[0;39m\x1b[0m\x1b[0;39m00'
Disconnecting from [I have removed the server name from here]
为什么它不允许我将“00”转换为整数?“以 10 为基数:”之后的错误中的奇怪值是什么?