Skip to main content

Extract metadata from video files using ffprobe or mediainfo

Project description

Features

  • Formatted data from ffprobe/mediainfo
  • Fallback data in case ffprobe/mediainfo cannot get data
  • Identical data structure
  • Full compatability with Python 3

Install

pip install PyProbe

Usage

import pyprobe
parser = pyprobe.VideoFileParser(ffprobe="/usr/bin/ffprobe", includeMissing=True, rawMode=False)
data = parser.parseFfprobe(inputFile)

This code will return a dictionary of values (as described below).

  • includeMissing Will remove values where ffprobe/mediainfo does not return data
  • rawMode Will make each value the raw output from ffprobe/mediainfo, which will be a string (except resolution, which is a tuple of strings).

There are also two helper functions provided to create more nicely formatted data -

>>> import pyprobe
>>> pyprobe.timeToTuple(12345.44)
(3, 25, 45, 440)
>> pyprobe.sizeStr(12345678.99)
'11.8 MB'

Data format

{
    "path": str,
    "bit_rate": int,
    "duration": float,
    "size": int,
    "videos": [
        {
            "aspect_ratio": str,
            "bit_rate": int,
            "codec": str,
            "format": str,
            "framerate": float,
            "pixel_format": str,
            "resolution": (
                int # Width,
                int # Height
            )
        }
    ],
    "audios": [
        {
            "bit_rate": int,
            "channel_count": int,
            "channel_layout": str,
            "codec": str,
            "format": str,
            "sample_rate": int # Hz
        }
    ],
    "subtitles": [
        {
            "codec": str,
            "language": str
        }
    ],
    "chapters": [
        {
            "title": str,
            "start": float,
            "end": float,
        }
    ]
}

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

PyProbe-0.1.2.tar.gz (7.6 kB view details)

Uploaded Source

File details

Details for the file PyProbe-0.1.2.tar.gz.

File metadata

  • Download URL: PyProbe-0.1.2.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.8

File hashes

Hashes for PyProbe-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3c4b0b7cb008851f3bd2629702bcf54f62d5284ee0556069cdbf1097f6866ce9
MD5 d292430af09752669a41707a84a652bd
BLAKE2b-256 cd0a60e89a889adf6e43667eac62d055930507b9b5f5cce8418d1ca210e10699

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