From 20bc900f7b1182201324ad206cfd5a7a85ec4113 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sat, 18 Oct 2025 11:38:20 +0200 Subject: fix compression for audio --- cogs/compression.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'cogs/compression.py') diff --git a/cogs/compression.py b/cogs/compression.py index 177f543..1905d74 100644 --- a/cogs/compression.py +++ b/cogs/compression.py @@ -43,7 +43,11 @@ class Compression(commands.Cog): if file_type == "Video": command = f"ffmpeg -y -i {file_path} -c:v libx264 -crf 51 -b:v 100 -vf 'fps=10,scale=trunc(iw*0.5/2)*2:trunc(ih*0.5/2)*2' -preset ultrafast -c:a libopus -b:a 500 {output_path}" elif file_type == "Audio": - command = f"ffmpeg -y -i {file_path} -ac 1 -b:a 500 -acodec libopus {output_path}" + if output_path.lower().endswith('.mp3'): + output_path = os.path.splitext(output_path)[0] + os.path.splitext(output_path)[1].replace('.mp3', '') + if not output_path.lower().endswith('.ogg'): + output_path = os.path.splitext(output_path)[0] + '.ogg' + command = f"ffmpeg -y -i {file_path} -c:a libopus -b:a 500 -ar 12000 -ac 1 {output_path}" elif file_type == "Image": ext = os.path.splitext(file_path)[1].lower() if ext in [".jpg", ".jpeg"]: -- cgit v1.2.3