audio-extract


Nameaudio-extract JSON
Version 0.6.0 PyPI version JSON
download
home_pagehttps://github.com/riad-azz/audio-extract
SummaryExtract and trim audio from videos or trim audios.
upload_time2023-10-19 15:04:11
maintainer
docs_urlNone
authorriad-azz
requires_python
licenseMIT License
keywords convert video audio ffmpeg video to mp3
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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

- Install from Pypi:

```bash
pip install audio-extract
```

- Install from GitHub:

```bash
pip install git+https://github.com/riad-azz/audio-extract.git
```

## Getting Started

### AudioExtract - Info

The application is pretty straightforward all you need is to import the `extract_audio` function. 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 is `mp3`.

* **`start_time`**: The start time of the output in `HH:MM:SS` or `MM:SS` format. The default value is `00:00:00`.

* **`duration`**: The duration of the extracted audio in seconds _(float)_. The default value is  `None` which means
  full audio will be extracted if `start_time` is set to `00:00:00`.

* **`overwrite`**: Whether to overwrite the output file if it already exists or not. The default value is `False`.

The supported file formats:

- Supported audio formats : `WAV, OGG, MP3, AAC, FLAC, M4A, OGA, OPUS`

- Supported video formats : `MP4, MKV, WEBM, FLV, AVI, MOV, WMV, M4V`

### Executing the program

#### Extract full audio:

```python
from audio_extract import extract_audio

extract_audio(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:

```python
from audio_extract import extract_audio

extract_audio(input_path="./video.mp4",
              output_path="./audio.mp3",
              start_time="00:30",
              overwrite=True)
```

This will create a `mp3` file called `audio.mp3` that starts after the first 30 seconds of the video file `video.mp4`
and will overwrite `audio.mp3` file if it already exists.

#### Extract sub clip audio with custom duration

```python
from audio_extract import extract_audio

extract_audio(input_path="./video.mp4",
              output_path="./audio.mp3",
              start_time="00:25",
              duration=15.0)
```

This will convert video file `video.mp4` to a mp3 file starting from `00:25` to `00:40`
called `audio.mp3` that will have a duration of `00:15`.

#### Trim audio:

```python
from audio_extract import extract_audio

extract_audio(input_path="./audio.mp3",
              output_path="./new_audio.mp3",
              start_time="00:05",
              duration=20.0)
