Using the following in powershell produces the expected output of 01:22:02:03
:
在powershell中使用以下命令可以生成01:22:02:03的预期输出:
MediaInfo --Language=raw --Full --Inform="Video;%Duration/String4%" filename
My following python 2.7 script always gives the full mediainfo output with every piece of metadata, not just the Duration String that I specified.. I've tried escaping the semi colons but it has no effect. What am I doing wrong?
我下面的python 2.7脚本总是为每个元数据提供完整的mediainfo输出,而不仅仅是我指定的持续时间字符串。我试着逃过半子午线,但没有效果。我做错了什么?
import sys
import subprocess
filename = sys.argv[1]
test = subprocess.check_output(['MediaInfo', '--Language=raw', '--Full', '--inform="Video;%Duration/String4%"', filename])
print test
1 个解决方案
#1
2
Lose the double-quotes in the --Inform
argument. I can reproduce your problem with this code:
在-Inform参数中丢失双引号。我可以用这个代码重现你的问题:
import subprocess
args = [
'mediainfo',
'--Language=raw',
'--Full',
'--inform="Video;%Duration/String4%"',
'tests/reference.mp4'
]
bad_output = subprocess.check_output(args)
line_count_bad = len(bad_output.splitlines())
args[3] = args[3].replace('"', '')
good_output = subprocess.check_output(args)
line_count_good = len(good_output.splitlines())
print(line_count_bad, line_count_good, sep='\t')
print(good_output)
The output is:
的输出是:
204 1
b'00:00:07:08\n'
#1
2
Lose the double-quotes in the --Inform
argument. I can reproduce your problem with this code:
在-Inform参数中丢失双引号。我可以用这个代码重现你的问题:
import subprocess
args = [
'mediainfo',
'--Language=raw',
'--Full',
'--inform="Video;%Duration/String4%"',
'tests/reference.mp4'
]
bad_output = subprocess.check_output(args)
line_count_bad = len(bad_output.splitlines())
args[3] = args[3].replace('"', '')
good_output = subprocess.check_output(args)
line_count_good = len(good_output.splitlines())
print(line_count_bad, line_count_good, sep='\t')
print(good_output)
The output is:
的输出是:
204 1
b'00:00:07:08\n'