diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7fdb84a --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +env/ +*egg-info/ +__pycache__/ +build/ +dist/ diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..df70b67 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,7 @@ +Copyright 2021 Zev Benjamin Averbach + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index dd452a4..190a264 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,15 @@ # Installation ```bash -git clone https://github.com/zevaverbach/extract_audio_from_video -ln -s /app/extract_audio /usr/local/bin/extract +pip install extract-audio +``` + +## Prequisites + +ffmpeg + +```bash +$ brew install ffmpeg ``` # Usage @@ -10,5 +17,4 @@ ln -s /app/extract_audio /usr/local/bin/extract ```bash extract ``` - This will produce m4a versions of the video files in that same directory. diff --git a/app/__init__.py b/app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/extract_audio b/app/extract_audio.py similarity index 76% rename from app/extract_audio rename to app/extract_audio.py index 65b4d9b..6757907 100755 --- a/app/extract_audio +++ b/app/extract_audio.py @@ -7,10 +7,11 @@ import threading def extract_audio(dir_, fp): - return check_output(f"ffmpeg -i {fp} -vn -acodec copy {dir_}{fp.stem}.m4a", shell=True) + return check_output(f'ffmpeg -y -i "{fp}" -vn -acodec copy "{dir_}{fp.stem}.m4a"', shell=True) -def main(dir_): +def main(): + dir_ = args[1] threads = [] for fp in Path(dir_).iterdir(): a = threading.Thread( @@ -27,5 +28,4 @@ def main(dir_): if __name__ == "__main__": - dirpath = args[1] - main(dirpath) + main() diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..ef9e2d1 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[metadata] +license_files = LICENSE.txt diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..894ac5e --- /dev/null +++ b/setup.py @@ -0,0 +1,17 @@ +from setuptools import setup + + +setup( + name="extract-audio", + version="0.1", + packages=["app"], + description="Extract audio from a directory of video files.", + author="Zev Averbach", + author_email="zev@averba.ch", + url="https://github.com/zevaverbach/extract_audio_from_video", + entry_points={ + "console_scripts": [ + "extract=app.extract_audio:main", + ] + }, +)