更新时间:2023-02-12 17:35:28
只使用ffmpeg,在输出中您可以看到所有流,然后可以使用正则表达式查找视频流并对其进行调节.
Just use ffmpeg, in the output you can see all the streams and than you can use regex to find video stream and condition on it.
import re
videostream=re.compile( r"Stream #\d*\:\d*\s*Video")
cmd = shlex.split('ffmpeg -i %s' % video_path)
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output = p.communicate()[1]
if not videostream.match(output): # !
audio_only = True
else: audio_only = False