1234567891011121314151617181920212223 |
- from pathlib import Path
- from .utils import to_hhmmss, system
- async def slice_audio(src_path: Path, dst_path: Path, timecode: str):
- if not src_path.exists():
- raise FileNotFoundError
- if dst_path.exists():
- return dst_path
- start, end = map(int, timecode.split("/"))
- if start == -1:
- return src_path
- if start == 0 and end == -1:
- return src_path
- start = to_hhmmss(start)
- end = to_hhmmss(end)
- command = f'ffmpeg -ss {start} -to {end} -i "{src_path}" -qscale 0 "{dst_path}"'
- await system(command)
- return dst_path
|