def check_nvidia_requirements(application_preferences): """ Runs any tests needed to check if the system supports Nvidia's NVENC encoder. This will check if NVENC works and, if so, how many NVENC processes can be ran in parallel. :param application_preferences: Application's preferences. """ NvidiaHelper.setup_nvenc_max_workers(application_preferences)
def _rebuild_ts_video_codec_combobox(self): if NvidiaHelper.is_nvenc_supported(): self._rebuild_video_codec_combobox( GeneralSettings.VIDEO_CODEC_TS_NVENC_UI_LIST) else: self._rebuild_video_codec_combobox( GeneralSettings.VIDEO_CODEC_TS_UI_LIST)
def _apply_nvdec_args(self, ffmpeg_args): if self.is_video_settings_nvenc() and NvidiaHelper.is_nvdec_supported( ): ffmpeg_args.extend(self.NVDEC_ARGS) if self.picture_settings.crop is None: ffmpeg_args.extend(self.NVDEC_OUT_FORMAT_ARGS)
def _setup_video_codec_widgets(self): video_codec_combobox = self.gtk_builder.get_object("video_codec_combobox") if NvidiaHelper.is_nvenc_supported(): video_codec_list = GeneralSettings.VIDEO_CODEC_MP4_NVENC_UI_LIST else: video_codec_list = GeneralSettings.VIDEO_CODEC_MP4_UI_LIST UIHelper.setup_combobox(video_codec_combobox, video_codec_list)
def empty_queue(self): self._empty_codec_queue(self.x264_codec_queue) self._empty_codec_queue(self.x265_codec_queue) self._empty_codec_queue(self.vp9_codec_queue) self._empty_codec_queue(self.copy_codec_queue) if NvidiaHelper.is_nvenc_supported(): self._empty_codec_queue(self.nvenc_codec_queue)
def __init__(self, encoder_queue): self.encoder_queue = encoder_queue self.parallel_nvenc_tasks_queue = queue.Queue() self.number_of_tasks = NvidiaHelper.nvenc_max_workers self.parallel_nvenc_tasks_startup_thread = threading.Thread( target=self._start_parallel_nvenc_tasks_thread, args=(), daemon=True) if NvidiaHelper.is_nvenc_supported(): self.parallel_nvenc_tasks_startup_thread.start() else: logging.info('--- NVENC ENCODING THREAD DISABLED ---')
def set_stop_state(self): """ Sends a stop task to all codec queues. """ self._set_codec_queue_stop_state(self.x264_codec_queue, self.number_of_x264_tasks) self._set_codec_queue_stop_state(self.x265_codec_queue, self.number_of_x265_tasks) self._set_codec_queue_stop_state(self.vp9_codec_queue, self.number_of_vp9_tasks) self._set_codec_queue_stop_state(self.copy_codec_queue, self.number_of_copy_codec_tasks) if NvidiaHelper.is_nvenc_supported(): self._set_codec_queue_stop_state(self.nvenc_codec_queue, self.number_of_nvenc_tasks)
def _setup_mkv_video_codec_widgets(self, video_codec_text): if NvidiaHelper.is_nvenc_supported(): if video_codec_text in GeneralSettings.VIDEO_CODEC_MKV_NVENC_UI_LIST: self.video_codec_combobox.set_active( GeneralSettings.VIDEO_CODEC_MKV_NVENC_UI_LIST.index( video_codec_text)) return else: if video_codec_text in GeneralSettings.VIDEO_CODEC_MKV_UI_LIST: self.video_codec_combobox.set_active( GeneralSettings.VIDEO_CODEC_MKV_UI_LIST.index( video_codec_text)) return self.is_widgets_setting_up = False self._reset_and_signal_video_codec_combobox() self.is_widgets_setting_up = True
def _generate_picture_settings_args(self): args = [] if self.is_video_settings_nvenc() and NvidiaHelper.is_npp_supported( ) and self.picture_settings.crop is None: args.extend(self.picture_settings.get_scale_nvenc_args()) else: for setting, arg in self.picture_settings.ffmpeg_args.items(): if setting == '-map': for subtitle_stream_arg in arg: args.append(setting) args.append(subtitle_stream_arg) continue if arg is not None: args.append(setting) args.append(arg) return args
def _setup_codec_queues(self, application_preferences): threading.Thread(target=self._setup_x264_codec_queue, args=(application_preferences, ), daemon=True).start() threading.Thread(target=self._setup_x265_codec_queue, args=(application_preferences, ), daemon=True).start() threading.Thread(target=self._setup_vp9_codec_queue, args=(application_preferences, ), daemon=True).start() threading.Thread(target=self._setup_copy_codec_queue, args=(), daemon=True).start() if NvidiaHelper.is_nvenc_supported(): threading.Thread(target=self._setup_nvenc_codec_queue, args=(), daemon=True).start() else: logging.info('--- NVENC ENCODING THREAD DISABLED ---')
def wait_until_nvenc_available(active_row): while True: if NvidiaHelper.is_nvenc_available() or active_row.stopped: break time.sleep(3)