qr-lipsync-detect.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:qr-lipsync 作者: UbiCastTeam 项目源码 文件源码
def get_media_info(self, media_file):
        try:
            ffprobe = shutil.which('ffprobe')
        except Exception:
            # python2
            from distutils.spawn import find_executable
            ffprobe = find_executable('ffprobe')
        if ffprobe: 
            cmd = "ffprobe -v error -select_streams v -show_entries stream=width,height,avg_frame_rate,duration -of default=noprint_wrappers=1 -print_format json %s" % media_file
            result = subprocess.check_output(cmd.split(' '), universal_newlines=True)
            vjres = json.loads(result)['streams'][0]
            if not vjres.get('duration'):
                cmd = "ffprobe -v error -select_streams v -show_format_entry duration -of default=noprint_wrappers=1 -print_format json %s" % media_file
                result = subprocess.check_output(cmd.split(' '), universal_newlines=True)
                vjres['duration'] = json.loads(result)['format']['duration']
            cmd = "ffprobe -v error -select_streams a -show_entries stream=sample_rate -of default=noprint_wrappers=1 -print_format json %s" % media_file
            result = subprocess.check_output(cmd.split(' '), universal_newlines=True)
            ajres = json.loads(result)['streams'][0]
            vjres['sample_rate'] = ajres['sample_rate']
            return vjres
        else:
            logger.error('ffprobe is required')
            sys.exit()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号