aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDH42017-05-26 23:06:47 -0500
committerDH42017-05-26 23:06:47 -0500
commiteaee0ab233709c18324dbb25f38b59c95c447e3c (patch)
treefeee68f0389916dbbe60579dcea3144d387c35c9
parent5487319dc10c42728ecc0d8f67abe55278348509 (diff)
Removed hardcoded parameters. Defaults loaded at runtime.
-rw-r--r--.vscode/launch.json204
-rw-r--r--main.py22
-rw-r--r--video_thread.py21
3 files changed, 237 insertions, 10 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..5b2c335
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,204 @@
+{
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "Python",
+ "type": "python",
+ "request": "launch",
+ "stopOnEntry": true,
+ "pythonPath": "${config:python.pythonPath}",
+ "program": "${file}",
+ "cwd": "${workspaceRoot}",
+ "env": {},
+ "envFile": "${workspaceRoot}/.env",
+ "debugOptions": [
+ "WaitOnAbnormalExit",
+ "WaitOnNormalExit",
+ "RedirectOutput"
+ ]
+ },
+ {
+ "name": "PySpark",
+ "type": "python",
+ "request": "launch",
+ "stopOnEntry": true,
+ "osx": {
+ "pythonPath": "${env:SPARK_HOME}/bin/spark-submit"
+ },
+ "windows": {
+ "pythonPath": "${env:SPARK_HOME}/bin/spark-submit.cmd"
+ },
+ "linux": {
+ "pythonPath": "${env:SPARK_HOME}/bin/spark-submit"
+ },
+ "program": "${file}",
+ "cwd": "${workspaceRoot}",
+ "env": {},
+ "envFile": "${workspaceRoot}/.env",
+ "debugOptions": [
+ "WaitOnAbnormalExit",
+ "WaitOnNormalExit",
+ "RedirectOutput"
+ ]
+ },
+ {
+ "name": "Python Module",
+ "type": "python",
+ "request": "launch",
+ "stopOnEntry": true,
+ "pythonPath": "${config:python.pythonPath}",
+ "module": "module.name",
+ "cwd": "${workspaceRoot}",
+ "env": {},
+ "envFile": "${workspaceRoot}/.env",
+ "debugOptions": [
+ "WaitOnAbnormalExit",
+ "WaitOnNormalExit",
+ "RedirectOutput"
+ ]
+ },
+ {
+ "name": "Integrated Terminal/Console",
+ "type": "python",
+ "request": "launch",
+ "stopOnEntry": true,
+ "pythonPath": "${config:python.pythonPath}",
+ "program": "${file}",
+ "cwd": "",
+ "console": "integratedTerminal",
+ "env": {},
+ "envFile": "${workspaceRoot}/.env",
+ "debugOptions": [
+ "WaitOnAbnormalExit",
+ "WaitOnNormalExit"
+ ]
+ },
+ {
+ "name": "External Terminal/Console",
+ "type": "python",
+ "request": "launch",
+ "stopOnEntry": true,
+ "pythonPath": "${config:python.pythonPath}",
+ "program": "${file}",
+ "cwd": "",
+ "console": "externalTerminal",
+ "env": {},
+ "envFile": "${workspaceRoot}/.env",
+ "debugOptions": [
+ "WaitOnAbnormalExit",
+ "WaitOnNormalExit"
+ ]
+ },
+ {
+ "name": "Django",
+ "type": "python",
+ "request": "launch",
+ "stopOnEntry": true,
+ "pythonPath": "${config:python.pythonPath}",
+ "program": "${workspaceRoot}/manage.py",
+ "cwd": "${workspaceRoot}",
+ "args": [
+ "runserver",
+ "--noreload"
+ ],
+ "env": {},
+ "envFile": "${workspaceRoot}/.env",
+ "debugOptions": [
+ "WaitOnAbnormalExit",
+ "WaitOnNormalExit",
+ "RedirectOutput",
+ "DjangoDebugging"
+ ]
+ },
+ {
+ "name": "Flask",
+ "type": "python",
+ "request": "launch",
+ "stopOnEntry": false,
+ "pythonPath": "${config:python.pythonPath}",
+ "program": "fully qualified path fo 'flask' executable. Generally located along with python interpreter",
+ "cwd": "${workspaceRoot}",
+ "env": {
+ "FLASK_APP": "${workspaceRoot}/quickstart/app.py"
+ },
+ "args": [
+ "run",
+ "--no-debugger",
+ "--no-reload"
+ ],
+ "envFile": "${workspaceRoot}/.env",
+ "debugOptions": [
+ "WaitOnAbnormalExit",
+ "WaitOnNormalExit",
+ "RedirectOutput"
+ ]
+ },
+ {
+ "name": "Flask (old)",
+ "type": "python",
+ "request": "launch",
+ "stopOnEntry": false,
+ "pythonPath": "${config:python.pythonPath}",
+ "program": "${workspaceRoot}/run.py",
+ "cwd": "${workspaceRoot}",
+ "args": [],
+ "env": {},
+ "envFile": "${workspaceRoot}/.env",
+ "debugOptions": [
+ "WaitOnAbnormalExit",
+ "WaitOnNormalExit",
+ "RedirectOutput"
+ ]
+ },
+ {
+ "name": "Pyramid",
+ "type": "python",
+ "request": "launch",
+ "stopOnEntry": true,
+ "pythonPath": "${config:python.pythonPath}",
+ "cwd": "${workspaceRoot}",
+ "env": {},
+ "envFile": "${workspaceRoot}/.env",
+ "args": [
+ "${workspaceRoot}/development.ini"
+ ],
+ "debugOptions": [
+ "WaitOnAbnormalExit",
+ "WaitOnNormalExit",
+ "RedirectOutput",
+ "Pyramid"
+ ]
+ },
+ {
+ "name": "Watson",
+ "type": "python",
+ "request": "launch",
+ "stopOnEntry": true,
+ "pythonPath": "${config:python.pythonPath}",
+ "program": "${workspaceRoot}/console.py",
+ "cwd": "${workspaceRoot}",
+ "args": [
+ "dev",
+ "runserver",
+ "--noreload=True"
+ ],
+ "env": {},
+ "envFile": "${workspaceRoot}/.env",
+ "debugOptions": [
+ "WaitOnAbnormalExit",
+ "WaitOnNormalExit",
+ "RedirectOutput"
+ ]
+ },
+ {
+ "name": "Attach (Remote Debug)",
+ "type": "python",
+ "request": "attach",
+ "localRoot": "${workspaceRoot}",
+ "remoteRoot": "${workspaceRoot}",
+ "port": 3000,
+ "secret": "my_secret",
+ "host": "localhost"
+ }
+ ]
+} \ No newline at end of file
diff --git a/main.py b/main.py
index 9f608d8..3915c71 100644
--- a/main.py
+++ b/main.py
@@ -36,6 +36,7 @@ class Command(QtCore.QObject):
self.args = self.parser.parse_args()
self.settings = QSettings('settings.ini', QSettings.IniFormat)
+ LoadDefaultSettings(self)
# load colours as tuples from comma-separated strings
self.textColor = core.Core.RGBFromString(self.settings.value("textColor", '255, 255, 255'))
@@ -106,6 +107,8 @@ class Command(QtCore.QObject):
self.settings.setValue("textColor", '%s,%s,%s' % self.textColor)
sys.exit(0)
+
+
class Main(QtCore.QObject):
newTask = QtCore.pyqtSignal(str, str, QFont, int, int, int, int, tuple, tuple)
@@ -119,6 +122,8 @@ class Main(QtCore.QObject):
self.window = window
self.core = core.Core()
self.settings = QSettings('settings.ini', QSettings.IniFormat)
+
+ LoadDefaultSettings(self)
# load colors as tuples from a comma-separated string
self.textColor = core.Core.RGBFromString(self.settings.value("textColor", '255, 255, 255'))
@@ -314,6 +319,23 @@ class Main(QtCore.QObject):
self.window.lineEdit_visColor.setText(RGBstring)
window.pushButton_visColor.setStyleSheet(btnStyle)
+def LoadDefaultSettings(self):
+ default = {
+ "outputWidth": 1280,
+ "outputHeight": 720,
+ "outputFrameRate": 30,
+ "outputAudioCodec": "aac",
+ "outputAudioBitrate": "192k",
+ "outputVideoCodec": "libx264",
+ "outputVideoFormat": "yuv420p",
+ "outputPreset": "medium",
+ "outputFormat": "mp4"
+ }
+
+ for parm, value in default.items():
+ if self.settings.value(parm) == None:
+ self.settings.setValue(parm,value)
+
if len(sys.argv) > 1:
# command line mode
app = QtGui.QApplication(sys.argv, False)
diff --git a/video_thread.py b/video_thread.py
index 6f71d38..fe1f6f6 100644
--- a/video_thread.py
+++ b/video_thread.py
@@ -15,6 +15,7 @@ class Worker(QtCore.QObject):
def __init__(self, parent=None):
QtCore.QObject.__init__(self)
+ self.settings = parent.settings
parent.videoTask.connect(self.createVideo)
self.core = core.Core()
@@ -52,27 +53,27 @@ class Worker(QtCore.QObject):
# test if user has libfdk_aac
encoders = sp.check_output(self.core.FFMPEG_BIN + " -encoders -hide_banner", shell=True)
- if b'libfdk_aac' in encoders:
+ acodec = self.settings.value('outputAudioCodec')
+
+ if b'libfdk_aac' in encoders and acodec == 'aac':
acodec = 'libfdk_aac'
- else:
- acodec = 'aac'
ffmpegCommand = [ self.core.FFMPEG_BIN,
'-y', # (optional) means overwrite the output file if it already exists.
'-f', 'rawvideo',
'-vcodec', 'rawvideo',
- '-s', '1280x720', # size of one frame
+ '-s', self.settings.value('outputWidth')+'x'+self.settings.value('outputHeight'), # size of one frame
'-pix_fmt', 'rgb24',
- '-r', '30', # frames per second
+ '-r', self.settings.value('outputFrameRate'), # frames per second
'-i', '-', # The input comes from a pipe
'-an',
'-i', inputFile,
'-acodec', acodec, # output audio codec
- '-b:a', "192k",
- '-vcodec', "libx264",
- '-pix_fmt', "yuv420p",
- '-preset', "medium",
- '-f', "mp4"]
+ '-b:a', self.settings.value('outputAudioBitrate'),
+ '-vcodec', self.settings.value('outputVideoCodec'),
+ '-pix_fmt', self.settings.value('outputVideoFormat'),
+ '-preset', self.settings.value('outputPreset'),
+ '-f', self.settings.value('outputFormat')]
if acodec == 'aac':
ffmpegCommand.append('-strict')