Package: audio-extract
Audio Extractaudio-extract is a Python library that allows you to extract audio from video files and trim the audio according to your
needsDescriptionaudio-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.InstallingInstall from Pypi:pipinstallaudio-extractInstall from GitHub:pipinstallgit+https://github.com/riad-azz/audio-extract.gitGetting StartedAudioExtract - InfoThe application is pretty straightforward all you need is to import theextract_audiofunction. The function args:input_path: The path to the input (Video/Audio) file.output_path: The path to the extracted audio file. The default value is./audio.mp3.output_format: The format of the extracted audio. The default value ismp3.start_time: The start time of the output inHH:MM:SSorMM:SSformat. The default value is00:00:00.duration: The duration of the extracted audio in seconds(float). The default value isNonewhich means
full audio will be extracted ifstart_timeis set to00:00:00.overwrite: Whether to overwrite the output file if it already exists or not. The default value isFalse.The supported file formats:Supported audio formats :WAV, OGG, MP3, AAC, FLAC, M4A, OGA, OPUSSupported video formats :MP4, MKV, WEBM, FLV, AVI, MOV, WMV, M4VExecuting the programExtract full audio:fromaudio_extractimportextract_audioextract_audio(input_path="./video.mp4",output_path="./audio.mp3")This will create amp3file calledaudio.mp3that contains the full audio of the video filevideo.mp4.Extract sub clip audio:fromaudio_extractimportextract_audioextract_audio(input_path="./video.mp4",output_path="./audio.mp3",start_time="00:30",overwrite=True)This will create amp3file calledaudio.mp3that starts after the first 30 seconds of the video filevideo.mp4and will overwriteaudio.mp3file if it already exists.Extract sub clip audio with custom durationfromaudio_extractimportextract_audioextract_audio(input_path="./video.mp4",output_path="./audio.mp3",start_time="00:25",duration=15.0)This will convert video filevideo.mp4to a mp3 file starting from00:25to00:40calledaudio.mp3that will have a duration of00:15.Trim audio:fromaudio_extractimportextract_audioextract_audio(input_path="./audio.mp3",output_path="./new_audio.mp3",start_time="00:05",duration=20.0)This will trim theaudio.mp3file starting from00:05to00:25to amp3file callednew_audio.mp3that will
have a duration of00:20.Running Command-Line-InterfaceCLI ArgumentsThe following cli arguments are supported:--inputor-i: The path to the input (Video/Audio) file.--outputor-o: The path to the extracted audio file. The default value is./audio.mp3.--formator-f: The format of the extracted audio. The default value ismp3.--start-timeor-st: The start time of the output inHH:MM:SSorMM:SSformat. The default value
is00:00:00.--durationor-d: The duration of the extracted audio in seconds(float), The default value isNonewhich means full audio will be extracted ifstart_timeis set to00:00:00.--overwriteor-ow: Whether to overwrite the output file if it already exists or not. The default value
isFalse.CLI Usage Example:Here is an example of using the CLI to extract audio:audio-extract--input="./video.mp4"--output="./audios/extracted_audio.wav"--format="wav"This command will extract the full audio starting fromvideo.mp4to awavfile calledextracted_audio.wavand will
be saved to the folder./audios/. The folder will be automatically created if it doesn't exist.AuthorsRiadh Azzoun -@riad-azzLicenseThis project is licensed under the [MIT] License - see the LICENSE.md file for details