From 834da14329e43d891fd4d8e2087a6e5b346f0aa3 Mon Sep 17 00:00:00 2001 From: zhupengfei Date: Wed, 29 Jan 2020 14:57:16 +0800 Subject: [PATCH] citra, citra_qt: Add video dumping config read/write The default values are VP9/libvorbis just like before. The default configuration is provided for VP9 --- src/citra/config.cpp | 27 ++++++++++ src/citra/default_ini.h | 26 ++++++++++ src/citra_qt/configuration/config.cpp | 72 +++++++++++++++++++++++++++ src/citra_qt/configuration/config.h | 2 + 4 files changed, 127 insertions(+) diff --git a/src/citra/config.cpp b/src/citra/config.cpp index b2c878ddf..92efb310b 100644 --- a/src/citra/config.cpp +++ b/src/citra/config.cpp @@ -264,6 +264,33 @@ void Config::ReadValues() { sdl2_config->GetString("WebService", "web_api_url", "https://api.citra-emu.org"); Settings::values.citra_username = sdl2_config->GetString("WebService", "citra_username", ""); Settings::values.citra_token = sdl2_config->GetString("WebService", "citra_token", ""); + + // Video Dumping + Settings::values.output_format = + sdl2_config->GetString("Video Dumping", "output_format", "webm"); + Settings::values.format_options = sdl2_config->GetString("Video Dumping", "format_options", ""); + + Settings::values.video_encoder = + sdl2_config->GetString("Video Dumping", "video_encoder", "libvpx-vp9"); + + // Options for variable bit rate live streaming taken from here: + // https://developers.google.com/media/vp9/live-encoding + std::string default_video_options; + if (Settings::values.video_encoder == "libvpx-vp9") { + default_video_options = + "quality:realtime,speed:6,tile-columns:4,frame-parallel:1,threads:8,row-mt:1"; + } + Settings::values.video_encoder_options = + sdl2_config->GetString("Video Dumping", "video_encoder_options", default_video_options); + Settings::values.video_bitrate = + sdl2_config->GetInteger("Video Dumping", "video_bitrate", 2500000); + + Settings::values.audio_encoder = + sdl2_config->GetString("Video Dumping", "audio_encoder", "libvorbis"); + Settings::values.audio_encoder_options = + sdl2_config->GetString("Video Dumping", "audio_encoder_options", ""); + Settings::values.audio_bitrate = + sdl2_config->GetInteger("Video Dumping", "audio_bitrate", 64000); } void Config::Reload() { diff --git a/src/citra/default_ini.h b/src/citra/default_ini.h index 9c441e354..6af827c09 100644 --- a/src/citra/default_ini.h +++ b/src/citra/default_ini.h @@ -295,5 +295,31 @@ web_api_url = https://api.citra-emu.org # See https://profile.citra-emu.org/ for more info citra_username = citra_token = + +[Video Dumping] +# Format of the video to output, default: webm +output_format = + +# Options passed to the muxer (optional) +# This is a param package, format: [key1]:[value1],[key2]:[value2],... +format_options = + +# Video encoder used, default: libvpx-vp9 +video_encoder = + +# Options passed to the video codec (optional) +video_encoder_options = + +# Video bitrate, default: 2500000 +video_bitrate = + +# Audio encoder used, default: libvorbis +audio_encoder = + +# Options passed to the audio codec (optional) +audio_encoder_options = + +# Audio bitrate, default: 64000 +audio_bitrate = )"; } diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp index 82274bff0..416d05f09 100644 --- a/src/citra_qt/configuration/config.cpp +++ b/src/citra_qt/configuration/config.cpp @@ -93,6 +93,7 @@ void Config::ReadValues() { ReadMiscellaneousValues(); ReadDebuggingValues(); ReadWebServiceValues(); + ReadVideoDumpingValues(); ReadUIValues(); ReadUtilityValues(); } @@ -485,6 +486,49 @@ void Config::ReadSystemValues() { qt_config->endGroup(); } +// Options for variable bit rate live streaming taken from here: +// https://developers.google.com/media/vp9/live-encoding +const QString DEFAULT_VIDEO_ENCODER_OPTIONS = + QStringLiteral("quality:realtime,speed:6,tile-columns:4,frame-parallel:1,threads:8,row-mt:1"); +const QString DEFAULT_AUDIO_ENCODER_OPTIONS = QString{}; + +void Config::ReadVideoDumpingValues() { + qt_config->beginGroup(QStringLiteral("VideoDumping")); + + Settings::values.output_format = + ReadSetting(QStringLiteral("output_format"), QStringLiteral("webm")) + .toString() + .toStdString(); + Settings::values.format_options = + ReadSetting(QStringLiteral("format_options")).toString().toStdString(); + + Settings::values.video_encoder = + ReadSetting(QStringLiteral("video_encoder"), QStringLiteral("libvpx-vp9")) + .toString() + .toStdString(); + + Settings::values.video_encoder_options = + ReadSetting(QStringLiteral("video_encoder_options"), DEFAULT_VIDEO_ENCODER_OPTIONS) + .toString() + .toStdString(); + + Settings::values.video_bitrate = + ReadSetting(QStringLiteral("video_bitrate"), 2500000).toULongLong(); + + Settings::values.audio_encoder = + ReadSetting(QStringLiteral("audio_encoder"), QStringLiteral("libvorbis")) + .toString() + .toStdString(); + Settings::values.audio_encoder_options = + ReadSetting(QStringLiteral("audio_encoder_options"), DEFAULT_AUDIO_ENCODER_OPTIONS) + .toString() + .toStdString(); + Settings::values.audio_bitrate = + ReadSetting(QStringLiteral("audio_bitrate"), 64000).toULongLong(); + + qt_config->endGroup(); +} + void Config::ReadUIValues() { qt_config->beginGroup(QStringLiteral("UI")); @@ -617,6 +661,7 @@ void Config::SaveValues() { SaveMiscellaneousValues(); SaveDebuggingValues(); SaveWebServiceValues(); + SaveVideoDumpingValues(); SaveUIValues(); SaveUtilityValues(); } @@ -915,6 +960,33 @@ void Config::SaveSystemValues() { qt_config->endGroup(); } +void Config::SaveVideoDumpingValues() { + qt_config->beginGroup(QStringLiteral("VideoDumping")); + + WriteSetting(QStringLiteral("output_format"), + QString::fromStdString(Settings::values.output_format), QStringLiteral("webm")); + WriteSetting(QStringLiteral("format_options"), + QString::fromStdString(Settings::values.format_options)); + WriteSetting(QStringLiteral("video_encoder"), + QString::fromStdString(Settings::values.video_encoder), + QStringLiteral("libvpx-vp9")); + WriteSetting(QStringLiteral("video_encoder_options"), + QString::fromStdString(Settings::values.video_encoder_options), + DEFAULT_VIDEO_ENCODER_OPTIONS); + WriteSetting(QStringLiteral("video_bitrate"), + static_cast(Settings::values.video_bitrate), 2500000); + WriteSetting(QStringLiteral("audio_encoder"), + QString::fromStdString(Settings::values.audio_encoder), + QStringLiteral("libvorbis")); + WriteSetting(QStringLiteral("audio_encoder_options"), + QString::fromStdString(Settings::values.audio_encoder_options), + DEFAULT_AUDIO_ENCODER_OPTIONS); + WriteSetting(QStringLiteral("audio_bitrate"), + static_cast(Settings::values.audio_bitrate), 64000); + + qt_config->endGroup(); +} + void Config::SaveUIValues() { qt_config->beginGroup(QStringLiteral("UI")); diff --git a/src/citra_qt/configuration/config.h b/src/citra_qt/configuration/config.h index 7d65d41b6..8b1cf8193 100644 --- a/src/citra_qt/configuration/config.h +++ b/src/citra_qt/configuration/config.h @@ -44,6 +44,7 @@ private: void ReadUpdaterValues(); void ReadUtilityValues(); void ReadWebServiceValues(); + void ReadVideoDumpingValues(); void SaveValues(); void SaveAudioValues(); @@ -65,6 +66,7 @@ private: void SaveUpdaterValues(); void SaveUtilityValues(); void SaveWebServiceValues(); + void SaveVideoDumpingValues(); QVariant ReadSetting(const QString& name) const; QVariant ReadSetting(const QString& name, const QVariant& default_value) const;