server.py 文件源码

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

项目:TS-Browser 作者: MatthewJohn 项目源码 文件源码
def ts_file(self, path):
        full_path = os.path.normpath(os.path.join(TS_DIR, './%s' % path))
        inspector = Inspector.get_inspector(full_path)
        parent = inspector.get_file_paths()['web_dir']
        metadata = inspector.get_metadata()

        video_streams = []
        audio_streams = []
        other_streams = []
        if metadata not in range(1, 5) and 'streams' in metadata:
            for index, stream in enumerate(metadata['streams']):
                if 'codec_type' in stream and stream['codec_type'] == 'video':
                    video_streams.append(index)
                    try:
                        if 'avg_frame_rate' in stream:
                            stream['avg_frame_rate_norm'] = eval(stream['avg_frame_rate'])
                    except ZeroDivisionError:
                        pass
                elif 'codec_type' in stream and stream['codec_type'] == 'audio':
                    audio_streams.append(index)
                else:
                    other_streams.append(index)

            if 'format' in metadata and 'size' in metadata['format']:
                metadata['format']['size_hr'] = humanize.naturalsize(metadata['format']['size'],
                                                                     gnu=True)


        return render_template('ts_file.html', inspector=inspector,
                               screenshot=inspector.get_screenshot(),
                               metadata=metadata, parent=parent,
                               job_status=JobStatus(),
                               video_streams=video_streams, audio_streams=audio_streams,
                               other_streams=other_streams)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号