Области, извлеченные из аудиофайла wav, имеют «Неверное значение длительности для сс»
Например, в моем случае продолжительность в этом формате
[(0.006000000000000005, 1.03), (2.0540000000000003, 4.870000000000003)]
Это для преобразования регионов в формат Flac.
class FLACConverter(object):
# pylint: disable=too-few-public-methods
"""
Class for converting a region of an input audio or video file into a FLAC audio file
"""
def __init__(self, source_path, include_before=0.25, include_after=0.25):
self.source_path = source_path
self.include_before = include_before
self.include_after = include_after
def __call__(self, region):
try:
print("regions to convert in flac:{}".format(region))
start = region
end = region
# start = max(0, start - self.include_before)
start = list(map(lambda x: tuple(max(0, y - self.include_before) for y in x), start))
end = list(map(lambda x: tuple(y + self.include_after for y in x), end))
temp = tempfile.NamedTemporaryFile(suffix='.flac', delete=False)
command = ["ffmpeg", "-ss", str(start), "-t", str([tuple(x-y for x, y in zip(x1, x2)) for (x1, x2) in zip(end, start)]),
"-y", "-i", self.source_path,
"-loglevel", "error", temp.name]
use_shell = True if os.name == "nt" else False
subprocess.check_output(command)
print(temp.name)
#subprocess.check_output(command, stdin=open(os.devnull), shell=use_shell)
read_data = temp.read()
temp.close()
os.unlink(temp.name)
print("read_data :{}".format(read_data))
print("temp :{}".format(temp.name))
return read_data
except KeyboardInterrupt:
return None
Я ожидаю вывод /var/folders/p1/6ttydjfx2sq9zl4cnmjxgjh40000gp/T/tmpwz5n4fnv.flac
, но он возвращает ошибку
CalledProcessError at /
Command '['ffmpeg', '-ss', '[(0.006000000000000005, 1.03), (2.0540000000000003, 4.870000000000003)]', '-t', '[(0.5, 0.5), (0.5, 0.5)]', '-y', '-i', '/var/folders/p1/6ttydjfx2sq9zl4cnmjxgjh40000gp/T/tmpuyi5spat.wav', '-loglevel', 'error', '/var/folders/p1/6ttydjfx2sq9zl4cnmjxgjh40000gp/T/tmp0vdewoyd.flac']' returned non-zero exit status 1.```