more commandline component options
commandline options that existed before the redesign are now back
This commit is contained in:
parent
49cda1bf3a
commit
3c903794e3
15
command.py
15
command.py
|
@ -2,6 +2,7 @@ from PyQt4 import QtCore
|
||||||
from PyQt4.QtCore import QSettings
|
from PyQt4.QtCore import QSettings
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
import core
|
import core
|
||||||
import video_thread
|
import video_thread
|
||||||
|
@ -22,14 +23,14 @@ class Command(QtCore.QObject):
|
||||||
description='Create a visualization for an audio file',
|
description='Create a visualization for an audio file',
|
||||||
epilog='EXAMPLE COMMAND: main.py myvideotemplate.avp '
|
epilog='EXAMPLE COMMAND: main.py myvideotemplate.avp '
|
||||||
'-i ~/Music/song.mp3 -o ~/video.mp4 '
|
'-i ~/Music/song.mp3 -o ~/video.mp4 '
|
||||||
'-c 0 image ~/Pictures/thisWeeksPicture.jpg '
|
'-c 0 image path=~/Pictures/thisWeeksPicture.jpg '
|
||||||
'-c 1 video "preset=My Logo" -c 2 vis classic')
|
'-c 1 video "preset=My Logo" -c 2 vis layout=classic')
|
||||||
self.parser.add_argument(
|
self.parser.add_argument(
|
||||||
'-i', '--input', metavar='SOUND',
|
'-i', '--input', metavar='SOUND',
|
||||||
help='input audio file', required=True)
|
help='input audio file')
|
||||||
self.parser.add_argument(
|
self.parser.add_argument(
|
||||||
'-o', '--output', metavar='OUTPUT',
|
'-o', '--output', metavar='OUTPUT',
|
||||||
help='output video file', required=True)
|
help='output video file')
|
||||||
|
|
||||||
# optional arguments
|
# optional arguments
|
||||||
self.parser.add_argument(
|
self.parser.add_argument(
|
||||||
|
@ -71,7 +72,11 @@ class Command(QtCore.QObject):
|
||||||
for arg in args:
|
for arg in args:
|
||||||
self.core.selectedComponents[i].command(arg)
|
self.core.selectedComponents[i].command(arg)
|
||||||
|
|
||||||
self.createAudioVisualisation()
|
if self.args.input and self.args.output:
|
||||||
|
self.createAudioVisualisation()
|
||||||
|
elif 'help' not in sys.argv:
|
||||||
|
self.parser.print_help()
|
||||||
|
quit(1)
|
||||||
|
|
||||||
def createAudioVisualisation(self):
|
def createAudioVisualisation(self):
|
||||||
self.videoThread = QtCore.QThread(self)
|
self.videoThread = QtCore.QThread(self)
|
||||||
|
|
|
@ -73,7 +73,7 @@ class Component(QtCore.QObject):
|
||||||
print(
|
print(
|
||||||
self.__doc__, 'Usage:\n'
|
self.__doc__, 'Usage:\n'
|
||||||
'Open a preset for this component:\n'
|
'Open a preset for this component:\n'
|
||||||
' "preset=Preset Name"\n')
|
' "preset=Preset Name"')
|
||||||
self.commandHelp()
|
self.commandHelp()
|
||||||
quit(0)
|
quit(0)
|
||||||
|
|
||||||
|
|
|
@ -233,3 +233,14 @@ class Component(__base__.Component):
|
||||||
else:
|
else:
|
||||||
self.page.lineEdit_color2.setText(RGBstring)
|
self.page.lineEdit_color2.setText(RGBstring)
|
||||||
self.page.pushButton_color2.setStyleSheet(btnStyle)
|
self.page.pushButton_color2.setStyleSheet(btnStyle)
|
||||||
|
|
||||||
|
def commandHelp(self):
|
||||||
|
print('Specify a color:\n color=255,255,255')
|
||||||
|
|
||||||
|
def command(self, arg):
|
||||||
|
if not arg.startswith('preset=') and '=' in arg:
|
||||||
|
key, arg = arg.split('=', 1)
|
||||||
|
if key == 'color':
|
||||||
|
self.page.lineEdit_color1.setText(arg)
|
||||||
|
return
|
||||||
|
super().command(arg)
|
||||||
|
|
|
@ -94,18 +94,18 @@ class Component(__base__.Component):
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def command(self, arg):
|
def command(self, arg):
|
||||||
if not arg.startswith('preset='):
|
if not arg.startswith('preset=') and '=' in arg:
|
||||||
if os.path.exists(arg):
|
key, arg = arg.split('=', 1)
|
||||||
|
if key == 'path' and os.path.exists(arg):
|
||||||
try:
|
try:
|
||||||
Image.open(arg)
|
Image.open(arg)
|
||||||
self.imagePath = arg
|
self.page.lineEdit_image.setText(arg)
|
||||||
self.stretched = True
|
self.page.checkBox_stretch.setChecked(True)
|
||||||
return True
|
return
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
print("Not a supported image format")
|
print("Not a supported image format")
|
||||||
quit(1)
|
quit(1)
|
||||||
super().command(arg)
|
super().command(arg)
|
||||||
|
|
||||||
def commandHelp(self):
|
def commandHelp(self):
|
||||||
print('Give a complete filepath to an image to load that '
|
print('Load an image:\n path=/filepath/to/image.png')
|
||||||
'image with default settings.')
|
|
||||||
|
|
|
@ -184,14 +184,21 @@ class Component(__base__.Component):
|
||||||
return im
|
return im
|
||||||
|
|
||||||
def command(self, arg):
|
def command(self, arg):
|
||||||
if not arg.startswith('preset='):
|
if not arg.startswith('preset=') and '=' in arg:
|
||||||
if arg == 'classic':
|
key, arg = arg.split('=', 1)
|
||||||
self.layout = 0; return
|
if key == 'color':
|
||||||
elif arg == 'split':
|
self.page.lineEdit_visColor.setText(arg)
|
||||||
self.layout = 1; return
|
return
|
||||||
elif arg == 'bottom':
|
elif key == 'layout':
|
||||||
self.layout = 2; return
|
if arg == 'classic':
|
||||||
|
self.page.comboBox_visLayout.setCurrentIndex(0)
|
||||||
|
elif arg == 'split':
|
||||||
|
self.page.comboBox_visLayout.setCurrentIndex(1)
|
||||||
|
elif arg == 'bottom':
|
||||||
|
self.page.comboBox_visLayout.setCurrentIndex(2)
|
||||||
|
return
|
||||||
super().command(arg)
|
super().command(arg)
|
||||||
|
|
||||||
def commandHelp(self):
|
def commandHelp(self):
|
||||||
print('Give a layout name: classic, split, or bottom')
|
print('Give a layout name:\n layout=[classic/split/bottom]')
|
||||||
|
print('Specify a color:\n color=255,255,255')
|
||||||
|
|
|
@ -149,12 +149,28 @@ class Component(__base__.Component):
|
||||||
self.page.lineEdit_textColor.setText(RGBstring)
|
self.page.lineEdit_textColor.setText(RGBstring)
|
||||||
self.page.pushButton_textColor.setStyleSheet(btnStyle)
|
self.page.pushButton_textColor.setStyleSheet(btnStyle)
|
||||||
|
|
||||||
def commandHelp(self, arg):
|
def commandHelp(self):
|
||||||
print('Enter a string to use as centred white text. '
|
print('Enter a string to use as centred white text:')
|
||||||
'Use quotes around the string to escape spaces.')
|
print(' "title=User Error"')
|
||||||
|
print('Specify a text color:\n color=255,255,255')
|
||||||
|
print('Set custom x, y position:\n x=500 y=500')
|
||||||
|
|
||||||
def command(self, arg):
|
def command(self, arg):
|
||||||
if not arg.startswith('preset='):
|
if not arg.startswith('preset=') and '=' in arg:
|
||||||
self.title = arg
|
key, arg = arg.split('=', 1)
|
||||||
return True
|
if key == 'color':
|
||||||
|
self.page.lineEdit_textColor.setText(arg)
|
||||||
|
return
|
||||||
|
elif key == 'size':
|
||||||
|
self.page.spinBox_fontSize.setValue(int(arg))
|
||||||
|
return
|
||||||
|
elif key == 'x':
|
||||||
|
self.page.spinBox_xTextAlign.setValue(int(arg))
|
||||||
|
return
|
||||||
|
elif key == 'y':
|
||||||
|
self.page.spinBox_yTextAlign.setValue(int(arg))
|
||||||
|
return
|
||||||
|
elif key == 'title':
|
||||||
|
self.page.lineEdit_title.setText(arg)
|
||||||
|
return
|
||||||
super().command(arg)
|
super().command(arg)
|
||||||
|
|
|
@ -222,21 +222,21 @@ class Component(__base__.Component):
|
||||||
self.chunkSize = 4*width*height
|
self.chunkSize = 4*width*height
|
||||||
|
|
||||||
def command(self, arg):
|
def command(self, arg):
|
||||||
if not arg.startswith('preset='):
|
if not arg.startswith('preset=') and '=' in arg:
|
||||||
if os.path.exists(arg):
|
key, arg = arg.split('=', 1)
|
||||||
|
if key == 'path' and os.path.exists(arg):
|
||||||
if os.path.splitext(arg)[1] in self.core.videoFormats:
|
if os.path.splitext(arg)[1] in self.core.videoFormats:
|
||||||
self.videoPath = arg
|
self.page.lineEdit_video.setText(arg)
|
||||||
self.scale = 100
|
self.page.spinBox_scale.setValue(100)
|
||||||
self.loopVideo = True
|
self.page.checkBox_loop.setChecked(True)
|
||||||
return True
|
return
|
||||||
else:
|
else:
|
||||||
print("Not a supported video format")
|
print("Not a supported video format")
|
||||||
quit(1)
|
quit(1)
|
||||||
super().command(arg)
|
super().command(arg)
|
||||||
|
|
||||||
def commandHelp(self):
|
def commandHelp(self):
|
||||||
print('Give a complete filepath to a video to load that '
|
print('Load a video:\n path=/filepath/to/video.mp4')
|
||||||
'video with default settings.')
|
|
||||||
|
|
||||||
def scale(scale, width, height, returntype=None):
|
def scale(scale, width, height, returntype=None):
|
||||||
width = (float(width) / 100.0) * float(scale)
|
width = (float(width) / 100.0) * float(scale)
|
||||||
|
|
Reference in New Issue