from batman.codec_interface import base_codec from batman.codec_interface import ffmpeg_base_codec import subprocess class LibFlac(ffmpeg_base_codec.FFMpegBaseAudioCodec): PRETTY_NAME = "FLAC" TECHNICAL_NAME = "libflac" SOLO_ENCODING = True def make_valid_file_name_from_caption(self, caption): return ffmpeg_base_codec.prepare_caption(caption) + ".flac" def encode(self, out_path, avi_file): subprocess.call([self.ffmpeg_command, "-y", "-i", avi_file, "-vn", "-codec:a", "flac", out_path]) base_codec.register_audio_codec(LibFlac)
return False def make_valid_file_name_from_caption(self, caption): caption = re.sub("\/", "-", caption) caption = re.sub("\"", "", caption) caption = re.sub("'", "", caption) # Double and single quotes # Ignore last dot, just in case caption = re.sub("[.]$", "", caption) # Any other dots... caption = re.sub("[.]", "_", caption) treated_result = caption + ".mp3" return treated_result def encode(self, out_path, avi_file): if definitions.WINDOWS: wav_file = tempfile.NamedTemporaryFile(suffix=".wav", delete=False) wav_file.close() else: wav_file = tempfile.NamedTemporaryFile(suffix=".wav") subprocess.call([self.ffmpeg_command, "-y", "-i", avi_file, "-vn", wav_file.name], stdout=subprocess.DEVNULL) subprocess.call([self.lame_command, "-V2", wav_file.name, out_path], stdout=subprocess.DEVNULL) if definitions.WINDOWS: os.unlink(wav_file.name) base_codec.register_audio_codec(LibMP3Lame)
from batman.codec_interface import base_codec from batman.codec_interface import ffmpeg_base_codec import subprocess class LibVorbis(ffmpeg_base_codec.FFMpegBaseAudioCodec): PRETTY_NAME = "OGG(Vorbis)" TECHNICAL_NAME = "libvorbis" SOLO_ENCODING = True def make_valid_file_name_from_caption(self, caption): return ffmpeg_base_codec.prepare_caption(caption) + ".ogg" def encode(self, out_path, avi_file): subprocess.call([self.ffmpeg_command, "-y", "-i", avi_file, "-vn", "-codec:a", "libvorbis", "-qscale:a", "3", out_path]) base_codec.register_audio_codec(LibVorbis)