diff options
| author | salmonik <raisersoft@proton.me> | 2025-10-18 11:38:20 +0200 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2025-10-18 11:38:20 +0200 |
| commit | 20bc900f7b1182201324ad206cfd5a7a85ec4113 (patch) | |
| tree | e90918703b09ed84ee259fbbff77daa9c8f3e653 | |
| parent | Merge remote-tracking branch 'origin/main' (diff) | |
| download | senator-sperma-20bc900f7b1182201324ad206cfd5a7a85ec4113.tar.gz senator-sperma-20bc900f7b1182201324ad206cfd5a7a85ec4113.zip | |
fix compression for audio
| -rw-r--r-- | cogs/compression.py | 6 |
1 files changed, 5 insertions, 1 deletions
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): | |||
| 43 | if file_type == "Video": | 43 | if file_type == "Video": |
| 44 | 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}" | 44 | 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}" |
| 45 | elif file_type == "Audio": | 45 | elif file_type == "Audio": |
| 46 | command = f"ffmpeg -y -i {file_path} -ac 1 -b:a 500 -acodec libopus {output_path}" | 46 | if output_path.lower().endswith('.mp3'): |
| 47 | output_path = os.path.splitext(output_path)[0] + os.path.splitext(output_path)[1].replace('.mp3', '') | ||
| 48 | if not output_path.lower().endswith('.ogg'): | ||
| 49 | output_path = os.path.splitext(output_path)[0] + '.ogg' | ||
| 50 | command = f"ffmpeg -y -i {file_path} -c:a libopus -b:a 500 -ar 12000 -ac 1 {output_path}" | ||
| 47 | elif file_type == "Image": | 51 | elif file_type == "Image": |
| 48 | ext = os.path.splitext(file_path)[1].lower() | 52 | ext = os.path.splitext(file_path)[1].lower() |
| 49 | if ext in [".jpg", ".jpeg"]: | 53 | if ext in [".jpg", ".jpeg"]: |
