diff options
author | MaZderMind <git@mazdermind.de> | 2016-09-26 20:42:07 +0200 |
---|---|---|
committer | MaZderMind <git@mazdermind.de> | 2016-09-26 20:42:07 +0200 |
commit | 6e846c7081e242213cd70ceacfcff319e221942c (patch) | |
tree | 9d037e9272e65aea06c74775b2af1eae2f50a46e /example-scripts/ffmpeg/record-all-audio-streams.py | |
parent | fbcbc3743e9179738244a96be54aa588e44314cb (diff) | |
parent | 1972da7f6aa60d3cb3b68808d0381e37898665f3 (diff) |
Merge branch 'pep8'
Diffstat (limited to 'example-scripts/ffmpeg/record-all-audio-streams.py')
-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) |