Extract and trim audio from videos or trim audios.
Project description
Audio Extract
audio-extract is a Python library that allows you to extract audio from video files and trim the audio according to your needs
Description
audio-extract is a Python library that allows you to extract audio from video files and trim the audio according to your needs. You can use it to create audio clips from movies, podcasts, or any other video source. It supports various audio and video formats, such as MP3, WAV, OGG, MP4, AVI, and MKV.
Installing
pip install audio-extract
Executing the program
Extract full audio
import audio_extract
audio_extract.run(input_path="./video.mp4", output_path="./audio.mp3")
This will create a mp3 file called audio.mp3
that contains the full audio of the video file video.mp4
.
Extract sub clip audio
import audio_extract
audio_extract.run(input_path="./video.mp4", output_path="./audio.mp3", start_time="00:30")
This will create a mp3 file called audio.mp3
that starts after the first 30 seconds of the video file video.mp4
.
Extract sub clip audio with custom duration
import audio_extract
audio_extract.run(input_path="./video.mp4", output_path="./audio.mp3", start_time="00:25", duration="01:15")
This will convert video file video.mp4
to a mp3 file starting from 00:25
to 01:15
called audio.mp3
that will have a duration of 00:50
.
Trim audio
import audio_extract
audio_extract.run(input_path="./audio.mp3", output_path="./new_audio.mp3", start_time="00:05", duration="01:15")
This will trim the audio.mp3
file starting from 00:05
to 01:15
to a mp3 file called new_audio.mp3
that will
have a duration of 01:10
.
Running Command-Line-Interface
CLI Arguments
The following cli arguments are supported:
--input
or-i
The path to the video/audio input file.
--output
or-o
The path to the mp3 output file. The default value is ./audio.mp3
.
--start
or-s
The start time of the output in HH:MM:SS
or MM:SS
format. The default value is 00:00
.
--duration
or-d
The duration of the output in HH:MM:SS
or MM:SS
format.
Extract full audio
audio-extract --input video.mp4 --output audio.mp3
This command will create a mp3 file called audio.mp3
that contains the full audio of the video file video.mp4
.
Extract sub clip audio
audio-extract --input video.mp4 --output audio.mp3 --start 00:00:30
This would create a mp3 file called audio.mp3
that starts after the first 30 seconds of the video file video.mp4
.
Extract sub clip audio with custom duration
audio-extract --input video.mp4 --output audio.mp3 --start '00:25' --duration '01:15'
This command will convert video file video.mp4
to a mp3 file starting from 00:25
to 01:15
called audio.mp3
that will have a duration of 00:50
.
Trim audio
audio-extract --input audio.mp3 --output new_audio.mp3 --start '00:05' --duration '01:15'
This command trim the audio starting from 00:05
to 01:15
of the file audio.mp3
to a mp3 file
called new_audio.mp3
that will have a duration of 01:10
.
Authors
Riadh Azzoun - @riad-azz
License
This project is licensed under the [MIT] License - see the LICENSE.md file for details
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 audio_extract-0.3.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f543a6f5c6afe93c8ad5a835aea94c30f6df1ac0446687643f6fd24c5c05f55d |
|
MD5 | a641d5a057597a464327f85a6e28c6f2 |
|
BLAKE2b-256 | 8d685be92773957faad54974c6f3c84533b6e4e950b6d39a8fc56cf0afd14ab1 |