UI: Add Apple H.264 hardware encoder to simple mode

Adds the Apple Silicon hardware encoder as a simple mode option. For
recordings this only requires being on Apple Silicon (since we use the
Constant Quality setting), while for streaming it requires the user to
be on macOS 13 or newer (since we're using CBR).
This commit is contained in:
gxalpha
2022-07-11 23:45:43 +02:00
committed by Sebastian Beckmann
parent 566ce79b0f
commit 29ae00e4af
6 changed files with 68 additions and 1 deletions
+21
View File
@@ -289,6 +289,7 @@ struct SimpleOutput : BasicOutputHandler {
void UpdateRecordingSettings_nvenc_hevc(int cqp);
#endif
void UpdateRecordingSettings_amd_cqp(int cqp);
void UpdateRecordingSettings_apple(int quality);
void UpdateRecordingSettings();
void UpdateRecordingAudioSettings();
virtual void Update() override;
@@ -402,6 +403,9 @@ void SimpleOutput::LoadRecordingPreset()
: "ffmpeg_hevc_nvenc";
LoadRecordingPreset_Lossy(id);
#endif
} else if (strcmp(encoder, SIMPLE_ENCODER_APPLE_H264) == 0) {
LoadRecordingPreset_Lossy(
"com.apple.videotoolbox.videoencoder.ave.avc");
}
usingRecordingPreset = true;
@@ -438,6 +442,10 @@ SimpleOutput::SimpleOutput(OBSBasic *main_) : BasicOutputHandler(main_)
LoadStreamingPreset_Lossy(id);
#endif
} else if (strcmp(encoder, SIMPLE_ENCODER_APPLE_H264) == 0) {
LoadStreamingPreset_Lossy(
"com.apple.videotoolbox.videoencoder.ave.avc");
} else {
LoadStreamingPreset_Lossy("obs_x264");
}
@@ -690,6 +698,16 @@ void SimpleOutput::UpdateRecordingSettings_nvenc_hevc(int cqp)
}
#endif
void SimpleOutput::UpdateRecordingSettings_apple(int quality)
{
OBSDataAutoRelease settings = obs_data_create();
obs_data_set_string(settings, "rate_control", "CRF");
obs_data_set_string(settings, "profile", "high");
obs_data_set_int(settings, "quality", quality);
obs_encoder_update(videoRecording, settings);
}
void SimpleOutput::UpdateStreamingSettings_amd(obs_data_t *settings,
int bitrate)
{
@@ -754,6 +772,9 @@ void SimpleOutput::UpdateRecordingSettings()
} else if (videoEncoder == SIMPLE_ENCODER_NVENC_HEVC) {
UpdateRecordingSettings_nvenc_hevc(crf);
#endif
} else if (videoEncoder == SIMPLE_ENCODER_APPLE_H264) {
/* These are magic numbers. 0 - 100, more is better. */
UpdateRecordingSettings_apple(ultra_hq ? 70 : 50);
}
UpdateRecordingAudioSettings();
}