mirror of
https://github.com/YuzuZensai/spleeter.git
synced 2026-01-31 14:58:23 +00:00
fix: ffmpeg issues
This commit is contained in:
@@ -65,16 +65,15 @@ class FFMPEGProcessAudioAdapter(AudioAdapter):
|
|||||||
n_channels = metadata['channels']
|
n_channels = metadata['channels']
|
||||||
if sample_rate is None:
|
if sample_rate is None:
|
||||||
sample_rate = metadata['sample_rate']
|
sample_rate = metadata['sample_rate']
|
||||||
input_kwargs = {'format': 'f32le', 'ar': sample_rate}
|
output_kwargs = {'format': 'f32le', 'ar': sample_rate}
|
||||||
if duration is not None:
|
if duration is not None:
|
||||||
input_kwargs['t'] = _to_ffmpeg_time(duration)
|
output_kwargs['t'] = _to_ffmpeg_time(duration)
|
||||||
if offset is not None:
|
if offset is not None:
|
||||||
input_kwargs['ss'] = _to_ffmpeg_time(offset)
|
output_kwargs['ss'] = _to_ffmpeg_time(offset)
|
||||||
buffer, _ = (
|
buffer, _ = (
|
||||||
ffmpeg
|
ffmpeg
|
||||||
.input(path, **input_kwargs)
|
.input(path)
|
||||||
.output('-', format='f32le')
|
.output('-', **output_kwargs)
|
||||||
.overwrite_output()
|
|
||||||
.run(capture_stdout=True, capture_stderr=True))
|
.run(capture_stdout=True, capture_stderr=True))
|
||||||
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):
|
||||||
@@ -104,13 +103,13 @@ class FFMPEGProcessAudioAdapter(AudioAdapter):
|
|||||||
'strict': '-2'}
|
'strict': '-2'}
|
||||||
if bitrate:
|
if bitrate:
|
||||||
output_kwargs['audio_bitrate'] = bitrate
|
output_kwargs['audio_bitrate'] = bitrate
|
||||||
if codec:
|
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')
|
||||||
.output(path, format='f32le', **output_kwargs)
|
.output(path, format='f32le', **output_kwargs)
|
||||||
.run_async(pipe_stdin=True))
|
.run_async(pipe_stdin=True, quiet=True))
|
||||||
try:
|
try:
|
||||||
process.stdin.write(data.astype('<f4').tostring())
|
process.stdin.write(data.astype('<f4').tostring())
|
||||||
process.stdin.close()
|
process.stdin.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user