diff options
author | Florian Zeitz <florob@babelmonkeys.de> | 2016-09-14 08:43:15 +0200 |
---|---|---|
committer | Florian Zeitz <florob@babelmonkeys.de> | 2016-09-14 08:43:15 +0200 |
commit | f06786518f40ec6d5013a3035c9d4101a22bfa10 (patch) | |
tree | 8caa8fdfb7286cf2fad9b4f934ca43d7d232a6ee /example-scripts/ffmpeg | |
parent | 6dec67387f3fa4a24d5d722be2b42bfc47416bc7 (diff) |
record-all-audio-streams example: pep8ify
* Indent by 4 spaces
* Remove semicolons
* Use format() over percent formating
Diffstat (limited to 'example-scripts/ffmpeg')
-rwxr-xr-x | example-scripts/ffmpeg/record-all-audio-streams.py | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/example-scripts/ffmpeg/record-all-audio-streams.py b/example-scripts/ffmpeg/record-all-audio-streams.py index f5bff8f..29cfd6b 100755 --- a/example-scripts/ffmpeg/record-all-audio-streams.py +++ b/example-scripts/ffmpeg/record-all-audio-streams.py @@ -14,29 +14,28 @@ host = 'localhost' port = 9999 log.info('Connecting to %s:%u', host, port) -conn = socket.create_connection( (host, port) ) +conn = socket.create_connection((host, port)) fd = conn.makefile('rw') log.info('Fetching Config from Server') -fd.write("get_config\n"); +fd.write("get_config\n") fd.flush() for line in fd: - if line.startswith('server_config'): - words = line.split(' ') - args = words[1:] - server_config_json = " ".join(args) - log.info('Received Config from Server') - break + if line.startswith('server_config'): + [cmd, arg] = line.split(' ', 1) + server_config_json = arg + log.info('Received Config from Server') + break log.info('Parsing Server-Config') server_config = json.loads(server_config_json) + def getlist(self, section, option): - return [x.strip() for x in self.get(section, option).split(',')] + return [x.strip() for x in self.get(section, option).split(',')] SafeConfigParser.getlist = getlist - config = SafeConfigParser() config.read_dict(server_config) @@ -45,26 +44,26 @@ sources = config.getlist('mix', 'sources') inputs = [] maps = [] for idx, source in enumerate(sources): - inputs.append('-i tcp://localhost:%u' % (13000+idx)) - maps.append('-map %u:a -metadata:s:a:%u language=und' % (idx, idx)) + inputs.append('-i tcp://localhost:{:d}'.format(13000 + idx)) + maps.append('-map {0:d}:a -metadata:s:a:{0:d} language=und'.format(idx)) try: - output = sys.argv[1] + output = sys.argv[1] except: - output = 'output.ts' + output = 'output.ts' cmd = """ ffmpeg \ - -hide_banner - -y -nostdin - %s - -ac 2 -channel_layout stereo - %s - -c:a mp2 -b:a 192k -ac:a 2 -ar:a 48000 - -flags +global_header -flags +ilme+ildct - -f mpegts - %s -""" % (' '.join(inputs), ' '.join(maps), output) + -hide_banner + -y -nostdin + {} + -ac 2 -channel_layout stereo + {} + -c:a mp2 -b:a 192k -ac:a 2 -ar:a 48000 + -flags +global_header -flags +ilme+ildct + -f mpegts + {} +""".format(' '.join(inputs), ' '.join(maps), output) log.info('running command:\n%s', cmd) args = shlex.split(cmd) p = subprocess.run(args) |