fix: finalizes FFMPEG debug

docs: update prog USAGE
This commit is contained in:
Félix Voituret
2019-11-06 19:41:16 +01:00
parent 55723cfa62
commit eaa6005e08
2 changed files with 10 additions and 10 deletions

View File

@@ -172,7 +172,7 @@ def create_argument_parser():
:returns: Created argument parser. :returns: Created argument parser.
""" """
parser = ArgumentParser(prog='python -m spleeter') parser = ArgumentParser(prog='spleeter')
subparsers = parser.add_subparsers() subparsers = parser.add_subparsers()
subparsers.dest = 'command' subparsers.dest = 'command'
subparsers.required = True subparsers.required = True

View File

@@ -72,11 +72,12 @@ class FFMPEGProcessAudioAdapter(AudioAdapter):
output_kwargs['t'] = _to_ffmpeg_time(duration) output_kwargs['t'] = _to_ffmpeg_time(duration)
if offset is not None: if offset is not None:
output_kwargs['ss'] = _to_ffmpeg_time(offset) output_kwargs['ss'] = _to_ffmpeg_time(offset)
buffer, _ = ( process = (
ffmpeg ffmpeg
.input(path) .input(path)
.output('-', **output_kwargs) .output('pipe:', **output_kwargs)
.run(capture_stdout=True, capture_stderr=True)) .run_async(pipe_stdout=True, pipe_stderr=True))
buffer, _ = process.communicate()
waveform = np.frombuffer(buffer, dtype='<f4').reshape(-1, n_channels) waveform = np.frombuffer(buffer, dtype='<f4').reshape(-1, n_channels)
if not waveform.dtype == np.dtype(dtype): if not waveform.dtype == np.dtype(dtype):
waveform = waveform.astype(dtype) waveform = waveform.astype(dtype)
@@ -99,18 +100,17 @@ class FFMPEGProcessAudioAdapter(AudioAdapter):
if not os.path.exists(directory): if not os.path.exists(directory):
os.makedirs(directory) os.makedirs(directory)
get_logger().debug('Writing file %s', path) get_logger().debug('Writing file %s', path)
output_kwargs = { input_kwargs = {'ar': sample_rate, 'ac': data.shape[1]}
'ar': sample_rate, output_kwargs = {'ar': sample_rate, 'strict': '-2'}
'ac': data.shape[1],
'strict': '-2'}
if bitrate: if bitrate:
output_kwargs['audio_bitrate'] = bitrate output_kwargs['audio_bitrate'] = bitrate
if codec is not None and codec != 'wav': if codec is not None and codec != 'wav':
output_kwargs['codec'] = codec output_kwargs['codec'] = codec
process = ( process = (
ffmpeg ffmpeg
.input('pipe:', format='f32le') .input('pipe:', format='f32le', **input_kwargs)
.output(path, format='f32le', **output_kwargs) .output(path, **output_kwargs)
.overwrite_output()
.run_async(pipe_stdin=True, quiet=True)) .run_async(pipe_stdin=True, quiet=True))
try: try:
process.stdin.write(data.astype('<f4').tobytes()) process.stdin.write(data.astype('<f4').tobytes())