根据ffprobe提取的头元数据测试条件筛选媒体文件。
FFfilter的Python项目详细描述
根据头元数据测试条件筛选媒体文件 由ffprobe提取。
安装
pip install fffilter
依赖关系
- fffilter使用 subprocess到 访问ffprobe的系统安装。
- colorama将是 由pip自动安装。
使用
命令行工具
-s--show[键]
返回以制表符分隔的[key]所有值的列表。
# Return the value(s) of display_aspect_ratio
fffilter /path/to/file --show display_aspect_ratio
# Return a list of files, surfacing all possible values of given keys # (note that '-' must be first argument when receiving piped input if using --show) find . -name '*.mp4'| fffilter - --show codec_name codec_type display_aspect_ratio
-m--match[键][值]
列出符合所有条件的文件:
- 匹配的文件列在stdout
- 不匹配的文件列在stderr上,用红色打印 背景
只需将键和值对传递给 --match参数。
# Return absoulte path for file if its header declares 4:3 aspect fffilter /path/to/file --match display_aspect_ratio 4:3
# Filter a list of files for h.264-encoded full-HD mp4s find . -name '*.mp4'| fffilter --match codec_name h264 --match height 1080 --match width 1920 -
模块
fromfffilterimportfffilterpath='media/some_file.mp4'# The show() method requires a path and a list of keysd=fffilter.show(path,['codec_type','display_aspect_ratio'])# The match() method requires a path and either key=value pairs or a packed dictionary: **{'key':'value'}m=fffilter.match(path,codec_type='video',display_aspect_ratio='16:9')print(d)print(m)
{'display_aspect_ratio': [u'16:9'], 'codec_type': [u'audio', u'video']} True
您还可以调用ffprobe(path)来访问 完整标题:
headers= fffilter.ffprobe(path) print(headers)
{u'streams': [{u'pix_fmt': u'yuv420p', u'sample_aspect_ratio': u'1:1', u'refs': 1, u'codec_type': u'video', u'coded_height': 720 ...
学分
fffilter由英国电影研究所的Edward Anderson撰写。