A library for asynchronous operation with FFmpeg, providing the ability to track events such as start, end, and encoding progress.
Project description
AsyFFmpeg
AsyFFmpeg is a Python library for interacting asynchronously with FFmpeg to perform various operations on media files.
Note: When coding links, photos and more, the progress event will not work. Progress is available only when encoding a local video file
Installation
To install AsyFFmpeg, run the following command:
pip install asyffmpeg
pip install -r requirements.txt --upgrade
Usage
An example of how to use the library:
import asyncio
from datetime import timedelta
from asyffmpeg import AsyFFmpeg
async def start(input:str, output:str):
print(f'[start]: {input} -> {output}')
async def end(encoding_time:timedelta):
print(f'[end]: {encoding_time}')
async def progress(progress:float, elapsed_time:timedelta, remaining_time:timedelta,
frame:int, is_finished:bool, bitrate:float):
print(f'#{frame} | [{progress}] [{elapsed_time}] [{bitrate}]: [{remaining_time}] [?:{is_finished}]')
async def encode_video():
ffmpeg = AsyFFmpeg(debug=False)
ffmpeg.input("input.mp4")
ffmpeg.output("output.mp4")
ffmpeg.args({'vf': 'scale=1920:1080', 'codec:a': 'aac'})
ffmpeg.on_event('start', start)
ffmpeg.on_event('end', end)
ffmpeg.on_event('progress', progress)
await ffmpeg.run()
asyncio.run(encode_video())
Features
- Asynchronous interface for interacting with FFmpeg.
- User-friendly API for controlling video and audio encoding.
- Support for various FFmpeg parameters and filters.
- Support for events such as
progress
,start
andend
.
License
AsyFFmpeg is distributed under the MIT license.
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
asyffmpeg-0.2.3.tar.gz
(6.7 kB
view hashes)
Built Distribution
Close
Hashes for asyffmpeg-0.2.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6e6aae039ecbca7d027d0743ef30638f352a01066c0508bf5ec552510999f57 |
|
MD5 | 11211ab7cfc02f71475780668d2b814c |
|
BLAKE2b-256 | 0066e31fd54a52cf2b5f2c5d2a1d4c70a616b2acf885887b853ad605eaa3d644 |