def test_ensure_we_can_convert_subtitles_from_mkv_to_avi_in_args(self): # Get the destination container object by it's name destination_container = self.get_container('avi') # Fetch a list of args from the unffmpeg subtitle handler subtitle_handle = unffmpeg.SubtitleHandle(mkv_ffprobe.mkv_multiple_subtitles_ffprobe, destination_container) subtitle_args = subtitle_handle.args() # Assert the streams to map array is not empty assert subtitle_args['streams_to_map'] # Assert the streams to encode array is not empty assert subtitle_args['streams_to_encode']
def test_ensure_we_can_remove_subtitles_in_args(self): # Get the destination container object by it's name destination_container = self.get_container('matroska') # Fetch a list of args from the unffmpeg subtitle handler subtitle_handle = unffmpeg.SubtitleHandle(mkv_ffprobe.mkv_multiple_subtitles_ffprobe, destination_container) # Remove the subtitles for this (even though the destination supports subtitles) subtitle_handle.remove_subtitle_streams = True subtitle_args = subtitle_handle.args() # Assert the streams to map array is not empty assert not subtitle_args['streams_to_map'] # Assert the streams to encode array is not empty assert not subtitle_args['streams_to_encode']
def generate_ffmpeg_args(self,): # ffmpeg -i /library/XXXXX.mkv \ # -c:v libx265 \ # -map 0:0 -map 0:1 -map 0:1 \ # -c:a:0 copy \ # -c:a:1 libmp3lame -b:a:0 192k -ac 2 \ # -y /cache/XXXXX.mkv # # Read video information for the input file file_probe = self.file_in['file_probe'] if not file_probe: return False # current_container = unffmpeg.containers.grab_module(self.settings.OUT_CONTAINER) destination_container = unffmpeg.containers.grab_module(self.settings.OUT_CONTAINER) # Suppress printing banner. (-hide_banner) # Set loglevel to info ("-loglevel", "info") # Allow experimental encoder config ("-strict", "-2") # command = ["-hide_banner", "-loglevel", "info", "-strict", "-2", "-max_muxing_queue_size", "512"] # Read stream data streams_to_map = [] streams_to_encode = [] # Set video encoding args video_codec_handle = unffmpeg.VideoCodecHandle(file_probe) if not self.settings.ENABLE_VIDEO_ENCODING: video_codec_handle.disable_video_encoding = True video_codec_handle.set_video_codec(self.settings.VIDEO_CODEC) video_codec_args = video_codec_handle.args() streams_to_map = streams_to_map + video_codec_args['streams_to_map'] streams_to_encode = streams_to_encode + video_codec_args['streams_to_encode'] # Set audio encoding args audio_codec_handle = unffmpeg.AudioCodecHandle(file_probe) if not self.settings.ENABLE_AUDIO_ENCODING: audio_codec_handle.disable_audio_encoding = True # Are we transcoding audio streams to a configured codec? audio_codec_handle.enable_audio_stream_transcoding = self.settings.ENABLE_AUDIO_STREAM_TRANSCODING audio_codec_handle.audio_codec_transcoding = self.settings.AUDIO_CODEC audio_codec_handle.audio_encoder_transcoding = self.settings.AUDIO_STREAM_ENCODER # Are we cloning audio streams to stereo streams? audio_codec_handle.enable_audio_stream_stereo_cloning = self.settings.ENABLE_AUDIO_STREAM_STEREO_CLONING audio_codec_handle.set_audio_codec_with_default_encoder_cloning(self.settings.AUDIO_CODEC_CLONING) audio_codec_handle.audio_stereo_stream_bitrate = self.settings.AUDIO_STEREO_STREAM_BITRATE # Fetch args audio_codec_args = audio_codec_handle.args() streams_to_map = streams_to_map + audio_codec_args['streams_to_map'] streams_to_encode = streams_to_encode + audio_codec_args['streams_to_encode'] # Set subtitle encoding args subtitle_handle = unffmpeg.SubtitleHandle(file_probe, destination_container) if self.settings.REMOVE_SUBTITLE_STREAMS: subtitle_handle.remove_subtitle_streams = True subtitle_args = subtitle_handle.args() streams_to_map = streams_to_map + subtitle_args['streams_to_map'] streams_to_encode = streams_to_encode + subtitle_args['streams_to_encode'] # Map streams command = command + streams_to_map # Add arguments for creating streams command = command + streams_to_encode self._log(" ".join(command), level='debug') return command