{"id":13827594,"url":"https://github.com/sbraz/pymediainfo","last_synced_at":"2025-04-13T20:19:13.456Z","repository":{"id":848141,"uuid":"576113","full_name":"sbraz/pymediainfo","owner":"sbraz","description":"A Python wrapper around the MediaInfo library","archived":false,"fork":false,"pushed_at":"2025-02-12T20:28:53.000Z","size":740,"stargazers_count":326,"open_issues_count":12,"forks_count":58,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-04-06T23:31:34.401Z","etag":null,"topics":["mediainfo","python"],"latest_commit_sha":null,"homepage":"https://pymediainfo.readthedocs.org/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sbraz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2010-03-23T18:15:52.000Z","updated_at":"2025-04-01T07:50:14.000Z","dependencies_parsed_at":"2023-10-29T14:33:11.199Z","dependency_job_id":"130f1aa6-2478-4fc7-9707-a70749d636a6","html_url":"https://github.com/sbraz/pymediainfo","commit_stats":{"total_commits":256,"total_committers":16,"mean_commits":16.0,"dds":0.234375,"last_synced_commit":"2a4650ece0534b68a22e01c34f9bc179001a2ec4"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbraz%2Fpymediainfo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbraz%2Fpymediainfo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbraz%2Fpymediainfo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbraz%2Fpymediainfo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sbraz","download_url":"https://codeload.github.com/sbraz/pymediainfo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248775278,"owners_count":21159581,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mediainfo","python"],"created_at":"2024-08-04T09:02:02.738Z","updated_at":"2025-04-13T20:19:13.436Z","avatar_url":"https://github.com/sbraz.png","language":"Python","funding_links":[],"categories":["Python","HarmonyOS","Media Tools"],"sub_categories":["Windows Manager","Metadata Extraction \u0026 Management"],"readme":"# pymediainfo\n\n[![PyPI](https://img.shields.io/pypi/v/pymediainfo.svg)](https://pypi.org/project/pymediainfo)\n[![Supported Python versions](https://img.shields.io/pypi/pyversions/pymediainfo.svg)](https://pypi.org/project/pymediainfo)\n[![Repology info](https://repology.org/badge/tiny-repos/python%3Apymediainfo.svg)](https://repology.org/project/python%3Apymediainfo/versions)\n[![GitHub](https://img.shields.io/github/stars/sbraz/pymediainfo)](https://github.com/sbraz/pymediainfo)\n[![Build status](https://ci.appveyor.com/api/projects/status/g15a2daem1oub57n/branch/master?svg=true)](https://ci.appveyor.com/project/sbraz/pymediainfo)\n\npymediainfo is a wrapper for [the MediaInfo library](https://mediaarea.net/en/MediaInfo). It makes it easy to\nextract detailed information from multimedia files.\n\n## Compatibility\n\npymediainfo is compatible with the following:\n\n* **Platforms**: **Linux**, **macOS** and **Windows**.\n* **Python Versions**: Tested with Python **3.9** (the minimum required version) to **3.13**, as well as **PyPy3**.\n\n## Installation\n\nPlease note that, without [the MediaInfo library](https://mediaarea.net/en/MediaInfo), pymediainfo\n**cannot parse media files**. This severely limits its functionality, allowing it to process\nonly pre-generated XML output from MediaInfo.\n\n### Linux distribution Packages\n\nPackages are available for [most major Linux distributions](https://repology.org/project/python%3Apymediainfo/versions).\nThey often depend on the MediaInfo library and are the preferred way to\ninstall pymediainfo on Linux, as they allow for independent updates to pymediainfo and the MediaInfo library itself.\n\n### PyPI on Linux, macOS and Windows\n\nIf pymediainfo is not available for your Linux distribution, or if you're running macOS or Windows,\nyou can install it from PyPI:\n```\npython -m pip install pymediainfo\n```\n\n**Wheels** containing a bundled version of the MediaInfo library are available for:\n\n* Linux x86-64 and ARM64.\n* macOS x86-64 and ARM64.\n* Windows x86-64 and x86.\n\nIf you do not want to use the wheels (for instance if you want to use the system-wide\nMediaInfo library instead of the bundled one):\n```\npython -m pip install pymediainfo --no-binary pymediainfo\n```\n\n## Usage\n\nHere are a few examples demonstrating how to use pymediainfo.\n### Getting information from an image\nThe `MediaInfo` class provides a `parse()` method which takes paths as input and returns `MediaInfo` objects.\n#### Example snippet\n\n```py\nfrom pymediainfo import MediaInfo\n\nmedia_info = MediaInfo.parse(\"/home/user/image.jpg\")\n# Tracks can be accessed using the 'tracks' attribute or through shorthands\n# such as 'image_tracks', 'audio_tracks', 'video_tracks', etc.\ngeneral_track = media_info.general_tracks[0]\nimage_track = media_info.image_tracks[0]\nprint(\n  f\"{image_track.format} of {image_track.width}×{image_track.height} pixels\"\n  f\" and {general_track.file_size} bytes.\"\n)\n```\n\n#### Example output\n\n```text\nJPEG of 828×828 pixels and 19098 bytes.\n```\n\n### Getting information from a video\n\nIn this example, we take advantage of the `to_data()` method, which returns a `dict` containing  all\nattributes from a `MediaInfo` or `Track` object. This makes it\neasier to inspect tracks even when their attributes are unknown.\n\n#### Example snippet\n\n```py\nfrom pprint import pprint\nfrom pymediainfo import MediaInfo\n\nmedia_info = MediaInfo.parse(\"my_video_file.mp4\")\nfor track in media_info.tracks:\n    if track.track_type == \"Video\":\n        print(f\"Bit rate: {track.bit_rate}, Frame rate: {track.frame_rate}, Format: {track.format}\")\n        print(\"Duration (raw value):\", track.duration)\n        print(\"Duration (other values:\")\n        pprint(track.other_duration)\n    elif track.track_type == \"Audio\":\n        print(\"Track data:\")\n        pprint(track.to_data())\n```\n\n#### Example output\n\n```text\nBit rate: 3117597, Frame rate: 23.976, Format: AVC\nDuration (raw value): 958\nDuration (other values):\n['958 ms',\n'958 ms',\n'958 ms',\n'00:00:00.958',\n'00:00:00;23',\n'00:00:00.958 (00:00:00;23)']\nTrack data:\n{'bit_rate': 236392,\n'bit_rate_mode': 'VBR',\n'channel_layout': 'L R',\n'channel_positions': 'Front: L R',\n'channel_s': 2,\n'codec_id': 'mp4a-40-2',\n'commercial_name': 'AAC',\n'compression_mode': 'Lossy',\n…\n}\n```\n\n### Accessing Track attributes\n\nSince the attributes from a `Track` are dynamically created during parsing, there isn't a firm definition\nof what will be available at runtime.\n\nIn order to make consuming objects easier, the `__getattribute__` method from `Track` objects\nhas been overridden to return `None` when a non-existent attribute is accessed, instead of raising `AttributeError`.\n\n#### Example snippet\n```py\nfrom pymediainfo import MediaInfo\n\nmedia_info = MediaInfo.parse(\"my_video_file.mp4\")\nfor track in media_info.tracks:\n    if track.bit_rate is None:\n        print(f\"{track.track_type} tracks do not have a bit rate associated with them\")\n    else:\n        print(f\"Track {track.track_id} of type {track.track_type} has a bit rate of {track.bit_rate} b/s\")\n```\n\n#### Example output\n\n```text\nGeneral tracks do not have a bit rate associated with them\nTrack 1 of type Video has a bit rate of 4398075 b/s\nTrack 2 of type Audio has a bit rate of 131413 b/s\nMenu tracks do not have a bit rate associated with them\n```\n\n\n### Parsing pre-generated MediaInfo XML output\npymediainfo relies on MediaInfo's `OLDXML` output to create `MediaInfo` objects.\n\nIt is possible to create a `MediaInfo` object from an existing XML string. For\ninstance if someone sent you the output of `mediainfo --output=OLDXML`, you can\ncall the `MediaInfo` constructor directly.\n\n#### Example snippet\n```py\nfrom pymediainfo import MediaInfo\n\nraw_xml_string = \"\"\"\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cMediainfo version=\"24.11\"\u003e\n\u003cFile\u003e\n\u003ctrack type=\"General\"\u003e\n\u003cComplete_name\u003ebinary_file\u003c/Complete_name\u003e\n\u003cFile_size\u003e1.00 Byte\u003c/File_size\u003e\n\u003c/track\u003e\n\u003c/File\u003e\n\u003c/Mediainfo\u003e\"\"\"\nmedia_info = MediaInfo(raw_xml_string)\nprint(f\"File name is: {media_info.general_tracks[0].complete_name}\")\n```\n\n#### Example output\n```text\nFile name is: binary_file\n```\n\n### Text output (à la `mediainfo`)\n\nIf you want a text report, similar to what `mediainfo my_video_file.mp4` outputs,\nuse the `output=\"text\"` argument with the `parse()` method. In this case, it\nwill return a string, not a `MediaInfo` object.\n\n#### Example snippet\n```py\nfrom pymediainfo import MediaInfo\n\n# To mirror a simple call to \"mediainfo\" without the \"--Full\" or \"-f\" option, we\n# set \"full=False\". Leaving it at the default of \"full=True\" would result in\n# more verbose output.\nprint(MediaInfo.parse(\"my_video_file.mp4\", output=\"text\", full=False))\n```\n\n#### Example output\n```text\nGeneral\nComplete name                            : my_video_file.mp4\nFormat                                   : MPEG-4\nFormat profile                           : Base Media\n[…]\n```\n\n## Documentation\n\nFor more detailed information, please refer to the reference documentation\navailable at \u003chttps://pymediainfo.readthedocs.io/\u003e.\n\n## Issues and Questions\nFor feature requests and bug reports, please use the GitHub issue tracker at\n\u003chttps://github.com/sbraz/pymediainfo/issues\u003e.\n\nIf you have any questions, feel free to ask in the discussions at\n\u003chttps://github.com/sbraz/pymediainfo/discussions\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbraz%2Fpymediainfo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsbraz%2Fpymediainfo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbraz%2Fpymediainfo/lists"}