【问题标题】:How to programmatically tell if a video file is audio-only如何以编程方式判断视频文件是否为纯音频文件
【发布时间】:2014-10-19 11:36:53
【问题描述】:

拍摄以下两个视频文件,每个两分钟:

1) 仅音频:https://s3-us-west-1.amazonaws.com/premiere-avails/out__04d05853-c7a6-4a22-8be9-04feb38032f5__WB-APERFECTMURDER-CAS-HD-16X9FF-FIX.mov

2) 音视频:https://s3-us-west-1.amazonaws.com/premiere-avails/out__04f259dc-14ad-44ae-98b5-745c4a6ba9de__STYLE_RUBY_209.mov

如何编写命令来告诉我视频文件是否有视频轨道?例如:

cmd = shlex.split('ffprobe -i %s' % video_path)
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output = p.communicate()[1]
if 'something' in ouput: # ?
    audio_only = True
else:
    audio_only = False

【问题讨论】:

    标签: python ffmpeg


    【解决方案1】:

    只需使用 ffmpeg,在输出中您可以看到所有流,然后您可以使用正则表达式查找视频流和条件。

    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
    

    【讨论】:

      猜你喜欢
      • 2011-12-16
      • 2012-09-05
      • 2019-09-27
      • 1970-01-01
      • 2018-02-19
      • 1970-01-01
      • 2021-05-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多