Add ConvertAACToMP3PP post-processor

pull/33153/head
Connor Mason 6 months ago
parent 8a5c8b8d09
commit 6e22b3b1eb

@ -4,7 +4,8 @@ import os
import subprocess import subprocess
import time import time
import re import re
from pathlib import Path
from typing import Any
from .common import AudioConversionError, PostProcessor from .common import AudioConversionError, PostProcessor
@ -651,3 +652,26 @@ class FFmpegSubtitlesConvertorPP(FFmpegPostProcessor):
} }
return sub_filenames, info return sub_filenames, info
class ConvertAACToMP3PP(FFmpegPostProcessor):
"""
Custom post processor that converts .aac files to .mp3 files
"""
def run(self, info: dict[str, Any]) -> tuple[list[str], dict[str, Any]]:
if info['ext'] == 'aac':
aac_path = Path(info['filepath'])
mp3_path = aac_path.with_suffix('.mp3')
self._downloader.to_screen('[ffmpeg] Converting .aac to .mp3')
options: list[str] = [
'-codec:a', 'libmp3lame',
'-qscale:a', '0',
]
self.run_ffmpeg(str(aac_path), str(mp3_path), options)
aac_path.unlink()
info['filepath'] = str(mp3_path)
info['ext'] = 'mp3'
return [], info

Loading…
Cancel
Save