From 29d08391624b28a218d03534ad1715105e574a2b Mon Sep 17 00:00:00 2001 From: Benau Date: Fri, 31 Mar 2017 12:22:21 +0800 Subject: [PATCH] Move libvpx parameters to user config --- src/config/user_config.hpp | 28 ++++++++++++++++++---------- src/utils/avi_writer.cpp | 9 +++++---- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/config/user_config.hpp b/src/config/user_config.hpp index 0ecc320e3..4725cf6e9 100644 --- a/src/config/user_config.hpp +++ b/src/config/user_config.hpp @@ -562,19 +562,27 @@ namespace UserConfigParams PARAM_PREFIX GroupUserConfigParam m_recording_group PARAM_DEFAULT( GroupUserConfigParam("Recording", "Recording Settings") ); - PARAM_PREFIX BoolUserConfigParam m_record_bmp - PARAM_DEFAULT(BoolUserConfigParam(false, "record_bmp", - &m_recording_group, "Record video using uncompressed bitmap, notice: this " - "will require a lot of space and fast disk access.")); - PARAM_PREFIX BoolUserConfigParam m_limit_game_fps PARAM_DEFAULT(BoolUserConfigParam(true, "limit_game_fps", - &m_recording_group, "Limit game framerate not beyond the fps of recording " - "video.")); + &m_recording_group, "Limit game framerate not beyond the fps of" + " recording video.")); - PARAM_PREFIX IntUserConfigParam m_record_compression - PARAM_DEFAULT(IntUserConfigParam(90, "record_compression", - &m_recording_group, "Specify the compression level of recording video")); + PARAM_PREFIX IntUserConfigParam m_vp_codec + PARAM_DEFAULT(IntUserConfigParam(0, "vp_codec", + &m_recording_group, "Specify the codec for libvpx (VP8 / VP9)")); + + PARAM_PREFIX IntUserConfigParam m_vp_end_usage + PARAM_DEFAULT(IntUserConfigParam(0, "vp_end_usage", + &m_recording_group, "Specify the rate control algorithm for libvpx," + " see enum vpx_rc_mode")); + + PARAM_PREFIX IntUserConfigParam m_vp_bitrate + PARAM_DEFAULT(IntUserConfigParam(20000, "vp_bitrate", + &m_recording_group, "Specify the bitrate for libvpx")); + + PARAM_PREFIX IntUserConfigParam m_recorder_jpg_quality + PARAM_DEFAULT(IntUserConfigParam(90, "recorder_jpg_quality", + &m_recording_group, "Specify the jpg compression level of recorder")); PARAM_PREFIX IntUserConfigParam m_record_fps PARAM_DEFAULT(IntUserConfigParam(30, "record_fps", diff --git a/src/utils/avi_writer.cpp b/src/utils/avi_writer.cpp index 65d4d4bdb..cb41e429d 100644 --- a/src/utils/avi_writer.cpp +++ b/src/utils/avi_writer.cpp @@ -146,10 +146,9 @@ int vpxEncodeFrame(vpx_codec_ctx_t *codec, vpx_image_t *img, int frame_index, // ---------------------------------------------------------------------------- void AVIWriter::resetCaptureFormat() { - m_img_quality = UserConfigParams::m_record_compression; + m_img_quality = UserConfigParams::m_recorder_jpg_quality; m_msec_per_frame = unsigned(1000 / UserConfigParams::m_record_fps); - m_avi_format = - UserConfigParams::m_record_bmp ? AVI_FORMAT_BMP : AVI_FORMAT_JPG; + m_avi_format = AVI_FORMAT_JPG; } // resetCaptureFormat // ---------------------------------------------------------------------------- @@ -193,7 +192,9 @@ void* AVIWriter::vpxEncoder(void *obj) cfg.g_h = height; cfg.g_timebase.num = 1; cfg.g_timebase.den = UserConfigParams::m_record_fps; - //cfg.rc_target_bitrate = 2000; + int end_usage = UserConfigParams::m_vp_end_usage; + cfg.rc_end_usage = (vpx_rc_mode)end_usage; + cfg.rc_target_bitrate = UserConfigParams::m_vp_bitrate; if (vpx_codec_enc_init(&codec, vpx_codec_vp8_cx(), &cfg, 0) > 0) { Log::error("vpxEncoder", "Failed to initialize encoder");