{"id":15010008,"url":"https://github.com/livingbio/ffmpeg-media-type","last_synced_at":"2025-04-09T18:05:42.063Z","repository":{"id":180033741,"uuid":"664285941","full_name":"livingbio/ffmpeg-media-type","owner":"livingbio","description":"ffmpeg-media-type is a Python library that utilizes FFmpeg to detect various media file information, such as duration, width, and height. This library provides an easy-to-use interface for extracting essential details from media files by leveraging the powerful capabilities of FFmpeg.","archived":false,"fork":false,"pushed_at":"2025-03-31T19:50:51.000Z","size":58297,"stargazers_count":5,"open_issues_count":6,"forks_count":1,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-03T00:04:02.642Z","etag":null,"topics":["audio","ffmpeg","ffprobe","fileextension","image","mimetype","mov","mp3","mp4","python","python-3","video","webm"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/livingbio.png","metadata":{"files":{"readme":"README.ipynb","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":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-09T13:58:42.000Z","updated_at":"2025-03-31T19:50:48.000Z","dependencies_parsed_at":"2025-02-15T11:32:11.219Z","dependency_job_id":"d270b23f-b4c3-4536-84cf-008a4ff1c124","html_url":"https://github.com/livingbio/ffmpeg-media-type","commit_stats":null,"previous_names":["livingbio/ffmpeg-media-type"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livingbio%2Fffmpeg-media-type","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livingbio%2Fffmpeg-media-type/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livingbio%2Fffmpeg-media-type/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livingbio%2Fffmpeg-media-type/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/livingbio","download_url":"https://codeload.github.com/livingbio/ffmpeg-media-type/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248084293,"owners_count":21045124,"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":["audio","ffmpeg","ffprobe","fileextension","image","mimetype","mov","mp3","mp4","python","python-3","video","webm"],"created_at":"2024-09-24T19:29:31.233Z","updated_at":"2025-04-09T18:05:42.036Z","avatar_url":"https://github.com/livingbio.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"# ffmpeg-media-type\\n\",\n    \"\\n\",\n    \"`ffmpeg-media-type` is a Python library that utilizes FFmpeg to detect various media file information, such as duration, width, and height. This library provides an easy-to-use interface for extracting essential details from media files by leveraging the powerful capabilities of FFmpeg.\\n\",\n    \"\\n\",\n    \"[![CI](https://github.com/livingbio/ffmpeg-media-type/workflows/python-unittest/badge.svg?branch=main)](https://github.com/livingbio/ffmpeg-media-type/actions?query=workflow%3Apython-unittest++branch%3Amain++)\\n\",\n    \"[![codecov](https://codecov.io/gh/livingbio/ffmpeg-media-type/graph/badge.svg?token=B95PR629LP)](https://codecov.io/gh/livingbio/ffmpeg-media-type)\\n\",\n    \"[![pypi](https://img.shields.io/pypi/v/ffmpeg-media-type.svg)](https://pypi.python.org/pypi/ffmpeg-media-type)\\n\",\n    \"[![downloads](https://pepy.tech/badge/ffmpeg-media-type/month)](https://pepy.tech/project/ffmpeg-media-type)\\n\",\n    \"[![versions](https://img.shields.io/pypi/pyversions/ffmpeg-media-type.svg)](https://github.com/livingbio/ffmpeg-media-type)\\n\",\n    \"[![license](https://img.shields.io/github/license/livingbio/ffmpeg-media-type.svg)](https://github.com/livingbio/ffmpeg-media-type/blob/main/LICENSE)\\n\",\n    \"[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)\\n\",\n    \"[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\\n\",\n    \"[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat\u0026labelColor=ef8336)](https://pycqa.github.io/isort/)\\n\",\n    \"\\n\",\n    \"\\n\",\n    \"\\n\",\n    \"### Table of Contents\\n\",\n    \"\\n\",\n    \"- [Documentation](https://livingbio.github.io/ffmpeg-media-type/)\\n\",\n    \"\\n\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"\\n\",\n    \"## Installation\\n\",\n    \"\\n\",\n    \"You can install `ffmpeg-media-type` via pip:\\n\",\n    \"\\n\",\n    \"```bash\\n\",\n    \"pip install ffmpeg-media-type\\n\",\n    \"```\\n\",\n    \"\\n\",\n    \"Note: FFmpeg must be installed on your system for this library to function correctly. Make sure you have FFmpeg installed and added to your system's PATH.\\n\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"\\n\",\n    \"## Usage\\n\",\n    \"\\n\",\n    \"To use `ffmpeg-media-type`, first import the library:\\n\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 7,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"import ffmpeg_media_type\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"\\n\",\n    \"### Detecting Media File Information\\n\",\n    \"\\n\",\n    \"To detect media file information, use the `detect` function, providing the path to the media file as a parameter:\\n\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 8,\n   \"metadata\": {},\n   \"outputs\": [\n    {\n     \"data\": {\n      \"text/plain\": [\n       \"MediaInfo(type='image', width=163, height=117, duration=None, format='png_pipe', size=2212, suggest_ext='png')\"\n      ]\n     },\n     \"execution_count\": 8,\n     \"metadata\": {},\n     \"output_type\": \"execute_result\"\n    }\n   ],\n   \"source\": [\n    \"\\n\",\n    \"media_info = ffmpeg_media_type.detect('https://raw.githubusercontent.com/livingbio/ffmpeg-media-type/main/docs/media/overlay.png')\\n\",\n    \"media_info\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"\\n\",\n    \"The `detect` function returns a model containing the following information:\\n\",\n    \"\\n\",\n    \"- `type`: The type of media file (e.g. `video`, `audio`, `image`, etc.).\\n\",\n    \"- `duration`: The duration of the media file in seconds.\\n\",\n    \"- `width`: The width of the media file in pixels.\\n\",\n    \"- `height`: The height of the media file in pixels.\\n\",\n    \"- `format`: The format of the media file (e.g. `mp4`, `mp3`, `png`, etc.).\\n\",\n    \"- `size`: The size of the media file in bytes.\\n\",\n    \"- `suggest_ext`: The suggested file extension for the media file (e.g. `mp4`, `mp3`, `png`, etc.).\\n\",\n    \"\\n\",\n    \"Here's an example of how to access these details:\\n\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 9,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"duration = media_info.duration\\n\",\n    \"width = media_info.width\\n\",\n    \"height = media_info.height\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"### Example\\n\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 10,\n   \"metadata\": {},\n   \"outputs\": [\n    {\n     \"name\": \"stdout\",\n     \"output_type\": \"stream\",\n     \"text\": [\n      \"Duration: 5.312 seconds\\n\",\n      \"Width: 1280 pixels\\n\",\n      \"Height: 720 pixels\\n\"\n     ]\n    }\n   ],\n   \"source\": [\n    \"import ffmpeg_media_type\\n\",\n    \"\\n\",\n    \"# Specify the path to the media file\\n\",\n    \"file_path = 'https://raw.githubusercontent.com/livingbio/ffmpeg-media-type/main/docs/media/SampleVideo_1280x720_1mb.mp4'\\n\",\n    \"\\n\",\n    \"# Detect media file information\\n\",\n    \"media_info = ffmpeg_media_type.detect(file_path)\\n\",\n    \"\\n\",\n    \"# Extract information from the media_info dictionary\\n\",\n    \"duration = media_info.duration\\n\",\n    \"width = media_info.width\\n\",\n    \"height = media_info.height\\n\",\n    \"\\n\",\n    \"# Print the extracted information\\n\",\n    \"print(f\\\"Duration: {duration} seconds\\\")\\n\",\n    \"print(f\\\"Width: {width} pixels\\\")\\n\",\n    \"print(f\\\"Height: {height} pixels\\\")\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"\\n\",\n    \"### Enhancing Accuracy in Guessing Media File Extensions with FFmpeg\\n\",\n    \"\\n\",\n    \"- Typically, the media file's extension is utilized to determine its file type. Nevertheless, this approach may not always yield accurate results. For instance, a file bearing the `.mp4` extension could, in reality, be an audio file.\\n\",\n    \"- The `ffmpeg-media-type` tool enhances the precision of media file extension guessing by leveraging the built-in format functionality of FFmpeg through the command `ffmpeg -formats`.\\n\",\n    \"\\n\",\n    \"check [cache](https://github.com/livingbio/ffmpeg-media-type/tree/main/src/ffmpeg_media_type/cache) for details.\\n\",\n    \"\\n\",\n    \"### Access ffprobe output\\n\",\n    \"\\n\",\n    \"If you need to access the raw ffprobe output, you can use the `ffprobe` function:\\n\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 12,\n   \"metadata\": {},\n   \"outputs\": [\n    {\n     \"data\": {\n      \"text/plain\": [\n       \"FFProbeInfo(format=FFProbeFormat(filename='https://raw.githubusercontent.com/livingbio/ffmpeg-media-type/main/docs/media/SampleVideo_1280x720_1mb.mp4', duration='5.312000', format_name='mov,mp4,m4a,3gp,3g2,mj2', format_long_name='QuickTime / MOV', start_time='0.000000', size='1055736', probe_score=100), streams=(FFProbeStream(index=0, width=1280, height=720, codec_type='video', codec_name='h264', codec_long_name='H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10', profile='Main', pix_fmt='yuv420p', r_frame_rate='25/1', tags=FFProbeStreamTags(rotate=0)), FFProbeStream(index=1, width=None, height=None, codec_type='audio', codec_name='aac', codec_long_name='AAC (Advanced Audio Coding)', profile='LC', pix_fmt=None, r_frame_rate='0/0', tags=FFProbeStreamTags(rotate=0))))\"\n      ]\n     },\n     \"execution_count\": 12,\n     \"metadata\": {},\n     \"output_type\": \"execute_result\"\n    }\n   ],\n   \"source\": [\n    \"ffprobe_output = ffmpeg_media_type.ffprobe('https://raw.githubusercontent.com/livingbio/ffmpeg-media-type/main/docs/media/SampleVideo_1280x720_1mb.mp4')\\n\",\n    \"\\n\",\n    \"ffprobe_output\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"## Contributing\\n\",\n    \"\\n\",\n    \"Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open an issue on the [GitHub repository](https://github.com/livingbio/ffmpeg-media-type/issues). If you would like to contribute code, please fork the repository and submit a pull request.\\n\",\n    \"\\n\",\n    \"Before submitting a pull request, make sure to run the tests using the following command:\\n\",\n    \"\\n\",\n    \"```bash\\n\",\n    \"poetry install --with dev\\n\",\n    \"py.test src\\n\",\n    \"```\\n\",\n    \"\\n\",\n    \"Please ensure that your code follows the established coding style and passes all tests.\\n\",\n    \"\\n\",\n    \"## License\\n\",\n    \"\\n\",\n    \"This project is licensed under the MIT License. See the [LICENSE](https://github.com/livingbio/ffmpeg-media-type/blob/main/LICENSE) file for more information.\"\n   ]\n  }\n ],\n \"metadata\": {\n  \"kernelspec\": {\n   \"display_name\": \".venv\",\n   \"language\": \"python\",\n   \"name\": \"python3\"\n  },\n  \"language_info\": {\n   \"codemirror_mode\": {\n    \"name\": \"ipython\",\n    \"version\": 3\n   },\n   \"file_extension\": \".py\",\n   \"mimetype\": \"text/x-python\",\n   \"name\": \"python\",\n   \"nbconvert_exporter\": \"python\",\n   \"pygments_lexer\": \"ipython3\",\n   \"version\": \"3.11.7\"\n  }\n },\n \"nbformat\": 4,\n \"nbformat_minor\": 2\n}\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flivingbio%2Fffmpeg-media-type","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flivingbio%2Fffmpeg-media-type","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flivingbio%2Fffmpeg-media-type/lists"}