2024-12-11 17:43:35 +01:00
|
|
|
#include "SimpleOutput.hpp"
|
2020-06-20 07:42:14 -07:00
|
|
|
|
2024-12-11 17:43:35 +01:00
|
|
|
#include <utility/audio-encoders.hpp>
|
|
|
|
|
#include <utility/StartMultiTrackVideoStreamingGuard.hpp>
|
|
|
|
|
#include <widgets/OBSBasic.hpp>
|
2024-07-08 14:07:10 +02:00
|
|
|
|
2024-12-11 17:43:35 +01:00
|
|
|
#include <qt-wrappers.hpp>
|
2024-07-08 14:07:10 +02:00
|
|
|
|
2024-12-11 17:43:35 +01:00
|
|
|
using namespace std;
|
2024-07-08 14:07:10 +02:00
|
|
|
|
2022-12-17 18:26:59 +01:00
|
|
|
static bool CreateSimpleAACEncoder(OBSEncoder &res, int bitrate, const char *name, size_t idx)
|
2015-06-06 01:52:22 +02:00
|
|
|
{
|
2022-12-17 18:16:05 +01:00
|
|
|
const char *id_ = GetSimpleAACEncoderForBitrate(bitrate);
|
2015-07-02 10:00:22 +02:00
|
|
|
if (!id_) {
|
|
|
|
|
res = nullptr;
|
|
|
|
|
return false;
|
2015-06-06 01:52:22 +02:00
|
|
|
}
|
|
|
|
|
|
2022-12-17 18:26:59 +01:00
|
|
|
res = obs_audio_encoder_create(id_, name, nullptr, idx, nullptr);
|
|
|
|
|
|
|
|
|
|
if (res) {
|
|
|
|
|
obs_encoder_release(res);
|
2015-07-02 10:00:22 +02:00
|
|
|
return true;
|
2022-12-17 18:26:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool CreateSimpleOpusEncoder(OBSEncoder &res, int bitrate, const char *name, size_t idx)
|
|
|
|
|
{
|
|
|
|
|
const char *id_ = GetSimpleOpusEncoderForBitrate(bitrate);
|
|
|
|
|
if (!id_) {
|
|
|
|
|
res = nullptr;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-07-02 10:00:22 +02:00
|
|
|
|
|
|
|
|
res = obs_audio_encoder_create(id_, name, nullptr, idx, nullptr);
|
|
|
|
|
|
|
|
|
|
if (res) {
|
|
|
|
|
obs_encoder_release(res);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
2015-06-06 01:52:22 +02:00
|
|
|
}
|
|
|
|
|
|
2024-12-11 17:43:35 +01:00
|
|
|
extern bool EncoderAvailable(const char *encoder);
|
2015-02-06 03:17:33 -08:00
|
|
|
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
void SimpleOutput::LoadRecordingPreset_Lossless()
|
|
|
|
|
{
|
|
|
|
|
fileOutput = obs_output_create("ffmpeg_output", "simple_ffmpeg_output", nullptr, nullptr);
|
|
|
|
|
if (!fileOutput)
|
|
|
|
|
throw "Failed to create recording FFmpeg output "
|
|
|
|
|
"(simple output)";
|
|
|
|
|
|
2021-11-26 22:25:39 +13:00
|
|
|
OBSDataAutoRelease settings = obs_data_create();
|
2016-02-09 18:46:15 -08:00
|
|
|
obs_data_set_string(settings, "format_name", "avi");
|
2015-09-19 21:21:34 -07:00
|
|
|
obs_data_set_string(settings, "video_encoder", "utvideo");
|
2016-02-09 19:24:44 -08:00
|
|
|
obs_data_set_string(settings, "audio_encoder", "pcm_s16le");
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
|
|
|
|
|
obs_output_update(fileOutput, settings);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-06 20:17:55 -07:00
|
|
|
void SimpleOutput::LoadRecordingPreset_Lossy(const char *encoderId)
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
{
|
2022-05-06 20:17:55 -07:00
|
|
|
videoRecording = obs_video_encoder_create(encoderId, "simple_video_recording", nullptr, nullptr);
|
|
|
|
|
if (!videoRecording)
|
|
|
|
|
throw "Failed to create video recording encoder (simple output)";
|
|
|
|
|
obs_encoder_release(videoRecording);
|
2016-04-18 00:56:51 -07:00
|
|
|
}
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
|
2022-05-06 20:17:55 -07:00
|
|
|
void SimpleOutput::LoadStreamingPreset_Lossy(const char *encoderId)
|
2016-04-18 00:56:51 -07:00
|
|
|
{
|
2022-05-06 20:17:55 -07:00
|
|
|
videoStreaming = obs_video_encoder_create(encoderId, "simple_video_stream", nullptr, nullptr);
|
|
|
|
|
if (!videoStreaming)
|
|
|
|
|
throw "Failed to create video streaming encoder (simple output)";
|
|
|
|
|
obs_encoder_release(videoStreaming);
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
}
|
|
|
|
|
|
2022-07-23 20:52:14 -07:00
|
|
|
/* mistakes have been made to lead us to this. */
|
|
|
|
|
const char *get_simple_output_encoder(const char *encoder)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp(encoder, SIMPLE_ENCODER_X264) == 0) {
|
|
|
|
|
return "obs_x264";
|
|
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_X264_LOWCPU) == 0) {
|
|
|
|
|
return "obs_x264";
|
|
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_QSV) == 0) {
|
2022-11-21 17:33:20 -08:00
|
|
|
return "obs_qsv11_v2";
|
2022-11-21 17:56:05 -08:00
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_QSV_AV1) == 0) {
|
|
|
|
|
return "obs_qsv11_av1";
|
2022-07-23 20:52:14 -07:00
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_AMD) == 0) {
|
|
|
|
|
return "h264_texture_amf";
|
|
|
|
|
#ifdef ENABLE_HEVC
|
|
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_AMD_HEVC) == 0) {
|
|
|
|
|
return "h265_texture_amf";
|
|
|
|
|
#endif
|
2022-11-08 00:38:23 -08:00
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_AMD_AV1) == 0) {
|
|
|
|
|
return "av1_texture_amf";
|
2022-07-23 20:52:14 -07:00
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_NVENC) == 0) {
|
2024-04-12 05:09:15 +02:00
|
|
|
return EncoderAvailable("obs_nvenc_h264_tex") ? "obs_nvenc_h264_tex" : "ffmpeg_nvenc";
|
2022-07-23 20:52:14 -07:00
|
|
|
#ifdef ENABLE_HEVC
|
|
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_NVENC_HEVC) == 0) {
|
2024-04-12 05:09:15 +02:00
|
|
|
return EncoderAvailable("obs_nvenc_hevc_tex") ? "obs_nvenc_hevc_tex" : "ffmpeg_hevc_nvenc";
|
2022-07-23 20:52:14 -07:00
|
|
|
#endif
|
2022-09-19 01:55:19 -07:00
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_NVENC_AV1) == 0) {
|
2024-04-12 05:09:15 +02:00
|
|
|
return "obs_nvenc_av1_tex";
|
2022-07-23 20:52:14 -07:00
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_APPLE_H264) == 0) {
|
|
|
|
|
return "com.apple.videotoolbox.videoencoder.ave.avc";
|
2022-10-23 03:55:20 +02:00
|
|
|
#ifdef ENABLE_HEVC
|
|
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_APPLE_HEVC) == 0) {
|
|
|
|
|
return "com.apple.videotoolbox.videoencoder.ave.hevc";
|
|
|
|
|
#endif
|
2022-07-23 20:52:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "obs_x264";
|
|
|
|
|
}
|
|
|
|
|
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
void SimpleOutput::LoadRecordingPreset()
|
|
|
|
|
{
|
|
|
|
|
const char *quality = config_get_string(main->Config(), "SimpleOutput", "RecQuality");
|
|
|
|
|
const char *encoder = config_get_string(main->Config(), "SimpleOutput", "RecEncoder");
|
2022-12-17 18:26:59 +01:00
|
|
|
const char *audio_encoder = config_get_string(main->Config(), "SimpleOutput", "RecAudioEncoder");
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
|
|
|
|
|
videoEncoder = encoder;
|
|
|
|
|
videoQuality = quality;
|
|
|
|
|
ffmpegOutput = false;
|
|
|
|
|
|
|
|
|
|
if (strcmp(quality, "Stream") == 0) {
|
2022-05-06 20:17:55 -07:00
|
|
|
videoRecording = videoStreaming;
|
2022-12-17 18:26:59 +01:00
|
|
|
audioRecording = audioStreaming;
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
usingRecordingPreset = false;
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
} else if (strcmp(quality, "Lossless") == 0) {
|
|
|
|
|
LoadRecordingPreset_Lossless();
|
|
|
|
|
usingRecordingPreset = true;
|
|
|
|
|
ffmpegOutput = true;
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
} else {
|
2016-04-18 00:56:51 -07:00
|
|
|
lowCPUx264 = false;
|
|
|
|
|
|
2022-07-23 20:52:14 -07:00
|
|
|
if (strcmp(encoder, SIMPLE_ENCODER_X264_LOWCPU) == 0)
|
2016-04-18 00:56:51 -07:00
|
|
|
lowCPUx264 = true;
|
2022-07-23 20:52:14 -07:00
|
|
|
LoadRecordingPreset_Lossy(get_simple_output_encoder(encoder));
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
usingRecordingPreset = true;
|
2016-04-18 00:56:51 -07:00
|
|
|
|
2022-12-17 18:26:59 +01:00
|
|
|
bool success = false;
|
|
|
|
|
|
|
|
|
|
if (strcmp(audio_encoder, "opus") == 0)
|
|
|
|
|
success = CreateSimpleOpusEncoder(audioRecording, 192, "simple_opus_recording", 0);
|
|
|
|
|
else
|
|
|
|
|
success = CreateSimpleAACEncoder(audioRecording, 192, "simple_aac_recording", 0);
|
|
|
|
|
|
|
|
|
|
if (!success)
|
|
|
|
|
throw "Failed to create audio recording encoder "
|
2016-04-18 00:56:51 -07:00
|
|
|
"(simple output)";
|
2022-07-22 15:28:26 +02:00
|
|
|
for (int i = 0; i < MAX_AUDIO_MIXES; i++) {
|
|
|
|
|
char name[23];
|
|
|
|
|
if (strcmp(audio_encoder, "opus") == 0) {
|
|
|
|
|
snprintf(name, sizeof name, "simple_opus_recording%d", i);
|
|
|
|
|
success = CreateSimpleOpusEncoder(audioTrack[i], GetAudioBitrate(), name, i);
|
|
|
|
|
} else {
|
|
|
|
|
snprintf(name, sizeof name, "simple_aac_recording%d", i);
|
|
|
|
|
success = CreateSimpleAACEncoder(audioTrack[i], GetAudioBitrate(), name, i);
|
|
|
|
|
}
|
|
|
|
|
if (!success)
|
|
|
|
|
throw "Failed to create multi-track audio recording encoder "
|
|
|
|
|
"(simple output)";
|
|
|
|
|
}
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-17 18:26:59 +01:00
|
|
|
#define SIMPLE_ARCHIVE_NAME "simple_archive_audio"
|
2020-12-03 00:59:43 -08:00
|
|
|
|
2015-02-06 03:17:33 -08:00
|
|
|
SimpleOutput::SimpleOutput(OBSBasic *main_) : BasicOutputHandler(main_)
|
|
|
|
|
{
|
2016-04-18 00:56:51 -07:00
|
|
|
const char *encoder = config_get_string(main->Config(), "SimpleOutput", "StreamEncoder");
|
2022-12-17 18:26:59 +01:00
|
|
|
const char *audio_encoder = config_get_string(main->Config(), "SimpleOutput", "StreamAudioEncoder");
|
2019-02-05 18:22:40 -08:00
|
|
|
|
2022-07-23 20:52:14 -07:00
|
|
|
LoadStreamingPreset_Lossy(get_simple_output_encoder(encoder));
|
2015-02-06 03:17:33 -08:00
|
|
|
|
2022-12-17 18:26:59 +01:00
|
|
|
bool success = false;
|
|
|
|
|
|
|
|
|
|
if (strcmp(audio_encoder, "opus") == 0)
|
|
|
|
|
success = CreateSimpleOpusEncoder(audioStreaming, GetAudioBitrate(), "simple_opus", 0);
|
|
|
|
|
else
|
|
|
|
|
success = CreateSimpleAACEncoder(audioStreaming, GetAudioBitrate(), "simple_aac", 0);
|
|
|
|
|
|
|
|
|
|
if (!success)
|
|
|
|
|
throw "Failed to create audio streaming encoder (simple output)";
|
|
|
|
|
|
|
|
|
|
if (strcmp(audio_encoder, "opus") == 0)
|
|
|
|
|
success = CreateSimpleOpusEncoder(audioArchive, GetAudioBitrate(), SIMPLE_ARCHIVE_NAME, 1);
|
|
|
|
|
else
|
|
|
|
|
success = CreateSimpleAACEncoder(audioArchive, GetAudioBitrate(), SIMPLE_ARCHIVE_NAME, 1);
|
|
|
|
|
|
|
|
|
|
if (!success)
|
|
|
|
|
throw "Failed to create audio archive encoder (simple output)";
|
2015-02-06 03:17:33 -08:00
|
|
|
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
LoadRecordingPreset();
|
|
|
|
|
|
|
|
|
|
if (!ffmpegOutput) {
|
2016-12-09 14:40:04 -08:00
|
|
|
bool useReplayBuffer = config_get_bool(main->Config(), "SimpleOutput", "RecRB");
|
2024-04-27 03:55:47 +02:00
|
|
|
const char *recFormat = config_get_string(main->Config(), "SimpleOutput", "RecFormat2");
|
|
|
|
|
|
2016-12-09 14:40:04 -08:00
|
|
|
if (useReplayBuffer) {
|
2021-11-26 22:25:39 +13:00
|
|
|
OBSDataAutoRelease hotkey;
|
2016-12-07 05:21:44 -08:00
|
|
|
const char *str = config_get_string(main->Config(), "Hotkeys", "ReplayBuffer");
|
2020-06-18 23:43:52 +02:00
|
|
|
if (str)
|
|
|
|
|
hotkey = obs_data_create_from_json(str);
|
|
|
|
|
else
|
|
|
|
|
hotkey = nullptr;
|
|
|
|
|
|
2016-12-09 14:40:04 -08:00
|
|
|
replayBuffer = obs_output_create("replay_buffer", Str("ReplayBuffer"), nullptr, hotkey);
|
2016-12-07 05:21:44 -08:00
|
|
|
|
2016-12-09 14:40:04 -08:00
|
|
|
if (!replayBuffer)
|
|
|
|
|
throw "Failed to create replay buffer output "
|
|
|
|
|
"(simple output)";
|
|
|
|
|
|
|
|
|
|
signal_handler_t *signal = obs_output_get_signal_handler(replayBuffer);
|
2024-10-04 17:33:58 -04:00
|
|
|
|
2016-12-09 14:40:04 -08:00
|
|
|
startReplayBuffer.Connect(signal, "start", OBSStartReplayBuffer, this);
|
|
|
|
|
stopReplayBuffer.Connect(signal, "stop", OBSStopReplayBuffer, this);
|
|
|
|
|
replayBufferStopping.Connect(signal, "stopping", OBSReplayBufferStopping, this);
|
2020-10-12 16:55:01 -07:00
|
|
|
replayBufferSaved.Connect(signal, "saved", OBSReplayBufferSaved, this);
|
2016-12-07 05:21:44 -08:00
|
|
|
}
|
|
|
|
|
|
2024-04-27 03:55:47 +02:00
|
|
|
bool use_native = strcmp(recFormat, "hybrid_mp4") == 0;
|
|
|
|
|
fileOutput = obs_output_create(use_native ? "mp4_output" : "ffmpeg_muxer", "simple_file_output",
|
|
|
|
|
nullptr, nullptr);
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
if (!fileOutput)
|
|
|
|
|
throw "Failed to create recording output "
|
|
|
|
|
"(simple output)";
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-04 08:00:21 +02:00
|
|
|
startRecording.Connect(obs_output_get_signal_handler(fileOutput), "start", OBSStartRecording, this);
|
|
|
|
|
stopRecording.Connect(obs_output_get_signal_handler(fileOutput), "stop", OBSStopRecording, this);
|
2016-06-22 01:47:08 -07:00
|
|
|
recordStopping.Connect(obs_output_get_signal_handler(fileOutput), "stopping", OBSRecordStopping, this);
|
2015-02-06 03:17:33 -08:00
|
|
|
}
|
|
|
|
|
|
2015-07-02 09:58:28 +02:00
|
|
|
int SimpleOutput::GetAudioBitrate() const
|
|
|
|
|
{
|
2022-12-17 18:26:59 +01:00
|
|
|
const char *audio_encoder = config_get_string(main->Config(), "SimpleOutput", "StreamAudioEncoder");
|
2015-09-21 18:36:26 -07:00
|
|
|
int bitrate = (int)config_get_uint(main->Config(), "SimpleOutput", "ABitrate");
|
|
|
|
|
|
2022-12-17 18:26:59 +01:00
|
|
|
if (strcmp(audio_encoder, "opus") == 0)
|
|
|
|
|
return FindClosestAvailableSimpleOpusBitrate(bitrate);
|
|
|
|
|
|
2022-12-17 18:16:05 +01:00
|
|
|
return FindClosestAvailableSimpleAACBitrate(bitrate);
|
2015-07-02 09:58:28 +02:00
|
|
|
}
|
|
|
|
|
|
2015-02-06 03:17:33 -08:00
|
|
|
void SimpleOutput::Update()
|
|
|
|
|
{
|
2022-05-06 20:17:55 -07:00
|
|
|
OBSDataAutoRelease videoSettings = obs_data_create();
|
2022-12-17 18:26:59 +01:00
|
|
|
OBSDataAutoRelease audioSettings = obs_data_create();
|
2015-02-06 03:17:33 -08:00
|
|
|
|
|
|
|
|
int videoBitrate = config_get_uint(main->Config(), "SimpleOutput", "VBitrate");
|
2015-07-02 09:58:28 +02:00
|
|
|
int audioBitrate = GetAudioBitrate();
|
2015-02-06 03:17:33 -08:00
|
|
|
bool advanced = config_get_bool(main->Config(), "SimpleOutput", "UseAdvanced");
|
2020-11-11 09:48:39 -08:00
|
|
|
bool enforceBitrate = !config_get_bool(main->Config(), "Stream1", "IgnoreRecommended");
|
2015-02-06 03:17:33 -08:00
|
|
|
const char *custom = config_get_string(main->Config(), "SimpleOutput", "x264Settings");
|
2016-04-18 00:56:51 -07:00
|
|
|
const char *encoder = config_get_string(main->Config(), "SimpleOutput", "StreamEncoder");
|
2024-08-22 11:47:16 +02:00
|
|
|
const char *encoder_id = obs_encoder_get_id(videoStreaming);
|
2016-04-18 00:56:51 -07:00
|
|
|
const char *presetType;
|
|
|
|
|
const char *preset;
|
|
|
|
|
|
2016-09-26 16:29:33 -07:00
|
|
|
if (strcmp(encoder, SIMPLE_ENCODER_QSV) == 0) {
|
2016-04-18 00:56:51 -07:00
|
|
|
presetType = "QSVPreset";
|
2016-09-26 16:29:33 -07:00
|
|
|
|
2022-11-21 17:56:05 -08:00
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_QSV_AV1) == 0) {
|
|
|
|
|
presetType = "QSVPreset";
|
|
|
|
|
|
2016-09-26 16:29:33 -07:00
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_AMD) == 0) {
|
|
|
|
|
presetType = "AMDPreset";
|
2022-07-21 13:02:21 -07:00
|
|
|
|
|
|
|
|
#ifdef ENABLE_HEVC
|
|
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_AMD_HEVC) == 0) {
|
|
|
|
|
presetType = "AMDPreset";
|
|
|
|
|
#endif
|
2016-09-26 16:29:33 -07:00
|
|
|
|
|
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_NVENC) == 0) {
|
2022-10-31 23:45:25 -04:00
|
|
|
presetType = "NVENCPreset2";
|
2016-09-26 16:29:33 -07:00
|
|
|
|
2022-05-19 07:53:37 +03:00
|
|
|
#ifdef ENABLE_HEVC
|
|
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_NVENC_HEVC) == 0) {
|
2022-10-31 23:45:25 -04:00
|
|
|
presetType = "NVENCPreset2";
|
2022-05-19 07:53:37 +03:00
|
|
|
#endif
|
|
|
|
|
|
2022-11-08 00:38:23 -08:00
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_AMD_AV1) == 0) {
|
|
|
|
|
presetType = "AMDAV1Preset";
|
|
|
|
|
|
2022-09-19 01:55:19 -07:00
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_NVENC_AV1) == 0) {
|
2022-10-31 23:45:25 -04:00
|
|
|
presetType = "NVENCPreset2";
|
2022-09-19 01:55:19 -07:00
|
|
|
|
2016-09-26 16:29:33 -07:00
|
|
|
} else {
|
2016-04-18 00:56:51 -07:00
|
|
|
presetType = "Preset";
|
2016-09-26 16:29:33 -07:00
|
|
|
}
|
2016-04-18 00:56:51 -07:00
|
|
|
|
|
|
|
|
preset = config_get_string(main->Config(), "SimpleOutput", presetType);
|
2024-08-22 11:47:16 +02:00
|
|
|
|
|
|
|
|
/* Only use preset2 for legacy/FFmpeg NVENC Encoder. */
|
|
|
|
|
if (strncmp(encoder_id, "ffmpeg_", 7) == 0 && strcmp(presetType, "NVENCPreset2") == 0) {
|
|
|
|
|
obs_data_set_string(videoSettings, "preset2", preset);
|
|
|
|
|
} else {
|
|
|
|
|
obs_data_set_string(videoSettings, "preset", preset);
|
|
|
|
|
}
|
2015-02-06 03:17:33 -08:00
|
|
|
|
2022-05-06 20:17:55 -07:00
|
|
|
obs_data_set_string(videoSettings, "rate_control", "CBR");
|
|
|
|
|
obs_data_set_int(videoSettings, "bitrate", videoBitrate);
|
2015-02-06 03:17:33 -08:00
|
|
|
|
2022-06-25 19:24:04 +02:00
|
|
|
if (advanced)
|
2022-05-06 20:17:55 -07:00
|
|
|
obs_data_set_string(videoSettings, "x264opts", custom);
|
2015-02-06 03:17:33 -08:00
|
|
|
|
2022-12-17 18:26:59 +01:00
|
|
|
obs_data_set_string(audioSettings, "rate_control", "CBR");
|
|
|
|
|
obs_data_set_int(audioSettings, "bitrate", audioBitrate);
|
2015-02-06 03:17:33 -08:00
|
|
|
|
2022-05-06 20:17:55 -07:00
|
|
|
obs_service_apply_encoder_settings(main->GetService(), videoSettings, audioSettings);
|
2015-03-07 16:32:00 -08:00
|
|
|
|
2020-11-11 09:48:39 -08:00
|
|
|
if (!enforceBitrate) {
|
2025-01-16 18:49:20 -05:00
|
|
|
int maxVideoBitrate;
|
|
|
|
|
int maxAudioBitrate;
|
|
|
|
|
obs_service_get_max_bitrate(main->GetService(), &maxVideoBitrate, &maxAudioBitrate);
|
|
|
|
|
|
|
|
|
|
std::string videoBitrateLogString = maxVideoBitrate > 0 ? std::to_string(maxVideoBitrate) : "None";
|
|
|
|
|
std::string audioBitrateLogString = maxAudioBitrate > 0 ? std::to_string(maxAudioBitrate) : "None";
|
|
|
|
|
|
|
|
|
|
blog(LOG_INFO,
|
|
|
|
|
"User is ignoring service bitrate limits.\n"
|
|
|
|
|
"Service Recommendations:\n"
|
|
|
|
|
"\tvideo bitrate: %s\n"
|
|
|
|
|
"\taudio bitrate: %s",
|
|
|
|
|
videoBitrateLogString.c_str(), audioBitrateLogString.c_str());
|
|
|
|
|
|
2022-05-06 20:17:55 -07:00
|
|
|
obs_data_set_int(videoSettings, "bitrate", videoBitrate);
|
2022-12-17 18:26:59 +01:00
|
|
|
obs_data_set_int(audioSettings, "bitrate", audioBitrate);
|
2016-04-10 22:53:42 -07:00
|
|
|
}
|
2016-04-10 03:10:36 -07:00
|
|
|
|
2015-04-17 02:48:06 -07:00
|
|
|
video_t *video = obs_get_video();
|
|
|
|
|
enum video_format format = video_output_get_format(video);
|
|
|
|
|
|
2022-04-29 09:45:56 -07:00
|
|
|
switch (format) {
|
|
|
|
|
case VIDEO_FORMAT_I420:
|
|
|
|
|
case VIDEO_FORMAT_NV12:
|
|
|
|
|
case VIDEO_FORMAT_I010:
|
|
|
|
|
case VIDEO_FORMAT_P010:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2022-05-06 20:17:55 -07:00
|
|
|
obs_encoder_set_preferred_video_format(videoStreaming, VIDEO_FORMAT_NV12);
|
2022-04-29 09:45:56 -07:00
|
|
|
}
|
2015-04-17 02:48:06 -07:00
|
|
|
|
2022-05-06 20:17:55 -07:00
|
|
|
obs_encoder_update(videoStreaming, videoSettings);
|
2022-12-17 18:26:59 +01:00
|
|
|
obs_encoder_update(audioStreaming, audioSettings);
|
|
|
|
|
obs_encoder_update(audioArchive, audioSettings);
|
2015-02-06 03:17:33 -08:00
|
|
|
}
|
|
|
|
|
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
void SimpleOutput::UpdateRecordingAudioSettings()
|
|
|
|
|
{
|
2021-11-26 22:25:39 +13:00
|
|
|
OBSDataAutoRelease settings = obs_data_create();
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
obs_data_set_int(settings, "bitrate", 192);
|
2016-05-08 11:20:51 -07:00
|
|
|
obs_data_set_string(settings, "rate_control", "CBR");
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
|
2022-07-22 15:28:26 +02:00
|
|
|
int tracks = config_get_int(main->Config(), "SimpleOutput", "RecTracks");
|
2023-03-26 07:07:25 +02:00
|
|
|
const char *recFormat = config_get_string(main->Config(), "SimpleOutput", "RecFormat2");
|
2022-07-22 15:28:26 +02:00
|
|
|
const char *quality = config_get_string(main->Config(), "SimpleOutput", "RecQuality");
|
|
|
|
|
bool flv = strcmp(recFormat, "flv") == 0;
|
|
|
|
|
|
|
|
|
|
if (flv || strcmp(quality, "Stream") == 0) {
|
|
|
|
|
obs_encoder_update(audioRecording, settings);
|
|
|
|
|
} else {
|
|
|
|
|
for (int i = 0; i < MAX_AUDIO_MIXES; i++) {
|
|
|
|
|
if ((tracks & (1 << i)) != 0) {
|
|
|
|
|
obs_encoder_update(audioTrack[i], settings);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define CROSS_DIST_CUTOFF 2000.0
|
|
|
|
|
|
|
|
|
|
int SimpleOutput::CalcCRF(int crf)
|
|
|
|
|
{
|
|
|
|
|
int cx = config_get_uint(main->Config(), "Video", "OutputCX");
|
|
|
|
|
int cy = config_get_uint(main->Config(), "Video", "OutputCY");
|
|
|
|
|
double fCX = double(cx);
|
|
|
|
|
double fCY = double(cy);
|
|
|
|
|
|
|
|
|
|
if (lowCPUx264)
|
|
|
|
|
crf -= 2;
|
|
|
|
|
|
|
|
|
|
double crossDist = sqrt(fCX * fCX + fCY * fCY);
|
|
|
|
|
double crfResReduction = fmin(CROSS_DIST_CUTOFF, crossDist) / CROSS_DIST_CUTOFF;
|
|
|
|
|
crfResReduction = (1.0 - crfResReduction) * 10.0;
|
|
|
|
|
|
|
|
|
|
return crf - int(crfResReduction);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SimpleOutput::UpdateRecordingSettings_x264_crf(int crf)
|
|
|
|
|
{
|
2021-11-26 22:25:39 +13:00
|
|
|
OBSDataAutoRelease settings = obs_data_create();
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
obs_data_set_int(settings, "crf", crf);
|
|
|
|
|
obs_data_set_bool(settings, "use_bufsize", true);
|
2016-05-08 11:20:51 -07:00
|
|
|
obs_data_set_string(settings, "rate_control", "CRF");
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
obs_data_set_string(settings, "profile", "high");
|
|
|
|
|
obs_data_set_string(settings, "preset", lowCPUx264 ? "ultrafast" : "veryfast");
|
|
|
|
|
|
2022-05-06 20:17:55 -07:00
|
|
|
obs_encoder_update(videoRecording, settings);
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
}
|
|
|
|
|
|
2016-04-18 00:56:51 -07:00
|
|
|
static bool icq_available(obs_encoder_t *encoder)
|
|
|
|
|
{
|
|
|
|
|
obs_properties_t *props = obs_encoder_properties(encoder);
|
|
|
|
|
obs_property_t *p = obs_properties_get(props, "rate_control");
|
|
|
|
|
bool icq_found = false;
|
|
|
|
|
|
|
|
|
|
size_t num = obs_property_list_item_count(p);
|
|
|
|
|
for (size_t i = 0; i < num; i++) {
|
|
|
|
|
const char *val = obs_property_list_item_string(p, i);
|
2016-05-11 13:19:38 -07:00
|
|
|
if (strcmp(val, "ICQ") == 0) {
|
2016-04-18 00:56:51 -07:00
|
|
|
icq_found = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
obs_properties_destroy(props);
|
|
|
|
|
return icq_found;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-21 17:56:05 -08:00
|
|
|
void SimpleOutput::UpdateRecordingSettings_qsv11(int crf, bool av1)
|
2016-04-18 00:56:51 -07:00
|
|
|
{
|
2022-05-06 20:17:55 -07:00
|
|
|
bool icq = icq_available(videoRecording);
|
2016-04-18 00:56:51 -07:00
|
|
|
|
2021-11-26 22:25:39 +13:00
|
|
|
OBSDataAutoRelease settings = obs_data_create();
|
2016-04-18 00:56:51 -07:00
|
|
|
obs_data_set_string(settings, "profile", "high");
|
|
|
|
|
|
2022-11-21 17:56:05 -08:00
|
|
|
if (icq && !av1) {
|
2016-05-11 13:19:38 -07:00
|
|
|
obs_data_set_string(settings, "rate_control", "ICQ");
|
2016-04-18 00:56:51 -07:00
|
|
|
obs_data_set_int(settings, "icq_quality", crf);
|
|
|
|
|
} else {
|
|
|
|
|
obs_data_set_string(settings, "rate_control", "CQP");
|
2022-11-21 17:33:20 -08:00
|
|
|
obs_data_set_int(settings, "cqp", crf);
|
2016-04-18 00:56:51 -07:00
|
|
|
}
|
|
|
|
|
|
2022-05-06 20:17:55 -07:00
|
|
|
obs_encoder_update(videoRecording, settings);
|
2016-04-18 00:56:51 -07:00
|
|
|
}
|
|
|
|
|
|
2016-05-08 11:21:37 -07:00
|
|
|
void SimpleOutput::UpdateRecordingSettings_nvenc(int cqp)
|
2016-04-18 16:12:59 -07:00
|
|
|
{
|
2021-11-26 22:25:39 +13:00
|
|
|
OBSDataAutoRelease settings = obs_data_create();
|
2016-05-08 11:21:37 -07:00
|
|
|
obs_data_set_string(settings, "rate_control", "CQP");
|
2016-04-18 16:12:59 -07:00
|
|
|
obs_data_set_string(settings, "profile", "high");
|
2016-05-08 11:21:37 -07:00
|
|
|
obs_data_set_int(settings, "cqp", cqp);
|
2016-04-18 16:12:59 -07:00
|
|
|
|
2022-05-06 20:17:55 -07:00
|
|
|
obs_encoder_update(videoRecording, settings);
|
2016-04-18 16:12:59 -07:00
|
|
|
}
|
|
|
|
|
|
2022-09-19 01:55:19 -07:00
|
|
|
void SimpleOutput::UpdateRecordingSettings_nvenc_hevc_av1(int cqp)
|
2022-05-19 07:53:37 +03:00
|
|
|
{
|
|
|
|
|
OBSDataAutoRelease settings = obs_data_create();
|
|
|
|
|
obs_data_set_string(settings, "rate_control", "CQP");
|
|
|
|
|
obs_data_set_string(settings, "profile", "main");
|
|
|
|
|
obs_data_set_int(settings, "cqp", cqp);
|
|
|
|
|
|
|
|
|
|
obs_encoder_update(videoRecording, settings);
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-23 02:46:03 +02:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-23 03:55:20 +02:00
|
|
|
#ifdef ENABLE_HEVC
|
|
|
|
|
void SimpleOutput::UpdateRecordingSettings_apple_hevc(int quality)
|
|
|
|
|
{
|
|
|
|
|
OBSDataAutoRelease settings = obs_data_create();
|
|
|
|
|
obs_data_set_string(settings, "rate_control", "CRF");
|
|
|
|
|
obs_data_set_string(settings, "profile", "main");
|
|
|
|
|
obs_data_set_int(settings, "quality", quality);
|
|
|
|
|
|
|
|
|
|
obs_encoder_update(videoRecording, settings);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-09-26 16:29:33 -07:00
|
|
|
void SimpleOutput::UpdateRecordingSettings_amd_cqp(int cqp)
|
|
|
|
|
{
|
2021-11-26 22:25:39 +13:00
|
|
|
OBSDataAutoRelease settings = obs_data_create();
|
2022-07-21 13:02:21 -07:00
|
|
|
obs_data_set_string(settings, "rate_control", "CQP");
|
|
|
|
|
obs_data_set_string(settings, "profile", "high");
|
2022-07-24 11:14:17 -07:00
|
|
|
obs_data_set_string(settings, "preset", "quality");
|
2022-07-21 13:02:21 -07:00
|
|
|
obs_data_set_int(settings, "cqp", cqp);
|
2022-05-06 20:17:55 -07:00
|
|
|
obs_encoder_update(videoRecording, settings);
|
2016-09-26 16:29:33 -07:00
|
|
|
}
|
|
|
|
|
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
void SimpleOutput::UpdateRecordingSettings()
|
|
|
|
|
{
|
2016-04-18 16:12:59 -07:00
|
|
|
bool ultra_hq = (videoQuality == "HQ");
|
|
|
|
|
int crf = CalcCRF(ultra_hq ? 16 : 23);
|
2016-04-18 00:56:51 -07:00
|
|
|
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
if (astrcmp_n(videoEncoder.c_str(), "x264", 4) == 0) {
|
2016-04-18 00:56:51 -07:00
|
|
|
UpdateRecordingSettings_x264_crf(crf);
|
|
|
|
|
|
|
|
|
|
} else if (videoEncoder == SIMPLE_ENCODER_QSV) {
|
2022-11-21 17:56:05 -08:00
|
|
|
UpdateRecordingSettings_qsv11(crf, false);
|
|
|
|
|
|
|
|
|
|
} else if (videoEncoder == SIMPLE_ENCODER_QSV_AV1) {
|
|
|
|
|
UpdateRecordingSettings_qsv11(crf, true);
|
2016-04-18 16:12:59 -07:00
|
|
|
|
2016-09-26 16:29:33 -07:00
|
|
|
} else if (videoEncoder == SIMPLE_ENCODER_AMD) {
|
|
|
|
|
UpdateRecordingSettings_amd_cqp(crf);
|
|
|
|
|
|
2022-07-21 13:02:21 -07:00
|
|
|
#ifdef ENABLE_HEVC
|
|
|
|
|
} else if (videoEncoder == SIMPLE_ENCODER_AMD_HEVC) {
|
|
|
|
|
UpdateRecordingSettings_amd_cqp(crf);
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-10-18 06:16:03 +02:00
|
|
|
} else if (videoEncoder == SIMPLE_ENCODER_AMD_AV1) {
|
|
|
|
|
UpdateRecordingSettings_amd_cqp(crf);
|
|
|
|
|
|
2016-04-18 16:12:59 -07:00
|
|
|
} else if (videoEncoder == SIMPLE_ENCODER_NVENC) {
|
2016-05-08 11:21:37 -07:00
|
|
|
UpdateRecordingSettings_nvenc(crf);
|
2022-05-19 07:53:37 +03:00
|
|
|
|
|
|
|
|
#ifdef ENABLE_HEVC
|
|
|
|
|
} else if (videoEncoder == SIMPLE_ENCODER_NVENC_HEVC) {
|
2022-09-19 01:55:19 -07:00
|
|
|
UpdateRecordingSettings_nvenc_hevc_av1(crf);
|
2022-05-19 07:53:37 +03:00
|
|
|
#endif
|
2022-09-19 01:55:19 -07:00
|
|
|
} else if (videoEncoder == SIMPLE_ENCODER_NVENC_AV1) {
|
|
|
|
|
UpdateRecordingSettings_nvenc_hevc_av1(crf);
|
|
|
|
|
|
2022-06-23 02:46:03 +02:00
|
|
|
} else if (videoEncoder == SIMPLE_ENCODER_APPLE_H264) {
|
|
|
|
|
/* These are magic numbers. 0 - 100, more is better. */
|
|
|
|
|
UpdateRecordingSettings_apple(ultra_hq ? 70 : 50);
|
2022-10-23 03:55:20 +02:00
|
|
|
#ifdef ENABLE_HEVC
|
|
|
|
|
} else if (videoEncoder == SIMPLE_ENCODER_APPLE_HEVC) {
|
|
|
|
|
UpdateRecordingSettings_apple_hevc(ultra_hq ? 70 : 50);
|
|
|
|
|
#endif
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
}
|
2019-10-25 10:56:26 -05:00
|
|
|
UpdateRecordingAudioSettings();
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
}
|
|
|
|
|
|
2015-02-06 03:17:33 -08:00
|
|
|
inline void SimpleOutput::SetupOutputs()
|
|
|
|
|
{
|
|
|
|
|
SimpleOutput::Update();
|
2022-05-06 20:17:55 -07:00
|
|
|
obs_encoder_set_video(videoStreaming, obs_get_video());
|
2022-12-17 18:26:59 +01:00
|
|
|
obs_encoder_set_audio(audioStreaming, obs_get_audio());
|
|
|
|
|
obs_encoder_set_audio(audioArchive, obs_get_audio());
|
2022-07-22 15:28:26 +02:00
|
|
|
int tracks = config_get_int(main->Config(), "SimpleOutput", "RecTracks");
|
2023-03-26 07:07:25 +02:00
|
|
|
const char *recFormat = config_get_string(main->Config(), "SimpleOutput", "RecFormat2");
|
2022-07-22 15:28:26 +02:00
|
|
|
bool flv = strcmp(recFormat, "flv") == 0;
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
|
|
|
|
|
if (usingRecordingPreset) {
|
|
|
|
|
if (ffmpegOutput) {
|
|
|
|
|
obs_output_set_media(fileOutput, obs_get_video(), obs_get_audio());
|
|
|
|
|
} else {
|
2022-05-06 20:17:55 -07:00
|
|
|
obs_encoder_set_video(videoRecording, obs_get_video());
|
2022-07-22 15:28:26 +02:00
|
|
|
if (flv) {
|
|
|
|
|
obs_encoder_set_audio(audioRecording, obs_get_audio());
|
|
|
|
|
} else {
|
|
|
|
|
for (int i = 0; i < MAX_AUDIO_MIXES; i++) {
|
|
|
|
|
if ((tracks & (1 << i)) != 0) {
|
|
|
|
|
obs_encoder_set_audio(audioTrack[i], obs_get_audio());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
}
|
2022-07-22 15:28:26 +02:00
|
|
|
} else {
|
|
|
|
|
obs_encoder_set_audio(audioRecording, obs_get_audio());
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
}
|
2015-02-06 03:17:33 -08:00
|
|
|
}
|
|
|
|
|
|
2024-07-08 14:07:10 +02:00
|
|
|
std::shared_future<void> SimpleOutput::SetupStreaming(obs_service_t *service, SetupStreamingContinuation_t continuation)
|
2015-02-06 03:17:33 -08:00
|
|
|
{
|
2020-09-03 06:56:03 -07:00
|
|
|
if (!Active())
|
2015-02-06 03:17:33 -08:00
|
|
|
SetupOutputs();
|
|
|
|
|
|
2019-02-06 22:24:25 -08:00
|
|
|
Auth *auth = main->GetAuth();
|
|
|
|
|
if (auth)
|
|
|
|
|
auth->OnStreamConfig();
|
|
|
|
|
|
2017-07-13 03:57:42 -07:00
|
|
|
/* --------------------- */
|
|
|
|
|
|
2022-10-07 11:42:12 +02:00
|
|
|
const char *type = GetStreamOutputType(service);
|
2024-07-08 14:07:10 +02:00
|
|
|
if (!type) {
|
|
|
|
|
continuation(false);
|
|
|
|
|
return StartMultitrackVideoStreamingGuard::MakeReadyFuture();
|
|
|
|
|
}
|
2024-04-18 15:41:36 +02:00
|
|
|
|
|
|
|
|
auto audio_bitrate = GetAudioBitrate();
|
|
|
|
|
auto vod_track_mixer = IsVodTrackEnabled(service) ? std::optional{1} : std::nullopt;
|
|
|
|
|
|
2024-11-18 15:30:08 +01:00
|
|
|
auto handle_multitrack_video_result = [=](std::optional<bool> multitrackVideoResult) {
|
2024-07-09 13:25:49 +02:00
|
|
|
if (multitrackVideoResult.has_value())
|
|
|
|
|
return multitrackVideoResult.value();
|
|
|
|
|
|
|
|
|
|
/* XXX: this is messy and disgusting and should be refactored */
|
|
|
|
|
if (outputType != type) {
|
|
|
|
|
streamDelayStarting.Disconnect();
|
|
|
|
|
streamStopping.Disconnect();
|
|
|
|
|
startStreaming.Disconnect();
|
|
|
|
|
stopStreaming.Disconnect();
|
|
|
|
|
|
|
|
|
|
streamOutput = obs_output_create(type, "simple_stream", nullptr, nullptr);
|
|
|
|
|
if (!streamOutput) {
|
|
|
|
|
blog(LOG_WARNING,
|
|
|
|
|
"Creation of stream output type '%s' "
|
|
|
|
|
"failed!",
|
|
|
|
|
type);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
streamDelayStarting.Connect(obs_output_get_signal_handler(streamOutput), "starting",
|
|
|
|
|
OBSStreamStarting, this);
|
|
|
|
|
streamStopping.Connect(obs_output_get_signal_handler(streamOutput), "stopping",
|
|
|
|
|
OBSStreamStopping, this);
|
|
|
|
|
|
|
|
|
|
startStreaming.Connect(obs_output_get_signal_handler(streamOutput), "start", OBSStartStreaming,
|
|
|
|
|
this);
|
|
|
|
|
stopStreaming.Connect(obs_output_get_signal_handler(streamOutput), "stop", OBSStopStreaming,
|
|
|
|
|
this);
|
|
|
|
|
|
|
|
|
|
outputType = type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
obs_output_set_video_encoder(streamOutput, videoStreaming);
|
|
|
|
|
obs_output_set_audio_encoder(streamOutput, audioStreaming, 0);
|
|
|
|
|
obs_output_set_service(streamOutput, service);
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
2024-06-18 15:12:57 +02:00
|
|
|
return SetupMultitrackVideo(service, GetSimpleAACEncoderForBitrate(audio_bitrate), 0, vod_track_mixer,
|
2024-11-18 15:30:08 +01:00
|
|
|
[=](std::optional<bool> res) {
|
2024-07-08 14:07:10 +02:00
|
|
|
continuation(handle_multitrack_video_result(res));
|
|
|
|
|
});
|
2020-09-16 22:20:02 -07:00
|
|
|
}
|
2015-02-06 03:17:33 -08:00
|
|
|
|
2024-04-18 15:41:36 +02:00
|
|
|
bool SimpleOutput::IsVodTrackEnabled(obs_service_t *service)
|
2020-11-14 08:05:52 -08:00
|
|
|
{
|
|
|
|
|
bool advanced = config_get_bool(main->Config(), "SimpleOutput", "UseAdvanced");
|
|
|
|
|
bool enable = config_get_bool(main->Config(), "SimpleOutput", "VodTrackEnabled");
|
2024-09-03 16:28:36 +02:00
|
|
|
bool enableForCustomServer = config_get_bool(App()->GetUserConfig(), "General", "EnableCustomServerVodTrack");
|
2020-11-14 08:05:52 -08:00
|
|
|
|
2021-11-26 22:25:39 +13:00
|
|
|
OBSDataAutoRelease settings = obs_service_get_settings(service);
|
2020-11-14 08:05:52 -08:00
|
|
|
const char *name = obs_data_get_string(settings, "service");
|
|
|
|
|
|
2020-12-03 01:20:37 -08:00
|
|
|
const char *id = obs_service_get_id(service);
|
|
|
|
|
if (strcmp(id, "rtmp_custom") == 0)
|
2024-04-18 15:41:36 +02:00
|
|
|
return enableForCustomServer ? enable : false;
|
2020-12-03 01:20:37 -08:00
|
|
|
else
|
2024-04-18 15:41:36 +02:00
|
|
|
return advanced && enable && ServiceSupportsVodTrack(name);
|
|
|
|
|
}
|
2020-12-03 01:20:37 -08:00
|
|
|
|
2024-04-18 15:41:36 +02:00
|
|
|
void SimpleOutput::SetupVodTrack(obs_service_t *service)
|
|
|
|
|
{
|
|
|
|
|
if (IsVodTrackEnabled(service))
|
2022-12-17 18:26:59 +01:00
|
|
|
obs_output_set_audio_encoder(streamOutput, audioArchive, 1);
|
2020-12-03 00:59:43 -08:00
|
|
|
else
|
|
|
|
|
clear_archive_encoder(streamOutput, SIMPLE_ARCHIVE_NAME);
|
2020-11-14 08:05:52 -08:00
|
|
|
}
|
|
|
|
|
|
2020-09-16 22:20:02 -07:00
|
|
|
bool SimpleOutput::StartStreaming(obs_service_t *service)
|
|
|
|
|
{
|
2015-09-10 19:10:40 -07:00
|
|
|
bool reconnect = config_get_bool(main->Config(), "Output", "Reconnect");
|
|
|
|
|
int retryDelay = config_get_uint(main->Config(), "Output", "RetryDelay");
|
|
|
|
|
int maxRetries = config_get_uint(main->Config(), "Output", "MaxRetries");
|
2015-09-06 16:19:53 -07:00
|
|
|
bool useDelay = config_get_bool(main->Config(), "Output", "DelayEnable");
|
|
|
|
|
int delaySec = config_get_int(main->Config(), "Output", "DelaySec");
|
|
|
|
|
bool preserveDelay = config_get_bool(main->Config(), "Output", "DelayPreserve");
|
2016-07-29 08:30:54 -07:00
|
|
|
const char *bindIP = config_get_string(main->Config(), "Output", "BindIP");
|
2023-06-15 15:17:24 -07:00
|
|
|
const char *ipFamily = config_get_string(main->Config(), "Output", "IPFamily");
|
2023-03-15 21:57:32 +01:00
|
|
|
#ifdef _WIN32
|
2017-02-22 02:05:45 +01:00
|
|
|
bool enableNewSocketLoop = config_get_bool(main->Config(), "Output", "NewSocketLoopEnable");
|
|
|
|
|
bool enableLowLatencyMode = config_get_bool(main->Config(), "Output", "LowLatencyEnable");
|
2024-04-18 15:41:36 +02:00
|
|
|
#else
|
|
|
|
|
bool enableNewSocketLoop = false;
|
2023-03-15 21:57:32 +01:00
|
|
|
#endif
|
2019-08-15 08:50:09 -07:00
|
|
|
bool enableDynBitrate = config_get_bool(main->Config(), "Output", "DynamicBitrate");
|
2016-07-29 08:30:54 -07:00
|
|
|
|
2024-04-18 15:41:36 +02:00
|
|
|
if (multitrackVideo && multitrackVideoActive &&
|
|
|
|
|
!multitrackVideo->HandleIncompatibleSettings(main, main->Config(), service, useDelay, enableNewSocketLoop,
|
|
|
|
|
enableDynBitrate)) {
|
|
|
|
|
multitrackVideoActive = false;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-26 22:25:39 +13:00
|
|
|
OBSDataAutoRelease settings = obs_data_create();
|
2016-07-29 08:30:54 -07:00
|
|
|
obs_data_set_string(settings, "bind_ip", bindIP);
|
2023-06-15 15:17:24 -07:00
|
|
|
obs_data_set_string(settings, "ip_family", ipFamily);
|
2023-03-15 21:57:32 +01:00
|
|
|
#ifdef _WIN32
|
2017-02-22 02:05:45 +01:00
|
|
|
obs_data_set_bool(settings, "new_socket_loop_enabled", enableNewSocketLoop);
|
|
|
|
|
obs_data_set_bool(settings, "low_latency_mode_enabled", enableLowLatencyMode);
|
2023-03-15 21:57:32 +01:00
|
|
|
#endif
|
2019-08-15 08:50:09 -07:00
|
|
|
obs_data_set_bool(settings, "dyn_bitrate", enableDynBitrate);
|
2024-04-18 15:41:36 +02:00
|
|
|
|
|
|
|
|
auto streamOutput = StreamingOutput(); // shadowing is sort of bad, but also convenient
|
|
|
|
|
|
2016-07-29 08:30:54 -07:00
|
|
|
obs_output_update(streamOutput, settings);
|
|
|
|
|
|
2015-02-06 03:17:33 -08:00
|
|
|
if (!reconnect)
|
|
|
|
|
maxRetries = 0;
|
|
|
|
|
|
2015-09-06 16:19:53 -07:00
|
|
|
obs_output_set_delay(streamOutput, useDelay ? delaySec : 0, preserveDelay ? OBS_OUTPUT_DELAY_PRESERVE : 0);
|
|
|
|
|
|
2015-02-06 03:17:33 -08:00
|
|
|
obs_output_set_reconnect_settings(streamOutput, maxRetries, retryDelay);
|
|
|
|
|
|
2024-04-18 15:41:36 +02:00
|
|
|
if (!multitrackVideo || !multitrackVideoActive)
|
|
|
|
|
SetupVodTrack(service);
|
2020-11-14 08:05:52 -08:00
|
|
|
|
2015-02-06 03:17:33 -08:00
|
|
|
if (obs_output_start(streamOutput)) {
|
2024-04-18 15:41:36 +02:00
|
|
|
if (multitrackVideo && multitrackVideoActive)
|
|
|
|
|
multitrackVideo->StartedStreaming();
|
2015-02-06 03:17:33 -08:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-18 15:41:36 +02:00
|
|
|
if (multitrackVideo && multitrackVideoActive)
|
|
|
|
|
multitrackVideoActive = false;
|
|
|
|
|
|
2017-10-06 04:48:24 -07:00
|
|
|
const char *error = obs_output_get_last_error(streamOutput);
|
2018-12-12 15:20:48 -08:00
|
|
|
bool hasLastError = error && *error;
|
|
|
|
|
if (hasLastError)
|
|
|
|
|
lastError = error;
|
|
|
|
|
else
|
|
|
|
|
lastError = string();
|
2017-10-06 04:48:24 -07:00
|
|
|
|
2023-01-15 21:27:47 -08:00
|
|
|
const char *type = obs_output_get_id(streamOutput);
|
2018-12-12 15:20:48 -08:00
|
|
|
blog(LOG_WARNING, "Stream output type '%s' failed to start!%s%s", type, hasLastError ? " Last Error: " : "",
|
|
|
|
|
hasLastError ? error : "");
|
2015-02-06 03:17:33 -08:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-09 14:40:04 -08:00
|
|
|
void SimpleOutput::UpdateRecording()
|
2015-02-06 03:17:33 -08:00
|
|
|
{
|
2023-03-26 07:07:25 +02:00
|
|
|
const char *recFormat = config_get_string(main->Config(), "SimpleOutput", "RecFormat2");
|
2022-07-22 15:28:26 +02:00
|
|
|
bool flv = strcmp(recFormat, "flv") == 0;
|
|
|
|
|
int tracks = config_get_int(main->Config(), "SimpleOutput", "RecTracks");
|
|
|
|
|
int idx = 0;
|
|
|
|
|
int idx2 = 0;
|
|
|
|
|
const char *quality = config_get_string(main->Config(), "SimpleOutput", "RecQuality");
|
|
|
|
|
|
2016-12-09 14:40:04 -08:00
|
|
|
if (replayBufferActive || recordingActive)
|
|
|
|
|
return;
|
|
|
|
|
|
UI: Add recording presets to simple output
So certain high-profile individuals were complaining that it was
difficult to configure recording settings for quality in OBS. So, I
decided to add a very easy-to-use auto-configuration for high quality
encoding -- including lossless encoding. This feature will
automatically configure ideal recording settings based upon a specified
quality level.
Recording quality presets added to simple output:
- Same as stream: Copies the encoded streaming data with no extra usage
hit.
- High quality: uses a higher CRF value (starting at 23) if using x264.
- Indistinguishable quality: uses a low CRF value (starting at 16) if
using x264.
- Lossless will spawn an FFmpeg output that uses huffyuv encoding. If a
user tries to select lossless, they will be warned both via a dialog
prompt and a warning message in the settings window to ensure they
understand that it requires tremendous amounts of free space. It will
always use the AVI file format.
Extra Notes:
- When High/Indistinguishable quality is set, it will allow you to
select the recording encoder. Currently, it just allows you to select
x264 (at either veryfast or ultrafast). Later on, it'll be useful to
be able to set up pre-configured presets for hardware encoders once
more are implemented and tested.
- I decided to allow the use of x264 at both veryfast or ultrafast
presets. The reasoning is two-fold:
1.) ultrafast is perfectly viable even for near indistinguishable
quality as long as it has the appropriate CRF value. It's nice if you
want to record but would like to or need to reduce the impact of
encoding on the CPU. It will automatically compensate for the preset at
the cost of larger file size.
2.) It was suggested to just always use ultrafast, but ultrafast
requires 2-4x as much disk space for the same CRF (most likely due to
x264 compensating for the preset). Providing veryfast is important if
you really want to reduce file size and/or reduce blocking at lower
quality levels.
- When a recording preset is used, a secondary audio encoder is also
spawned at 192 bitrate to ensure high quality audio. I chose 192
because that's the limit of the media foundation aac encoder on
windows, which I want to make sure is used if available due to its
high performance.
- The CRF calculation is based upon resolution, quality, and whether
it's set to ultrafast. First, quality sets the base CRF, 23 for
"good" quality, 16 for "very high" quality. If set to ultrafast,
it'll subtract 2 points from the CRF value to help compensate. Lower
resolutions will also lower the CRF value to help improve higher
details with a smaller pixel ratio.
2015-09-18 22:29:36 -07:00
|
|
|
if (usingRecordingPreset) {
|
|
|
|
|
if (!ffmpegOutput)
|
|
|
|
|
UpdateRecordingSettings();
|
|
|
|
|
} else if (!obs_output_active(streamOutput)) {
|
|
|
|
|
Update();
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-03 06:56:03 -07:00
|
|
|
if (!Active())
|
2015-02-06 03:17:33 -08:00
|
|
|
SetupOutputs();
|
|
|
|
|
|
2016-12-09 14:40:04 -08:00
|
|
|
if (!ffmpegOutput) {
|
2022-05-06 20:17:55 -07:00
|
|
|
obs_output_set_video_encoder(fileOutput, videoRecording);
|
2022-07-22 15:28:26 +02:00
|
|
|
if (flv || strcmp(quality, "Stream") == 0) {
|
|
|
|
|
obs_output_set_audio_encoder(fileOutput, audioRecording, 0);
|
|
|
|
|
} else {
|
|
|
|
|
for (int i = 0; i < MAX_AUDIO_MIXES; i++) {
|
|
|
|
|
if ((tracks & (1 << i)) != 0) {
|
|
|
|
|
obs_output_set_audio_encoder(fileOutput, audioTrack[i], idx++);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-12-09 14:40:04 -08:00
|
|
|
}
|
|
|
|
|
if (replayBuffer) {
|
2022-05-06 20:17:55 -07:00
|
|
|
obs_output_set_video_encoder(replayBuffer, videoRecording);
|
2022-07-22 15:28:26 +02:00
|
|
|
if (flv || strcmp(quality, "Stream") == 0) {
|
|
|
|
|
obs_output_set_audio_encoder(replayBuffer, audioRecording, 0);
|
|
|
|
|
} else {
|
|
|
|
|
for (int i = 0; i < MAX_AUDIO_MIXES; i++) {
|
|
|
|
|
if ((tracks & (1 << i)) != 0) {
|
|
|
|
|
obs_output_set_audio_encoder(replayBuffer, audioTrack[i], idx2++);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-12-09 14:40:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
recordingConfigured = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SimpleOutput::ConfigureRecording(bool updateReplayBuffer)
|
|
|
|
|
{
|
2015-02-06 03:17:33 -08:00
|
|
|
const char *path = config_get_string(main->Config(), "SimpleOutput", "FilePath");
|
2023-03-24 12:44:37 +01:00
|
|
|
const char *format = config_get_string(main->Config(), "SimpleOutput", "RecFormat2");
|
2015-11-23 15:36:06 +01:00
|
|
|
const char *mux = config_get_string(main->Config(), "SimpleOutput", "MuxerCustom");
|
2015-11-27 12:14:18 +01:00
|
|
|
bool noSpace = config_get_bool(main->Config(), "SimpleOutput", "FileNameWithoutSpace");
|
2016-03-25 02:43:38 -07:00
|
|
|
const char *filenameFormat = config_get_string(main->Config(), "Output", "FilenameFormatting");
|
|
|
|
|
bool overwriteIfExists = config_get_bool(main->Config(), "Output", "OverwriteIfExists");
|
2016-12-09 14:42:14 -08:00
|
|
|
const char *rbPrefix = config_get_string(main->Config(), "SimpleOutput", "RecRBPrefix");
|
|
|
|
|
const char *rbSuffix = config_get_string(main->Config(), "SimpleOutput", "RecRBSuffix");
|
2016-12-07 05:21:44 -08:00
|
|
|
int rbTime = config_get_int(main->Config(), "SimpleOutput", "RecRBTime");
|
|
|
|
|
int rbSize = config_get_int(main->Config(), "SimpleOutput", "RecRBSize");
|
2022-07-22 15:28:26 +02:00
|
|
|
int tracks = config_get_int(main->Config(), "SimpleOutput", "RecTracks");
|
2015-02-06 03:17:33 -08:00
|
|
|
|
2023-04-03 15:48:55 +02:00
|
|
|
bool is_fragmented = strncmp(format, "fragmented", 10) == 0;
|
2023-07-14 13:40:10 +02:00
|
|
|
bool is_lossless = videoQuality == "Lossless";
|
2023-01-29 12:48:01 +01:00
|
|
|
|
2020-07-23 08:45:03 -05:00
|
|
|
string f;
|
2015-02-06 03:17:33 -08:00
|
|
|
|
2021-11-26 22:25:39 +13:00
|
|
|
OBSDataAutoRelease settings = obs_data_create();
|
2016-12-09 14:40:04 -08:00
|
|
|
if (updateReplayBuffer) {
|
2020-07-23 08:45:03 -05:00
|
|
|
f = GetFormatString(filenameFormat, rbPrefix, rbSuffix);
|
2023-04-05 00:46:07 +02:00
|
|
|
string ext = GetFormatExt(format);
|
2016-12-07 05:21:44 -08:00
|
|
|
obs_data_set_string(settings, "directory", path);
|
2016-12-09 14:42:14 -08:00
|
|
|
obs_data_set_string(settings, "format", f.c_str());
|
2023-04-05 00:46:07 +02:00
|
|
|
obs_data_set_string(settings, "extension", ext.c_str());
|
2018-04-26 17:54:47 +02:00
|
|
|
obs_data_set_bool(settings, "allow_spaces", !noSpace);
|
2016-12-07 05:21:44 -08:00
|
|
|
obs_data_set_int(settings, "max_time_sec", rbTime);
|
|
|
|
|
obs_data_set_int(settings, "max_size_mb", usingRecordingPreset ? rbSize : 0);
|
|
|
|
|
} else {
|
2020-07-23 08:45:03 -05:00
|
|
|
f = GetFormatString(filenameFormat, nullptr, nullptr);
|
2023-04-02 22:34:34 +02:00
|
|
|
string strPath = GetRecordingFilename(path, ffmpegOutput ? "avi" : format, noSpace, overwriteIfExists,
|
|
|
|
|
f.c_str(), ffmpegOutput);
|
2016-12-07 05:21:44 -08:00
|
|
|
obs_data_set_string(settings, ffmpegOutput ? "url" : "path", strPath.c_str());
|
2022-07-22 15:28:26 +02:00
|
|
|
if (ffmpegOutput)
|
|
|
|
|
obs_output_set_mixers(fileOutput, tracks);
|
2016-12-07 05:21:44 -08:00
|
|
|
}
|
2016-12-09 14:40:04 -08:00
|
|
|
|
2023-01-29 12:48:01 +01:00
|
|
|
// Use fragmented MOV/MP4 if user has not already specified custom movflags
|
2023-07-14 13:40:10 +02:00
|
|
|
if (is_fragmented && !is_lossless && (!mux || strstr(mux, "movflags") == NULL)) {
|
2023-01-29 12:48:01 +01:00
|
|
|
string mux_frag = "movflags=frag_keyframe+empty_moov+delay_moov";
|
|
|
|
|
if (mux) {
|
|
|
|
|
mux_frag += " ";
|
|
|
|
|
mux_frag += mux;
|
|
|
|
|
}
|
|
|
|
|
obs_data_set_string(settings, "muxer_settings", mux_frag.c_str());
|
|
|
|
|
} else {
|
2023-07-14 13:40:10 +02:00
|
|
|
if (is_fragmented && !is_lossless)
|
2023-01-29 12:48:01 +01:00
|
|
|
blog(LOG_WARNING, "User enabled fragmented recording, "
|
|
|
|
|
"but custom muxer settings contained movflags.");
|
|
|
|
|
obs_data_set_string(settings, "muxer_settings", mux);
|
|
|
|
|
}
|
2015-02-06 03:17:33 -08:00
|
|
|
|
2016-12-09 14:40:04 -08:00
|
|
|
if (updateReplayBuffer)
|
|
|
|
|
obs_output_update(replayBuffer, settings);
|
|
|
|
|
else
|
|
|
|
|
obs_output_update(fileOutput, settings);
|
2015-02-06 03:17:33 -08:00
|
|
|
|
2016-12-09 14:40:04 -08:00
|
|
|
return true;
|
|
|
|
|
}
|
2015-02-06 03:17:33 -08:00
|
|
|
|
2016-12-09 14:40:04 -08:00
|
|
|
bool SimpleOutput::StartRecording()
|
|
|
|
|
{
|
|
|
|
|
UpdateRecording();
|
|
|
|
|
if (!ConfigureRecording(false))
|
|
|
|
|
return false;
|
2017-02-04 05:29:09 +01:00
|
|
|
if (!obs_output_start(fileOutput)) {
|
2017-08-07 00:24:44 +02:00
|
|
|
QString error_reason;
|
|
|
|
|
const char *error = obs_output_get_last_error(fileOutput);
|
|
|
|
|
if (error)
|
|
|
|
|
error_reason = QT_UTF8(error);
|
|
|
|
|
else
|
|
|
|
|
error_reason = QTStr("Output.StartFailedGeneric");
|
|
|
|
|
QMessageBox::critical(main, QTStr("Output.StartRecordingFailed"), error_reason);
|
2016-12-09 14:40:04 -08:00
|
|
|
return false;
|
2017-02-04 05:29:09 +01:00
|
|
|
}
|
|
|
|
|
|
2016-12-09 14:40:04 -08:00
|
|
|
return true;
|
|
|
|
|
}
|
2015-02-06 03:17:33 -08:00
|
|
|
|
2016-12-09 14:40:04 -08:00
|
|
|
bool SimpleOutput::StartReplayBuffer()
|
|
|
|
|
{
|
|
|
|
|
UpdateRecording();
|
|
|
|
|
if (!ConfigureRecording(true))
|
|
|
|
|
return false;
|
2017-02-04 05:29:09 +01:00
|
|
|
if (!obs_output_start(replayBuffer)) {
|
|
|
|
|
QMessageBox::critical(main, QTStr("Output.StartReplayFailed"), QTStr("Output.StartFailedGeneric"));
|
2016-12-09 14:40:04 -08:00
|
|
|
return false;
|
2017-02-04 05:29:09 +01:00
|
|
|
}
|
|
|
|
|
|
2016-12-09 14:40:04 -08:00
|
|
|
return true;
|
2015-02-06 03:17:33 -08:00
|
|
|
}
|
|
|
|
|
|
2016-09-09 07:37:54 -07:00
|
|
|
void SimpleOutput::StopStreaming(bool force)
|
2015-02-06 03:17:33 -08:00
|
|
|
{
|
2024-04-18 15:41:36 +02:00
|
|
|
auto output = StreamingOutput();
|
|
|
|
|
if (force && output)
|
|
|
|
|
obs_output_force_stop(output);
|
|
|
|
|
else if (multitrackVideo && multitrackVideoActive)
|
|
|
|
|
multitrackVideo->StopStreaming();
|
2016-09-09 07:37:54 -07:00
|
|
|
else
|
2024-04-18 15:41:36 +02:00
|
|
|
obs_output_stop(output);
|
2015-09-06 16:19:53 -07:00
|
|
|
}
|
|
|
|
|
|
2016-09-09 07:37:54 -07:00
|
|
|
void SimpleOutput::StopRecording(bool force)
|
2015-02-06 03:17:33 -08:00
|
|
|
{
|
2016-09-09 07:37:54 -07:00
|
|
|
if (force)
|
|
|
|
|
obs_output_force_stop(fileOutput);
|
|
|
|
|
else
|
|
|
|
|
obs_output_stop(fileOutput);
|
2015-02-06 03:17:33 -08:00
|
|
|
}
|
|
|
|
|
|
2016-12-09 14:40:04 -08:00
|
|
|
void SimpleOutput::StopReplayBuffer(bool force)
|
|
|
|
|
{
|
|
|
|
|
if (force)
|
|
|
|
|
obs_output_force_stop(replayBuffer);
|
|
|
|
|
else
|
|
|
|
|
obs_output_stop(replayBuffer);
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-06 03:17:33 -08:00
|
|
|
bool SimpleOutput::StreamingActive() const
|
|
|
|
|
{
|
2024-04-18 15:41:36 +02:00
|
|
|
return obs_output_active(StreamingOutput());
|
2015-02-06 03:17:33 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SimpleOutput::RecordingActive() const
|
|
|
|
|
{
|
|
|
|
|
return obs_output_active(fileOutput);
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-09 14:40:04 -08:00
|
|
|
bool SimpleOutput::ReplayBufferActive() const
|
|
|
|
|
{
|
|
|
|
|
return obs_output_active(replayBuffer);
|
|
|
|
|
}
|