size = 'ffprobe -v error -show_entries format=size -of default=noprint_wrappers=1:nokey=1 dump.mp4 > file'
proc = subprocess.Popen(shlex.split(size), shell=True)
time.sleep(1)
proc.terminate() #proc.kill() modify it by a suggestion
size = ""
with open('file', 'r') as infile:
for line in infile.readlines():
size += line.strip()
print(size)
os.remove('file')
当你使用
子过程
,必须终止进程。这是一个示例。如果不终止进程,
文件
会是空的,你什么也看不到。它可以继续运行
窗户
。我无法确保它可以在Unix上运行。