Skip to content

Commit

Permalink
AdvancedWidget: Change codec selection to a choice and add UTVideo.
Browse files Browse the repository at this point in the history
UTVideo was requrested by users based on its compatibility with video editing programs.
  • Loading branch information
TryTwo committed Dec 23, 2024
1 parent f9ce2b9 commit 28a8bde
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 10 deletions.
45 changes: 35 additions & 10 deletions Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,23 @@ void AdvancedWidget::CreateWidgets()
dump_layout->addWidget(m_frame_dumps_resolution_type, 0, 1);

#if defined(HAVE_FFMPEG)
m_dump_use_ffv1 =
new ConfigBool(tr("Use Lossless Codec (FFV1)"), Config::GFX_USE_FFV1, m_game_layer);
// Update EnableBitrate() if options are changed.

const std::vector<std::pair<QString, QString>> options{
{tr("Auto"), QStringLiteral("")},
{QStringLiteral("MPEG4"), QStringLiteral("mpeg4")},
{QStringLiteral("FFV1"), QStringLiteral("ffv1")},
{QStringLiteral("UTVideo"), QStringLiteral("utvideo")}};
m_codec_choice = new ConfigStringChoice(options, Config::GFX_DUMP_CODEC, m_game_layer);

dump_layout->addWidget(new QLabel(tr("Codec:")), 1, 0);
dump_layout->addWidget(m_codec_choice, 1, 1);

m_dump_bitrate = new ConfigInteger(0, 1000000, Config::GFX_BITRATE_KBPS, m_game_layer, 1000);
m_dump_bitrate->setEnabled(!m_dump_use_ffv1->isChecked());
dump_layout->addWidget(m_dump_use_ffv1, 1, 0);
dump_layout->addWidget(new QLabel(tr("Bitrate (kbps):")), 2, 0);
dump_layout->addWidget(m_dump_bitrate, 2, 1);

EnableBitrate();
#endif

dump_layout->addWidget(new QLabel(tr("PNG Compression Level:")), 3, 0);
Expand Down Expand Up @@ -263,11 +273,24 @@ void AdvancedWidget::ConnectWidgets()
[this](bool checked) { emit Settings::Instance().EnableGfxModsChanged(checked); });

#if defined(HAVE_FFMPEG)
connect(m_dump_use_ffv1, &QCheckBox::toggled, this,
[this](bool checked) { m_dump_bitrate->setEnabled(!checked); });
connect(m_codec_choice, &ConfigStringChoice::currentIndexChanged, this,
&AdvancedWidget::EnableBitrate);
#endif
}

#if defined(HAVE_FFMPEG)
void AdvancedWidget::EnableBitrate()
{
const QString& choice = m_codec_choice->currentText();
const bool enable = choice != QStringLiteral("UTVideo") && choice != QStringLiteral("FFV1");

if (m_game_layer)
m_dump_bitrate->setEnabled(enable);
else
m_dump_bitrate->setEnabled(!Config::Get(Config::GFX_USE_FFV1) && enable);
}
#endif

void AdvancedWidget::OnBackendChanged()
{
m_backend_multithreading->setEnabled(g_Config.backend_info.bSupportsMultithreading);
Expand Down Expand Up @@ -391,9 +414,11 @@ void AdvancedWidget::AddDescriptions()
"possible input for external editing software.<br><br><dolphin_emphasis>If unsure, leave "
"this at \"Aspect Ratio Corrected Internal Resolution\".</dolphin_emphasis>");
#if defined(HAVE_FFMPEG)
static const char TR_USE_FFV1_DESCRIPTION[] =
QT_TR_NOOP("Encodes frame dumps using the FFV1 codec.<br><br><dolphin_emphasis>If "
"unsure, leave this unchecked.</dolphin_emphasis>");
static const char TR_CODEC_CHOICE_DESCRIPTION[] = QT_TR_NOOP(
"Selects codec for encoding frame dumps. <br>MPEG4: Lossy. Good compression. Can set "
"bitrate.<br>FFV1: Lossless. Good compression. Slow.<br>UTVideo: Lossless. Fast. Poor "
"compression that produces large video files. Good compatibility with editing "
"programs.<br><br><dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>");
#endif
static const char TR_PNG_COMPRESSION_LEVEL_DESCRIPTION[] =
QT_TR_NOOP("Specifies the zlib compression level to use when saving PNG images (both for "
Expand Down Expand Up @@ -483,7 +508,7 @@ void AdvancedWidget::AddDescriptions()
m_enable_graphics_mods->SetDescription(tr(TR_LOAD_GRAPHICS_MODS_DESCRIPTION));
m_frame_dumps_resolution_type->SetDescription(tr(TR_FRAME_DUMPS_RESOLUTION_TYPE_DESCRIPTION));
#ifdef HAVE_FFMPEG
m_dump_use_ffv1->SetDescription(tr(TR_USE_FFV1_DESCRIPTION));
m_codec_choice->SetDescription(tr(TR_CODEC_CHOICE_DESCRIPTION));
#endif
m_png_compression_level->SetDescription(tr(TR_PNG_COMPRESSION_LEVEL_DESCRIPTION));
m_enable_cropping->SetDescription(tr(TR_CROPPING_DESCRIPTION));
Expand Down
5 changes: 5 additions & 0 deletions Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
class ConfigBool;
class ConfigChoice;
class ConfigInteger;
class ConfigStringChoice;
class GameConfigWidget;
class GraphicsWindow;

Expand All @@ -27,6 +28,9 @@ class AdvancedWidget final : public QWidget
void CreateWidgets();
void ConnectWidgets();
void AddDescriptions();
#if defined(HAVE_FFMPEG)
void EnableBitrate();
#endif
void OnBackendChanged();
void OnEmulationStateChanged(bool running);

Expand Down Expand Up @@ -62,6 +66,7 @@ class AdvancedWidget final : public QWidget
// Frame dumping
ConfigBool* m_dump_use_ffv1;
ConfigChoice* m_frame_dumps_resolution_type;
ConfigStringChoice* m_codec_choice;
ConfigInteger* m_dump_bitrate;
ConfigInteger* m_png_compression_level;

Expand Down

0 comments on commit 28a8bde

Please sign in to comment.