Skip to main content

Filters media files by testing criteria against header metadata extracted by ffprobe.

Project description

Filters media files by testing criteria against header metadata extracted by ffprobe.

Install

pip install fffilter

Dependencies

  • FFfilter uses subprocess to access the system installation of ffprobe.

  • colorama will be automatically installed by pip.

Use

Command-line tool

-s --show [key]

Returns a tab-separated list of all values of [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 [key] [value]

Lists files which match all criteria:

  • matching files are listed on stdout

  • non-matching files are listed on stderr, printed over a red background

Simply pass key and value pairs to repeating occurrences of the --match parameter.

# 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 -

Module

from fffilter import fffilter

path = 'media/some_file.mp4'

# The show() method requires a path and a list of keys
d = 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

You can also call ffprobe(path) to access a dictionary of the complete headers:

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
...

Disclaimer

This Python Package is not affiliated with FFmpeg or FFprobe.

Credits

FFfilter was written by Edward Anderson, British Film Institute.

Licence

Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

FFfilter-0.0.3.tar.gz (4.0 kB view details)

Uploaded Source

File details

Details for the file FFfilter-0.0.3.tar.gz.

File metadata

  • Download URL: FFfilter-0.0.3.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for FFfilter-0.0.3.tar.gz
Algorithm Hash digest
SHA256 f00c4b9f3394497b091963d7092ed5669cc30ad8f41bd307ac94a38c7bebf44a
MD5 d5a661461da9c77b108bd6f57b10c383
BLAKE2b-256 62e0cdecb38eb6aa056a9fe32df1f632cfcb3ec85d9a375ef147bca49d1a459a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page