```

This will trim the `audio.mp3` file starting from `00:05` to `00:25` to a `mp3` file called `new_audio.mp3` that will
have a duration of `00:20`.

## Running Command-Line-Interface

### CLI Arguments

The following cli arguments are supported:

* **`--input`** or **`-i`** : The path to the input (Video/Audio) file.

* **`--output`** or **`-o`** : The path to the extracted audio file. The default value is `./audio.mp3`.

* **`--format`** or **`-f`** : The format of the extracted audio. The default value is `mp3`.

* **`--start-time`** or **`-st`** : The start time of the output in `HH:MM:SS` or `MM:SS` format. The default value
  is `00:00:00`.

* **`--duration`** or **`-d`** : The duration of the extracted audio in seconds _(float)_, The default value is `None`
  which means full audio will be extracted if `start_time` is set to `00:00:00`.

* **`--overwrite`** or **`-ow`** : Whether to overwrite the output file if it already exists or not. The default value
  is `False`.

### CLI Usage Example:

Here is an example of using the CLI to extract audio:

```bash
audio-extract --input="./video.mp4" --output="./audios/extracted_audio.wav" --format="wav"
```

This command will extract the full audio starting from `video.mp4` to a `wav` file called `extracted_audio.wav` and will
be saved to the folder `./audios/`. The folder will be automatically created if it doesn't exist.

## Authors

Riadh Azzoun - [@riad-azz](https://github.com/riad-azz)

## License

This project is licensed under the [MIT] License - see the LICENSE.md file for details

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/riad-azz/audio-extract",
    "name": "audio-extract",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "convert video,audio,ffmpeg,video to mp3",
    "author": "riad-azz",
    "author_email": "riadh.azzoun@hotmail.com",
    "download_url": "https://files.pythonhosted.org/packages/7c/45/7ea6ef6885ef0c979280f2e6ad465847dfd9d4ebc93c7e09e2200f88267f/audio_extract-0.6.0.tar.gz",
    "platform": null,
    "description": "# Audio Extract\r\n\r\naudio-extract is a Python library that allows you to extract audio from video files and trim the audio according to your\r\nneeds\r\n\r\n## Description\r\n\r\naudio-extract is a Python library that allows you to extract audio from video files and trim the audio according to your\r\nneeds. You can use it to create audio clips from movies, podcasts, or any other video source. It supports various audio\r\nand video formats, such as MP3, WAV, OGG, MP4, AVI, and MKV.\r\n\r\n## Installing\r\n\r\n- Install from Pypi:\r\n\r\n```bash\r\npip install audio-extract\r\n```\r\n\r\n- Install from GitHub:\r\n\r\n```bash\r\npip install git+https://github.com/riad-azz/audio-extract.git\r\n```\r\n\r\n## Getting Started\r\n\r\n### AudioExtract - Info\r\n\r\nThe application is pretty straightforward all you need is to import the `extract_audio` function. The function args:\r\n\r\n* **`input_path`** : The path to the input (Video/Audio) file.\r\n\r\n* **`output_path`**: The path to the extracted audio file. The default value is `./audio.mp3`.\r\n\r\n* **`output_format`**: The format of the extracted audio. The default value is `mp3`.\r\n\r\n* **`start_time`**: The start time of the output in `HH:MM:SS` or `MM:SS` format. The default value is `00:00:00`.\r\n\r\n* **`duration`**: The duration of the extracted audio in seconds _(float)_. The default value is  `None` which means\r\n  full audio will be extracted if `start_time` is set to `00:00:00`.\r\n\r\n* **`overwrite`**: Whether to overwrite the output file if it already exists or not. The default value is `False`.\r\n\r\nThe supported file formats:\r\n\r\n- Supported audio formats : `WAV, OGG, MP3, AAC, FLAC, M4A, OGA, OPUS`\r\n\r\n- Supported video formats : `MP4, MKV, WEBM, FLV, AVI, MOV, WMV, M4V`\r\n\r\n### Executing the program\r\n\r\n#### Extract full audio:\r\n\r\n```python\r\nfrom audio_extract import extract_audio\r\n\r\nextract_audio(input_path=\"./video.mp4\", output_path=\"./audio.mp3\")\r\n```\r\n\r\nThis will create a `mp3` file called `audio.mp3` that contains the full audio of the video file `video.mp4`.\r\n\r\n#### Extract sub clip audio:\r\n\r\n```python\r\nfrom audio_extract import extract_audio\r\n\r\nextract_audio(input_path=\"./video.mp4\",\r\n              output_path=\"./audio.mp3\",\r\n              start_time=\"00:30\",\r\n              overwrite=True)\r\n```\r\n\r\nThis will create a `mp3` file called `audio.mp3` that starts after the first 30 seconds of the video file `video.mp4`\r\nand will overwrite `audio.mp3` file if it already exists.\r\n\r\n#### Extract sub clip audio with custom duration\r\n\r\n```python\r\nfrom audio_extract import extract_audio\r\n\r\nextract_audio(input_path=\"./video.mp4\",\r\n              output_path=\"./audio.mp3\",\r\n              start_time=\"00:25\",\r\n              duration=15.0)\r\n```\r\n\r\nThis will convert video file `video.mp4` to a mp3 file starting from `00:25` to `00:40`\r\ncalled `audio.mp3` that will have a duration of `00:15`.\r\n\r\n#### Trim audio:\r\n\r\n```python\r\nfrom audio_extract import extract_audio\r\n\r\nextract_audio(input_path=\"./audio.mp3\",\r\n              output_path=\"./new_audio.mp3\",\r\n              start_time=\"00:05\",\r\n              duration=20.0)\r\n```\r\n\r\nThis will trim the `audio.mp3` file starting from `00:05` to `00:25` to a `mp3` file called `new_audio.mp3` that will\r\nhave a duration of `00:20`.\r\n\r\n## Running Command-Line-Interface\r\n\r\n### CLI Arguments\r\n\r\nThe following cli arguments are supported:\r\n\r\n* **`--input`** or **`-i`** : The path to the input (Video/Audio) file.\r\n\r\n* **`--output`** or **`-o`** : The path to the extracted audio file. The default value is `./audio.mp3`.\r\n\r\n* **`--format`** or **`-f`** : The format of the extracted audio. The default value is `mp3`.\r\n\r\n* **`--start-time`** or **`-st`** : The start time of the output in `HH:MM:SS` or `MM:SS` format. The default value\r\n  is `00:00:00`.\r\n\r\n* **`--duration`** or **`-d`** : The duration of the extracted audio in seconds _(float)_, The default value is `None`\r\n  which means full audio will be extracted if `start_time` is set to `00:00:00`.\r\n\r\n* **`--overwrite`** or **`-ow`** : Whether to overwrite the output file if it already exists or not. The default value\r\n  is `False`.\r\n\r\n### CLI Usage Example:\r\n\r\nHere is an example of using the CLI to extract audio:\r\n\r\n```bash\r\naudio-extract --input=\"./video.mp4\" --output=\"./audios/extracted_audio.wav\" --format=\"wav\"\r\n```\r\n\r\nThis command will extract the full audio starting from `video.mp4` to a `wav` file called `extracted_audio.wav` and will\r\nbe saved to the folder `./audios/`. The folder will be automatically created if it doesn't exist.\r\n\r\n## Authors\r\n\r\nRiadh Azzoun - [@riad-azz](https://github.com/riad-azz)\r\n\r\n## License\r\n\r\nThis project is licensed under the [MIT] License - see the LICENSE.md file for details\r\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Extract and trim audio from videos or trim audios.",
    "version": "0.6.0",
    "project_urls": {
        "Homepage": "https://github.com/riad-azz/audio-extract",
        "Source": "https://github.com/riad-azz/audio-extract"
    },
    "split_keywords": [
        "convert video",
        "audio",
        "ffmpeg",
        "video to mp3"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ff76b7ef2c247b74824cfb194d20ee070d8bb12b238219db8ecc3ce4fd1e7469",
                "md5": "9cccecaa0790c9e15403741f379b4934",
                "sha256": "0e1b671a9fb2d2eade368a3cba1986fa098aba9c2d8affaed353196fcf90a1dd"
            },
            "downloads": -1,
            "filename": "audio_extract-0.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9cccecaa0790c9e15403741f379b4934",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 7450,
            "upload_time": "2023-10-19T15:04:09",
            "upload_time_iso_8601": "2023-10-19T15:04:09.240995Z",
            "url": "https://files.pythonhosted.org/packages/ff/76/b7ef2c247b74824cfb194d20ee070d8bb12b238219db8ecc3ce4fd1e7469/audio_extract-0.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7c457ea6ef6885ef0c979280f2e6ad465847dfd9d4ebc93c7e09e2200f88267f",
                "md5": "4ea8259033be40485e45f6a970d28f41",
                "sha256": "88ba707bfdbec15fd7486c26d361cd53d90f6aae575957b3663398fffca98be9"
            },
            "downloads": -1,
            "filename": "audio_extract-0.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "4ea8259033be40485e45f6a970d28f41",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6932,
            "upload_time": "2023-10-19T15:04:11",
            "upload_time_iso_8601": "2023-10-19T15:04:11.045662Z",
            "url": "https://files.pythonhosted.org/packages/7c/45/7ea6ef6885ef0c979280f2e6ad465847dfd9d4ebc93c7e09e2200f88267f/audio_extract-0.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-19 15:04:11",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "riad-azz",
    "github_project": "audio-extract",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "audio-extract"
}
        
Elapsed time: 0.12994s