mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-09 14:11:55 -04:00
Fix lossless conversion bit depth issues (#616)
This commit is contained in:
parent
b01382f267
commit
4353c84837
1 changed files with 17 additions and 13 deletions
|
@ -121,27 +121,31 @@ class Converter:
|
|||
command.extend(self.ffmpeg_arg.split())
|
||||
|
||||
if self.lossless:
|
||||
if isinstance(self.sampling_rate, int):
|
||||
sampling_rates = "|".join(
|
||||
str(rate) for rate in SAMPLING_RATES if rate <= self.sampling_rate
|
||||
)
|
||||
command.extend(["-af", f"aformat=sample_rates={sampling_rates}"])
|
||||
aformat = []
|
||||
|
||||
if isinstance(self.sampling_rate, int):
|
||||
sample_rates = "|".join(str(rate) for rate in SAMPLING_RATES if rate <= self.sampling_rate)
|
||||
aformat.append(f"sample_rates={sample_rates}")
|
||||
elif self.sampling_rate is not None:
|
||||
raise TypeError(
|
||||
f"Sampling rate must be int, not {type(self.sampling_rate)}",
|
||||
)
|
||||
raise TypeError(f"Sampling rate must be int, not {type(self.sampling_rate)}")
|
||||
|
||||
if isinstance(self.bit_depth, int):
|
||||
if int(self.bit_depth) == 16:
|
||||
command.extend(["-sample_fmt", "s16"])
|
||||
elif int(self.bit_depth) in (24, 32):
|
||||
command.extend(["-sample_fmt", "s32p"])
|
||||
else:
|
||||
bit_depths = ["s16p", "s16"]
|
||||
|
||||
if self.bit_depth in (24, 32):
|
||||
bit_depths.extend(["s32p", "s32"])
|
||||
elif self.bit_depth != 16:
|
||||
raise ValueError("Bit depth must be 16, 24, or 32")
|
||||
|
||||
sample_fmts = "|".join(bit_depths)
|
||||
aformat.append(f"sample_fmts={sample_fmts}")
|
||||
elif self.bit_depth is not None:
|
||||
raise TypeError(f"Bit depth must be int, not {type(self.bit_depth)}")
|
||||
|
||||
if aformat:
|
||||
aformat_params = ':'.join(aformat)
|
||||
command.extend(["-af", f"aformat={aformat_params}"])
|
||||
|
||||
# automatically overwrite
|
||||
command.extend(["-y", self.tempfile])
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue