diff --git a/.gitignore b/.gitignore index 84a5e2a..f4d88c1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ __pycache__ -settings.ini \ No newline at end of file +settings.ini +build/* \ No newline at end of file diff --git a/README.md b/README.md index 2bde44e..aac1e37 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,25 @@ Dependencies ------------ You need Python 3, PyQt4, PIL (or Pillow), numpy and the program ffmpeg, which is used to read the audio and render the video. +Installation +------------ +### Manual installation on Ubuntu +* Get all the python stuff: `sudo apt-get install python3 python3-pyqt4 python3-pil python3-numpy` +* Get ffmpeg/avconv: +You can either use `avconv` from the standard repositories (package `libav-tools`) or get `ffmpeg` from the [website](http://ffmpeg.org/) or from a PPA (e.g. [https://launchpad.net/~jon-severinsson/+archive/ubuntu/ffmpeg](https://launchpad.net/~jon-severinsson/+archive/ubuntu/ffmpeg). The program does automatically detect if you don't have the ffmpeg binary and tries to use avconv instead. + +Download audio-visualizer-python from this repository and run it with `python3 main.py`. + +### Manual installation on Windows +* Download and install Python 3.4 from [https://www.python.org/downloads/windows/](https://www.python.org/downloads/windows/) +* Download and install PyQt4 for Python 3.4 and Qt4 from [http://www.riverbankcomputing.co.uk/software/pyqt/download](http://www.riverbankcomputing.co.uk/software/pyqt/download) +* Download and install numpy from [http://www.scipy.org/scipylib/download.html](http://www.scipy.org/scipylib/download.html). There is an installer available, make sure to get the one for Python 3.4 +* Download and install Pillow from [https://pypi.python.org/pypi/Pillow/2.7.0](https://pypi.python.org/pypi/Pillow/2.7.0) +* Download and install ffmpeg from [https://www.ffmpeg.org/download.html](https://www.ffmpeg.org/download.html). You can use the static builds. +* Add ffmpeg to your system PATH environment variable. + +Download audio-visualizer-python from this repository and run it from the command line with `C:\Python34\python.exe main.py`. + Example ------- You can find an example video here: diff --git a/core.py b/core.py index ac957e7..996bd52 100644 --- a/core.py +++ b/core.py @@ -1,4 +1,4 @@ -import sys, io +import sys, io, os from PyQt4 import QtCore, QtGui, uic from PyQt4.QtGui import QPainter, QColor from os.path import expanduser @@ -13,10 +13,18 @@ class Core(): self.lastBackgroundImage = "" self._image = None + self.FFMPEG_BIN = self.findFfmpeg() + + def findFfmpeg(self): if sys.platform == "win32": - self.FFMPEG_BIN = "ffmpeg.exe" + return "ffmpeg.exe" else: - self.FFMPEG_BIN = "ffmpeg" # on Linux and Mac OS + try: + with open(os.devnull, "w") as f: + sp.check_call(['ffmpeg', '-version'], stdout=f, stderr=f) + return "ffmpeg" + except: + return "avconv" def drawBaseImage(self, backgroundImage, titleText, titleFont): diff --git a/main.py b/main.py index da8dabc..03e0f02 100644 --- a/main.py +++ b/main.py @@ -109,6 +109,8 @@ class Main(QtCore.QObject): self.drawPreview() def createAudioVisualisation(self): + ffmpeg_cmd = self.settings.value("ffmpeg_cmd", expanduser("~")) + self.videoThread = QtCore.QThread(self) self.videoWorker = video_thread.Worker(self) diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..0d9cbc4 --- /dev/null +++ b/setup.py @@ -0,0 +1,30 @@ +from cx_Freeze import setup, Executable + +# Dependencies are automatically detected, but it might need +# fine tuning. +buildOptions = dict(packages = [], excludes = [ + "apport", + "apt", + "ctypes", + "curses", + "distutils", + "email", + "html", + "http", + "json", + "xmlrpc", + "nose" + ], include_files = ["main.ui"]) + +import sys +base = 'Win32GUI' if sys.platform=='win32' else None + +executables = [ + Executable('main.py', base=base, targetName = 'audio-visualizer-python') +] + +setup(name='audio-visualizer-python', + version = '1.0', + description = 'a little GUI tool to render visualization videos of audio files', + options = dict(build_exe = buildOptions), + executables = executables)