No project description provided
Project description
ffmpeg-media-type
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.
Installation
You can install ffmpeg-media-type
via pip:
pip install ffmpeg-media-type
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.
Usage
To use ffmpeg-media-type
, first import the library:
import ffmpeg_media_type
Detecting Media File Information
To detect media file information, use the detect
function, providing the path to the media file as a parameter:
media_info = ffmpeg_media_type.info.detect('/path/to/media/file.mp4')
The detect
function returns a model containing the following information:
type
: The type of media file (e.g.video
,audio
,image
, etc.).duration
: The duration of the media file in seconds.width
: The width of the media file in pixels.height
: The height of the media file in pixels.format
: The format of the media file (e.g.mp4
,mp3
,png
, etc.).size
: The size of the media file in bytes.suggest_ext
: The suggested file extension for the media file (e.g.mp4
,mp3
,png
, etc.).
Here's an example of how to access these details:
duration = media_info.duration
width = media_info.width
height = media_info.height
Example
import ffmpeg_media_type
# Specify the path to the media file
file_path = '/path/to/media/file.mp4'
# Detect media file information
media_info = ffmpeg_media_type.info.detect(file_path)
# Extract information from the media_info dictionary
duration = media_info.duration
width = media_info.width
height = media_info.height
# Print the extracted information
print(f"Duration: {duration} seconds")
print(f"Width: {width} pixels")
print(f"Height: {height} pixels")
Contributing
Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open an issue on the GitHub repository. If you would like to contribute code, please fork the repository and submit a pull request.
Before submitting a pull request, make sure to run the tests using the following command:
poetry install --with test
py.test src
Please ensure that your code follows the established coding style and passes all tests.
License
This project is licensed under the MIT License. See the LICENSE file for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for ffmpeg_media_type-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fede6f3acbc38d9a1d0d05a39918cb87282ee4d24de26d5a8cfd71ea358388d2 |
|
MD5 | 53a6ee77af23f238ddcbd4822cc90bc2 |
|
BLAKE2b-256 | 0f9b958cf90905b562b90f4c2258f8c141200059fc716db8cd66fa22690c020c |