2015-02-06 12:17:33 +01:00
|
|
|
#include <string>
|
2016-07-05 08:11:24 +02:00
|
|
|
#include <algorithm>
|
2024-04-18 15:41:36 +02:00
|
|
|
#include <cinttypes>
|
2015-02-06 12:17:33 +01:00
|
|
|
#include <QMessageBox>
|
2024-07-08 14:07:10 +02:00
|
|
|
#include <QThreadPool>
|
2024-01-17 08:24:40 +01:00
|
|
|
#include <qt-wrappers.hpp>
|
2015-07-02 10:00:22 +02:00
|
|
|
#include "audio-encoders.hpp"
|
2024-04-18 15:41:36 +02:00
|
|
|
#include "multitrack-video-error.hpp"
|
2015-02-06 12:17:33 +01:00
|
|
|
#include "window-basic-main.hpp"
|
|
|
|
#include "window-basic-main-outputs.hpp"
|
2022-09-20 15:45:27 +02:00
|
|
|
#include "window-basic-vcam.hpp"
|
2015-02-06 12:17:33 +01:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2019-02-06 03:22:40 +01:00
|
|
|
extern bool EncoderAvailable(const char *encoder);
|
|
|
|
|
2019-02-26 15:37:01 +01:00
|
|
|
volatile bool streaming_active = false;
|
|
|
|
volatile bool recording_active = false;
|
2019-07-08 00:47:29 +02:00
|
|
|
volatile bool recording_paused = false;
|
2019-02-26 15:37:01 +01:00
|
|
|
volatile bool replaybuf_active = false;
|
2020-06-20 16:42:14 +02:00
|
|
|
volatile bool virtualcam_active = false;
|
2019-02-26 15:37:01 +01:00
|
|
|
|
2019-04-19 20:58:31 +02:00
|
|
|
#define RTMP_PROTOCOL "rtmp"
|
2022-07-15 22:03:43 +02:00
|
|
|
#define SRT_PROTOCOL "srt"
|
|
|
|
#define RIST_PROTOCOL "rist"
|
2019-04-19 20:58:31 +02:00
|
|
|
|
2015-09-07 01:19:53 +02:00
|
|
|
static void OBSStreamStarting(void *data, calldata_t *params)
|
|
|
|
{
|
|
|
|
BasicOutputHandler *output = static_cast<BasicOutputHandler *>(data);
|
|
|
|
obs_output_t *obj = (obs_output_t *)calldata_ptr(params, "output");
|
|
|
|
|
|
|
|
int sec = (int)obs_output_get_active_delay(obj);
|
|
|
|
if (sec == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
output->delayActive = true;
|
|
|
|
QMetaObject::invokeMethod(output->main, "StreamDelayStarting",
|
|
|
|
Q_ARG(int, sec));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void OBSStreamStopping(void *data, calldata_t *params)
|
|
|
|
{
|
|
|
|
BasicOutputHandler *output = static_cast<BasicOutputHandler *>(data);
|
|
|
|
obs_output_t *obj = (obs_output_t *)calldata_ptr(params, "output");
|
|
|
|
|
|
|
|
int sec = (int)obs_output_get_active_delay(obj);
|
|
|
|
if (sec == 0)
|
2016-06-22 10:47:08 +02:00
|
|
|
QMetaObject::invokeMethod(output->main, "StreamStopping");
|
|
|
|
else
|
|
|
|
QMetaObject::invokeMethod(output->main, "StreamDelayStopping",
|
|
|
|
Q_ARG(int, sec));
|
2015-09-07 01:19:53 +02:00
|
|
|
}
|
|
|
|
|
2023-01-29 03:42:41 +01:00
|
|
|
static void OBSStartStreaming(void *data, calldata_t * /* params */)
|
2015-02-06 12:17:33 +01:00
|
|
|
{
|
|
|
|
BasicOutputHandler *output = static_cast<BasicOutputHandler *>(data);
|
2015-09-07 01:07:45 +02:00
|
|
|
output->streamingActive = true;
|
2019-02-26 15:37:01 +01:00
|
|
|
os_atomic_set_bool(&streaming_active, true);
|
2015-02-06 12:17:33 +01:00
|
|
|
QMetaObject::invokeMethod(output->main, "StreamingStart");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void OBSStopStreaming(void *data, calldata_t *params)
|
|
|
|
{
|
|
|
|
BasicOutputHandler *output = static_cast<BasicOutputHandler *>(data);
|
|
|
|
int code = (int)calldata_int(params, "code");
|
2017-05-15 12:03:00 +02:00
|
|
|
const char *last_error = calldata_string(params, "last_error");
|
|
|
|
|
|
|
|
QString arg_last_error = QString::fromUtf8(last_error);
|
2015-02-06 12:17:33 +01:00
|
|
|
|
2015-09-07 01:07:45 +02:00
|
|
|
output->streamingActive = false;
|
2015-09-07 01:19:53 +02:00
|
|
|
output->delayActive = false;
|
2024-04-18 15:41:36 +02:00
|
|
|
output->multitrackVideoActive = false;
|
2019-02-26 15:37:01 +01:00
|
|
|
os_atomic_set_bool(&streaming_active, false);
|
2015-02-06 12:17:33 +01:00
|
|
|
QMetaObject::invokeMethod(output->main, "StreamingStop",
|
2019-03-30 15:44:44 +01:00
|
|
|
Q_ARG(int, code),
|
|
|
|
Q_ARG(QString, arg_last_error));
|
2015-02-06 12:17:33 +01:00
|
|
|
}
|
|
|
|
|
2023-01-29 03:42:41 +01:00
|
|
|
static void OBSStartRecording(void *data, calldata_t * /* params */)
|
2015-02-06 12:17:33 +01:00
|
|
|
{
|
|
|
|
BasicOutputHandler *output = static_cast<BasicOutputHandler *>(data);
|
|
|
|
|
2015-09-07 01:07:45 +02:00
|
|
|
output->recordingActive = true;
|
2019-02-26 15:37:01 +01:00
|
|
|
os_atomic_set_bool(&recording_active, true);
|
2015-02-06 12:17:33 +01:00
|
|
|
QMetaObject::invokeMethod(output->main, "RecordingStart");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void OBSStopRecording(void *data, calldata_t *params)
|
|
|
|
{
|
|
|
|
BasicOutputHandler *output = static_cast<BasicOutputHandler *>(data);
|
2015-06-10 06:00:22 +02:00
|
|
|
int code = (int)calldata_int(params, "code");
|
2019-03-30 15:44:44 +01:00
|
|
|
const char *last_error = calldata_string(params, "last_error");
|
|
|
|
|
|
|
|
QString arg_last_error = QString::fromUtf8(last_error);
|
2015-02-06 12:17:33 +01:00
|
|
|
|
2015-09-07 01:07:45 +02:00
|
|
|
output->recordingActive = false;
|
2019-02-26 15:37:01 +01:00
|
|
|
os_atomic_set_bool(&recording_active, false);
|
2019-07-08 00:47:29 +02:00
|
|
|
os_atomic_set_bool(&recording_paused, false);
|
2015-06-10 06:00:22 +02:00
|
|
|
QMetaObject::invokeMethod(output->main, "RecordingStop",
|
2019-03-30 15:44:44 +01:00
|
|
|
Q_ARG(int, code),
|
|
|
|
Q_ARG(QString, arg_last_error));
|
2015-02-06 12:17:33 +01:00
|
|
|
}
|
|
|
|
|
2023-01-29 03:42:41 +01:00
|
|
|
static void OBSRecordStopping(void *data, calldata_t * /* params */)
|
2016-06-22 10:47:08 +02:00
|
|
|
{
|
|
|
|
BasicOutputHandler *output = static_cast<BasicOutputHandler *>(data);
|
|
|
|
QMetaObject::invokeMethod(output->main, "RecordStopping");
|
|
|
|
}
|
|
|
|
|
2021-10-03 12:06:46 +02:00
|
|
|
static void OBSRecordFileChanged(void *data, calldata_t *params)
|
|
|
|
{
|
|
|
|
BasicOutputHandler *output = static_cast<BasicOutputHandler *>(data);
|
|
|
|
const char *next_file = calldata_string(params, "next_file");
|
|
|
|
|
|
|
|
QString arg_last_file =
|
|
|
|
QString::fromUtf8(output->lastRecordingPath.c_str());
|
|
|
|
|
|
|
|
QMetaObject::invokeMethod(output->main, "RecordingFileChanged",
|
|
|
|
Q_ARG(QString, arg_last_file));
|
|
|
|
|
|
|
|
output->lastRecordingPath = next_file;
|
|
|
|
}
|
|
|
|
|
2023-01-29 03:42:41 +01:00
|
|
|
static void OBSStartReplayBuffer(void *data, calldata_t * /* params */)
|
2016-12-09 23:40:04 +01:00
|
|
|
{
|
|
|
|
BasicOutputHandler *output = static_cast<BasicOutputHandler *>(data);
|
|
|
|
|
|
|
|
output->replayBufferActive = true;
|
2019-02-26 15:37:01 +01:00
|
|
|
os_atomic_set_bool(&replaybuf_active, true);
|
2016-12-09 23:40:04 +01:00
|
|
|
QMetaObject::invokeMethod(output->main, "ReplayBufferStart");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void OBSStopReplayBuffer(void *data, calldata_t *params)
|
|
|
|
{
|
|
|
|
BasicOutputHandler *output = static_cast<BasicOutputHandler *>(data);
|
|
|
|
int code = (int)calldata_int(params, "code");
|
|
|
|
|
|
|
|
output->replayBufferActive = false;
|
2019-02-26 15:37:01 +01:00
|
|
|
os_atomic_set_bool(&replaybuf_active, false);
|
2016-12-09 23:40:04 +01:00
|
|
|
QMetaObject::invokeMethod(output->main, "ReplayBufferStop",
|
|
|
|
Q_ARG(int, code));
|
|
|
|
}
|
|
|
|
|
2023-01-29 03:42:41 +01:00
|
|
|
static void OBSReplayBufferStopping(void *data, calldata_t * /* params */)
|
2016-12-09 23:40:04 +01:00
|
|
|
{
|
|
|
|
BasicOutputHandler *output = static_cast<BasicOutputHandler *>(data);
|
|
|
|
QMetaObject::invokeMethod(output->main, "ReplayBufferStopping");
|
|
|
|
}
|
|
|
|
|
2023-01-29 03:42:41 +01:00
|
|
|
static void OBSReplayBufferSaved(void *data, calldata_t * /* params */)
|
2020-10-13 01:55:01 +02:00
|
|
|
{
|
|
|
|
BasicOutputHandler *output = static_cast<BasicOutputHandler *>(data);
|
|
|
|
QMetaObject::invokeMethod(output->main, "ReplayBufferSaved",
|
|
|
|
Qt::QueuedConnection);
|
|
|
|
}
|
|
|
|
|
2023-01-29 03:42:41 +01:00
|
|
|
static void OBSStartVirtualCam(void *data, calldata_t * /* params */)
|
2020-06-20 16:42:14 +02:00
|
|
|
{
|
|
|
|
BasicOutputHandler *output = static_cast<BasicOutputHandler *>(data);
|
|
|
|
|
|
|
|
output->virtualCamActive = true;
|
|
|
|
os_atomic_set_bool(&virtualcam_active, true);
|
|
|
|
QMetaObject::invokeMethod(output->main, "OnVirtualCamStart");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void OBSStopVirtualCam(void *data, calldata_t *params)
|
|
|
|
{
|
|
|
|
BasicOutputHandler *output = static_cast<BasicOutputHandler *>(data);
|
|
|
|
int code = (int)calldata_int(params, "code");
|
|
|
|
|
|
|
|
output->virtualCamActive = false;
|
|
|
|
os_atomic_set_bool(&virtualcam_active, false);
|
|
|
|
QMetaObject::invokeMethod(output->main, "OnVirtualCamStop",
|
|
|
|
Q_ARG(int, code));
|
UI: Wait for full vcam deactivation to destroy its view
A bug which was technically introduced in df446c3f6e: the author
assigned video mixes to the virtual camera and did not realize you have
to wait for full capture stop with the "deactivate" signal rather than
the "stop" signal. This situation is understandable because these
signals are likely confusing and need more documentation.
The way an output works when it stops is it has three stages:
- "stopping", which is the moment the user themselves stop the output
- "stop", when the output's implementation has stopped and returns
success or an error code
- "deactivate", when the output inself (not the implementation) has
fully stopped capturing encoded or raw frame data after the
implementation has stopped. This is done in a separate thread,
end_data_capture_thread(), for performance and data race reasons, and
is when it's "actually fully stopped for real this time"
(Lain note: I sincerely apologize for this confusing signal design)
The author of df446c3f6e was likely confused as to why they could not
destroy the video mix in the "stop" signal without triggering a race
condition in end_data_capture_thread(), and instead decided to make a
workaround to clear the video mix set to the output before destroying
the video mix. Unsetting the video mix I'm guessing *seemed* to fix the
problem for them at the time, and destroying the video mix separately
after that automatically stops capture, so it *technically* worked
because the deactivate thread cannot be called until the
implementation's stop signal has executed. However, it was still the
incorrect way to handle the problem, because it circumvents the output's
mechanism for deactivating the frame data capture by destroying the view
instead.
The reason this was the incorrect way to handle the problem became
exposed in 7cd7ca80f8, when tytan made it so it uses the main video mix
under certain circumstances. The main view is special and cannot be
destroyed, so the mechanism to stop frame data capture that the
virtualcam was using before failed, and raw frame data capture continued
perpetually until the end of the program erroneously.
This fix solves the bug by using the "deactivate" signal rather than the
"stop" signal, thus allowing the output to fully end its data capture
and *then* destroy the video mix.
Fixes obsproject/obs-studio#9153
2023-07-06 23:56:48 +02:00
|
|
|
}
|
2022-07-19 18:32:39 +02:00
|
|
|
|
UI: Wait for full vcam deactivation to destroy its view
A bug which was technically introduced in df446c3f6e: the author
assigned video mixes to the virtual camera and did not realize you have
to wait for full capture stop with the "deactivate" signal rather than
the "stop" signal. This situation is understandable because these
signals are likely confusing and need more documentation.
The way an output works when it stops is it has three stages:
- "stopping", which is the moment the user themselves stop the output
- "stop", when the output's implementation has stopped and returns
success or an error code
- "deactivate", when the output inself (not the implementation) has
fully stopped capturing encoded or raw frame data after the
implementation has stopped. This is done in a separate thread,
end_data_capture_thread(), for performance and data race reasons, and
is when it's "actually fully stopped for real this time"
(Lain note: I sincerely apologize for this confusing signal design)
The author of df446c3f6e was likely confused as to why they could not
destroy the video mix in the "stop" signal without triggering a race
condition in end_data_capture_thread(), and instead decided to make a
workaround to clear the video mix set to the output before destroying
the video mix. Unsetting the video mix I'm guessing *seemed* to fix the
problem for them at the time, and destroying the video mix separately
after that automatically stops capture, so it *technically* worked
because the deactivate thread cannot be called until the
implementation's stop signal has executed. However, it was still the
incorrect way to handle the problem, because it circumvents the output's
mechanism for deactivating the frame data capture by destroying the view
instead.
The reason this was the incorrect way to handle the problem became
exposed in 7cd7ca80f8, when tytan made it so it uses the main video mix
under certain circumstances. The main view is special and cannot be
destroyed, so the mechanism to stop frame data capture that the
virtualcam was using before failed, and raw frame data capture continued
perpetually until the end of the program erroneously.
This fix solves the bug by using the "deactivate" signal rather than the
"stop" signal, thus allowing the output to fully end its data capture
and *then* destroy the video mix.
Fixes obsproject/obs-studio#9153
2023-07-06 23:56:48 +02:00
|
|
|
static void OBSDeactivateVirtualCam(void *data, calldata_t * /* params */)
|
|
|
|
{
|
|
|
|
BasicOutputHandler *output = static_cast<BasicOutputHandler *>(data);
|
2022-08-22 16:04:13 +02:00
|
|
|
output->DestroyVirtualCamView();
|
2020-06-20 16:42:14 +02:00
|
|
|
}
|
|
|
|
|
2015-02-06 12:17:33 +01:00
|
|
|
/* ------------------------------------------------------------------------ */
|
|
|
|
|
2024-07-08 14:07:10 +02:00
|
|
|
struct StartMultitrackVideoStreamingGuard {
|
|
|
|
StartMultitrackVideoStreamingGuard()
|
|
|
|
{
|
|
|
|
future = guard.get_future().share();
|
|
|
|
};
|
|
|
|
~StartMultitrackVideoStreamingGuard() { guard.set_value(); }
|
|
|
|
|
|
|
|
std::shared_future<void> GetFuture() const { return future; }
|
|
|
|
|
|
|
|
static std::shared_future<void> MakeReadyFuture()
|
|
|
|
{
|
|
|
|
StartMultitrackVideoStreamingGuard guard;
|
|
|
|
return guard.GetFuture();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::promise<void> guard;
|
|
|
|
std::shared_future<void> future;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------ */
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-10-07 11:42:12 +02:00
|
|
|
static inline bool can_use_output(const char *prot, const char *output,
|
|
|
|
const char *prot_test1,
|
|
|
|
const char *prot_test2 = nullptr)
|
|
|
|
{
|
|
|
|
return (strcmp(prot, prot_test1) == 0 ||
|
|
|
|
(prot_test2 && strcmp(prot, prot_test2) == 0)) &&
|
|
|
|
(obs_get_output_flags(output) & OBS_OUTPUT_SERVICE) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool return_first_id(void *data, const char *id)
|
|
|
|
{
|
|
|
|
const char **output = (const char **)data;
|
|
|
|
|
|
|
|
*output = id;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *GetStreamOutputType(const obs_service_t *service)
|
|
|
|
{
|
|
|
|
const char *protocol = obs_service_get_protocol(service);
|
|
|
|
const char *output = nullptr;
|
|
|
|
|
|
|
|
if (!protocol) {
|
|
|
|
blog(LOG_WARNING, "The service '%s' has no protocol set",
|
|
|
|
obs_service_get_id(service));
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!obs_is_output_protocol_registered(protocol)) {
|
|
|
|
blog(LOG_WARNING, "The protocol '%s' is not registered",
|
|
|
|
protocol);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if the service has a preferred output type */
|
|
|
|
output = obs_service_get_preferred_output_type(service);
|
|
|
|
if (output) {
|
|
|
|
if ((obs_get_output_flags(output) & OBS_OUTPUT_SERVICE) != 0)
|
|
|
|
return output;
|
|
|
|
|
|
|
|
blog(LOG_WARNING,
|
|
|
|
"The output '%s' is not registered, fallback to another one",
|
|
|
|
output);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Otherwise, prefer first-party output types */
|
|
|
|
if (can_use_output(protocol, "rtmp_output", "RTMP", "RTMPS")) {
|
|
|
|
return "rtmp_output";
|
|
|
|
} else if (can_use_output(protocol, "ffmpeg_hls_muxer", "HLS")) {
|
|
|
|
return "ffmpeg_hls_muxer";
|
|
|
|
} else if (can_use_output(protocol, "ffmpeg_mpegts_muxer", "SRT",
|
|
|
|
"RIST")) {
|
|
|
|
return "ffmpeg_mpegts_muxer";
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If third-party protocol, use the first enumerated type */
|
|
|
|
obs_enum_output_types_with_protocol(protocol, &output, return_first_id);
|
|
|
|
if (output)
|
|
|
|
return output;
|
|
|
|
|
|
|
|
blog(LOG_WARNING,
|
|
|
|
"No output compatible with the service '%s' is registered",
|
|
|
|
obs_service_get_id(service));
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-06-06 01:52:22 +02:00
|
|
|
/* ------------------------------------------------------------------------ */
|
2020-06-20 16:42:14 +02:00
|
|
|
|
|
|
|
inline BasicOutputHandler::BasicOutputHandler(OBSBasic *main_) : main(main_)
|
|
|
|
{
|
|
|
|
if (main->vcamEnabled) {
|
2022-09-20 15:45:27 +02:00
|
|
|
virtualCam = obs_output_create(
|
|
|
|
VIRTUAL_CAM_ID, "virtualcam_output", nullptr, nullptr);
|
2020-06-20 16:42:14 +02:00
|
|
|
|
|
|
|
signal_handler_t *signal =
|
|
|
|
obs_output_get_signal_handler(virtualCam);
|
|
|
|
startVirtualCam.Connect(signal, "start", OBSStartVirtualCam,
|
|
|
|
this);
|
|
|
|
stopVirtualCam.Connect(signal, "stop", OBSStopVirtualCam, this);
|
UI: Wait for full vcam deactivation to destroy its view
A bug which was technically introduced in df446c3f6e: the author
assigned video mixes to the virtual camera and did not realize you have
to wait for full capture stop with the "deactivate" signal rather than
the "stop" signal. This situation is understandable because these
signals are likely confusing and need more documentation.
The way an output works when it stops is it has three stages:
- "stopping", which is the moment the user themselves stop the output
- "stop", when the output's implementation has stopped and returns
success or an error code
- "deactivate", when the output inself (not the implementation) has
fully stopped capturing encoded or raw frame data after the
implementation has stopped. This is done in a separate thread,
end_data_capture_thread(), for performance and data race reasons, and
is when it's "actually fully stopped for real this time"
(Lain note: I sincerely apologize for this confusing signal design)
The author of df446c3f6e was likely confused as to why they could not
destroy the video mix in the "stop" signal without triggering a race
condition in end_data_capture_thread(), and instead decided to make a
workaround to clear the video mix set to the output before destroying
the video mix. Unsetting the video mix I'm guessing *seemed* to fix the
problem for them at the time, and destroying the video mix separately
after that automatically stops capture, so it *technically* worked
because the deactivate thread cannot be called until the
implementation's stop signal has executed. However, it was still the
incorrect way to handle the problem, because it circumvents the output's
mechanism for deactivating the frame data capture by destroying the view
instead.
The reason this was the incorrect way to handle the problem became
exposed in 7cd7ca80f8, when tytan made it so it uses the main video mix
under certain circumstances. The main view is special and cannot be
destroyed, so the mechanism to stop frame data capture that the
virtualcam was using before failed, and raw frame data capture continued
perpetually until the end of the program erroneously.
This fix solves the bug by using the "deactivate" signal rather than the
"stop" signal, thus allowing the output to fully end its data capture
and *then* destroy the video mix.
Fixes obsproject/obs-studio#9153
2023-07-06 23:56:48 +02:00
|
|
|
deactivateVirtualCam.Connect(signal, "deactivate",
|
|
|
|
OBSDeactivateVirtualCam, this);
|
2020-06-20 16:42:14 +02:00
|
|
|
}
|
2024-04-18 15:41:36 +02:00
|
|
|
|
|
|
|
auto multitrack_enabled = config_get_bool(main->Config(), "Stream1",
|
|
|
|
"EnableMultitrackVideo");
|
|
|
|
if (!config_has_user_value(main->Config(), "Stream1",
|
|
|
|
"EnableMultitrackVideo")) {
|
|
|
|
auto service = main_->GetService();
|
|
|
|
OBSDataAutoRelease settings = obs_service_get_settings(service);
|
|
|
|
multitrack_enabled = obs_data_has_user_value(
|
|
|
|
settings, "multitrack_video_configuration_url");
|
|
|
|
}
|
|
|
|
if (multitrack_enabled)
|
|
|
|
multitrackVideo = make_unique<MultitrackVideoOutput>();
|
2020-06-20 16:42:14 +02:00
|
|
|
}
|
|
|
|
|
2023-11-07 17:58:52 +01:00
|
|
|
extern void log_vcam_changed(const VCamConfig &config, bool starting);
|
2023-11-04 04:11:03 +01:00
|
|
|
|
2020-06-20 16:42:14 +02:00
|
|
|
bool BasicOutputHandler::StartVirtualCam()
|
|
|
|
{
|
2022-08-22 16:04:13 +02:00
|
|
|
if (!main->vcamEnabled)
|
|
|
|
return false;
|
2022-07-19 18:32:39 +02:00
|
|
|
|
2022-11-15 10:00:41 +01:00
|
|
|
bool typeIsProgram = main->vcamConfig.type ==
|
|
|
|
VCamOutputType::ProgramView;
|
|
|
|
|
|
|
|
if (!virtualCamView && !typeIsProgram)
|
2022-08-22 16:04:13 +02:00
|
|
|
virtualCamView = obs_view_create();
|
2020-09-03 15:56:03 +02:00
|
|
|
|
2022-08-22 16:04:13 +02:00
|
|
|
UpdateVirtualCamOutputSource();
|
2022-08-11 07:28:27 +02:00
|
|
|
|
2022-08-22 16:04:13 +02:00
|
|
|
if (!virtualCamVideo) {
|
2022-11-15 10:00:41 +01:00
|
|
|
virtualCamVideo = typeIsProgram ? obs_get_video()
|
|
|
|
: obs_view_add(virtualCamView);
|
2022-08-11 07:28:27 +02:00
|
|
|
|
2022-08-22 16:04:13 +02:00
|
|
|
if (!virtualCamVideo)
|
|
|
|
return false;
|
2020-06-20 16:42:14 +02:00
|
|
|
}
|
2022-08-22 16:04:13 +02:00
|
|
|
|
|
|
|
obs_output_set_media(virtualCam, virtualCamVideo, obs_get_audio());
|
|
|
|
if (!Active())
|
|
|
|
SetupOutputs();
|
|
|
|
|
|
|
|
bool success = obs_output_start(virtualCam);
|
2023-02-26 23:49:46 +01:00
|
|
|
if (!success) {
|
|
|
|
QString errorReason;
|
|
|
|
|
|
|
|
const char *error = obs_output_get_last_error(virtualCam);
|
|
|
|
if (error) {
|
|
|
|
errorReason = QT_UTF8(error);
|
|
|
|
} else {
|
|
|
|
errorReason = QTStr("Output.StartFailedGeneric");
|
|
|
|
}
|
|
|
|
|
|
|
|
QMessageBox::critical(main,
|
2023-05-19 04:18:00 +02:00
|
|
|
QTStr("Output.StartVirtualCamFailed"),
|
2023-02-26 23:49:46 +01:00
|
|
|
errorReason);
|
|
|
|
|
2022-08-22 16:04:13 +02:00
|
|
|
DestroyVirtualCamView();
|
2023-02-26 23:49:46 +01:00
|
|
|
}
|
2022-08-22 16:04:13 +02:00
|
|
|
|
2023-11-07 17:58:52 +01:00
|
|
|
log_vcam_changed(main->vcamConfig, true);
|
2023-11-04 04:11:03 +01:00
|
|
|
|
2022-08-22 16:04:13 +02:00
|
|
|
return success;
|
2020-06-20 16:42:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void BasicOutputHandler::StopVirtualCam()
|
|
|
|
{
|
|
|
|
if (main->vcamEnabled) {
|
|
|
|
obs_output_stop(virtualCam);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BasicOutputHandler::VirtualCamActive() const
|
|
|
|
{
|
|
|
|
if (main->vcamEnabled) {
|
|
|
|
return obs_output_active(virtualCam);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-08-22 16:04:13 +02:00
|
|
|
void BasicOutputHandler::UpdateVirtualCamOutputSource()
|
|
|
|
{
|
|
|
|
if (!main->vcamEnabled || !virtualCamView)
|
|
|
|
return;
|
|
|
|
|
|
|
|
OBSSourceAutoRelease source;
|
|
|
|
|
|
|
|
switch (main->vcamConfig.type) {
|
2022-11-15 10:00:41 +01:00
|
|
|
case VCamOutputType::Invalid:
|
|
|
|
case VCamOutputType::ProgramView:
|
2023-05-13 17:19:00 +02:00
|
|
|
DestroyVirtualCameraScene();
|
2022-11-15 10:00:41 +01:00
|
|
|
return;
|
|
|
|
case VCamOutputType::PreviewOutput: {
|
|
|
|
DestroyVirtualCameraScene();
|
|
|
|
OBSSource s = main->GetCurrentSceneSource();
|
|
|
|
obs_source_get_ref(s);
|
|
|
|
source = s.Get();
|
2022-08-22 16:04:13 +02:00
|
|
|
break;
|
2022-11-15 10:00:41 +01:00
|
|
|
}
|
2022-08-22 16:04:13 +02:00
|
|
|
case VCamOutputType::SceneOutput:
|
2023-05-13 17:19:00 +02:00
|
|
|
DestroyVirtualCameraScene();
|
2022-08-22 16:04:13 +02:00
|
|
|
source = obs_get_source_by_name(main->vcamConfig.scene.c_str());
|
|
|
|
break;
|
|
|
|
case VCamOutputType::SourceOutput:
|
2023-05-13 17:19:00 +02:00
|
|
|
OBSSourceAutoRelease s =
|
2022-08-22 16:04:13 +02:00
|
|
|
obs_get_source_by_name(main->vcamConfig.source.c_str());
|
|
|
|
|
|
|
|
if (!vCamSourceScene)
|
|
|
|
vCamSourceScene =
|
|
|
|
obs_scene_create_private("vcam_source");
|
|
|
|
source = obs_source_get_ref(
|
|
|
|
obs_scene_get_source(vCamSourceScene));
|
|
|
|
|
|
|
|
if (vCamSourceSceneItem &&
|
|
|
|
(obs_sceneitem_get_source(vCamSourceSceneItem) != s)) {
|
|
|
|
obs_sceneitem_remove(vCamSourceSceneItem);
|
|
|
|
vCamSourceSceneItem = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!vCamSourceSceneItem) {
|
|
|
|
vCamSourceSceneItem = obs_scene_add(vCamSourceScene, s);
|
|
|
|
|
|
|
|
obs_sceneitem_set_bounds_type(vCamSourceSceneItem,
|
|
|
|
OBS_BOUNDS_SCALE_INNER);
|
|
|
|
obs_sceneitem_set_bounds_alignment(vCamSourceSceneItem,
|
|
|
|
OBS_ALIGN_CENTER);
|
|
|
|
|
|
|
|
const struct vec2 size = {
|
|
|
|
(float)obs_source_get_width(source),
|
|
|
|
(float)obs_source_get_height(source),
|
|
|
|
};
|
|
|
|
obs_sceneitem_set_bounds(vCamSourceSceneItem, &size);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
OBSSourceAutoRelease current = obs_view_get_source(virtualCamView, 0);
|
|
|
|
if (source != current)
|
|
|
|
obs_view_set_source(virtualCamView, 0, source);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BasicOutputHandler::DestroyVirtualCamView()
|
|
|
|
{
|
2022-11-15 10:00:41 +01:00
|
|
|
if (main->vcamConfig.type == VCamOutputType::ProgramView) {
|
|
|
|
virtualCamVideo = nullptr;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-08-22 16:04:13 +02:00
|
|
|
obs_view_remove(virtualCamView);
|
|
|
|
obs_view_set_source(virtualCamView, 0, nullptr);
|
|
|
|
virtualCamVideo = nullptr;
|
|
|
|
|
|
|
|
obs_view_destroy(virtualCamView);
|
|
|
|
virtualCamView = nullptr;
|
|
|
|
|
2023-05-13 17:19:00 +02:00
|
|
|
DestroyVirtualCameraScene();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BasicOutputHandler::DestroyVirtualCameraScene()
|
|
|
|
{
|
2022-08-22 16:04:13 +02:00
|
|
|
if (!vCamSourceScene)
|
|
|
|
return;
|
|
|
|
|
|
|
|
obs_scene_release(vCamSourceScene);
|
|
|
|
vCamSourceScene = nullptr;
|
|
|
|
vCamSourceSceneItem = nullptr;
|
|
|
|
}
|
|
|
|
|
2020-06-20 16:42:14 +02:00
|
|
|
/* ------------------------------------------------------------------------ */
|
2015-06-06 01:52:22 +02:00
|
|
|
|
2015-02-06 12:17:33 +01:00
|
|
|
struct SimpleOutput : BasicOutputHandler {
|
2022-12-17 18:26:59 +01:00
|
|
|
OBSEncoder audioStreaming;
|
2022-05-07 05:17:55 +02:00
|
|
|
OBSEncoder videoStreaming;
|
2022-12-17 18:26:59 +01:00
|
|
|
OBSEncoder audioRecording;
|
|
|
|
OBSEncoder audioArchive;
|
2022-05-07 05:17:55 +02:00
|
|
|
OBSEncoder videoRecording;
|
2022-07-22 15:28:26 +02:00
|
|
|
OBSEncoder audioTrack[MAX_AUDIO_MIXES];
|
2015-02-06 12:17:33 +01: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-19 07:29:36 +02:00
|
|
|
string videoEncoder;
|
|
|
|
string videoQuality;
|
|
|
|
bool usingRecordingPreset = false;
|
2016-12-09 23:40:04 +01:00
|
|
|
bool recordingConfigured = false;
|
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-19 07:29:36 +02:00
|
|
|
bool ffmpegOutput = false;
|
|
|
|
bool lowCPUx264 = false;
|
2015-07-02 10:00:22 +02:00
|
|
|
|
2015-02-06 12:17:33 +01:00
|
|
|
SimpleOutput(OBSBasic *main_);
|
|
|
|
|
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-19 07:29:36 +02:00
|
|
|
int CalcCRF(int crf);
|
|
|
|
|
|
|
|
void UpdateRecordingSettings_x264_crf(int crf);
|
2022-11-22 02:56:05 +01:00
|
|
|
void UpdateRecordingSettings_qsv11(int crf, bool av1);
|
2016-05-08 20:21:37 +02:00
|
|
|
void UpdateRecordingSettings_nvenc(int cqp);
|
2022-09-19 10:55:19 +02:00
|
|
|
void UpdateRecordingSettings_nvenc_hevc_av1(int cqp);
|
2016-09-27 01:29:33 +02:00
|
|
|
void UpdateRecordingSettings_amd_cqp(int cqp);
|
2022-06-23 02:46:03 +02:00
|
|
|
void UpdateRecordingSettings_apple(int quality);
|
2022-10-23 03:55:20 +02:00
|
|
|
#ifdef ENABLE_HEVC
|
|
|
|
void UpdateRecordingSettings_apple_hevc(int quality);
|
|
|
|
#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-19 07:29:36 +02:00
|
|
|
void UpdateRecordingSettings();
|
|
|
|
void UpdateRecordingAudioSettings();
|
2015-02-06 12:17:33 +01:00
|
|
|
virtual void Update() override;
|
|
|
|
|
2020-09-03 15:56:03 +02:00
|
|
|
void SetupOutputs() override;
|
2015-07-02 09:58:28 +02:00
|
|
|
int GetAudioBitrate() const;
|
2015-02-06 12:17:33 +01:00
|
|
|
|
2022-05-07 05:17:55 +02:00
|
|
|
void LoadRecordingPreset_Lossy(const char *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-19 07:29:36 +02:00
|
|
|
void LoadRecordingPreset_Lossless();
|
|
|
|
void LoadRecordingPreset();
|
|
|
|
|
2022-05-07 05:17:55 +02:00
|
|
|
void LoadStreamingPreset_Lossy(const char *encoder);
|
2016-04-18 09:56:51 +02:00
|
|
|
|
2016-12-09 23:40:04 +01:00
|
|
|
void UpdateRecording();
|
|
|
|
bool ConfigureRecording(bool useReplayBuffer);
|
|
|
|
|
2024-04-18 15:41:36 +02:00
|
|
|
bool IsVodTrackEnabled(obs_service_t *service);
|
2020-11-14 17:05:52 +01:00
|
|
|
void SetupVodTrack(obs_service_t *service);
|
|
|
|
|
2024-07-08 14:07:10 +02:00
|
|
|
virtual std::shared_future<void>
|
|
|
|
SetupStreaming(obs_service_t *service,
|
|
|
|
SetupStreamingContinuation_t continuation) override;
|
2015-02-06 12:17:33 +01:00
|
|
|
virtual bool StartStreaming(obs_service_t *service) override;
|
|
|
|
virtual bool StartRecording() override;
|
2016-12-09 23:40:04 +01:00
|
|
|
virtual bool StartReplayBuffer() override;
|
2016-09-09 16:37:54 +02:00
|
|
|
virtual void StopStreaming(bool force) override;
|
|
|
|
virtual void StopRecording(bool force) override;
|
2016-12-09 23:40:04 +01:00
|
|
|
virtual void StopReplayBuffer(bool force) override;
|
2015-02-06 12:17:33 +01:00
|
|
|
virtual bool StreamingActive() const override;
|
|
|
|
virtual bool RecordingActive() const override;
|
2016-12-09 23:40:04 +01:00
|
|
|
virtual bool ReplayBufferActive() const override;
|
2015-02-06 12:17:33 +01: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-19 07:29:36 +02: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 10:25:39 +01:00
|
|
|
OBSDataAutoRelease settings = obs_data_create();
|
2016-02-10 03:46:15 +01:00
|
|
|
obs_data_set_string(settings, "format_name", "avi");
|
2015-09-20 06:21:34 +02:00
|
|
|
obs_data_set_string(settings, "video_encoder", "utvideo");
|
2016-02-10 04:24:44 +01: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-19 07:29:36 +02:00
|
|
|
|
|
|
|
obs_output_update(fileOutput, settings);
|
|
|
|
}
|
|
|
|
|
2022-05-07 05:17:55 +02: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-19 07:29:36 +02:00
|
|
|
{
|
2022-05-07 05:17:55 +02: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 09:56:51 +02: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-19 07:29:36 +02:00
|
|
|
|
2022-05-07 05:17:55 +02:00
|
|
|
void SimpleOutput::LoadStreamingPreset_Lossy(const char *encoderId)
|
2016-04-18 09:56:51 +02:00
|
|
|
{
|
2022-05-07 05:17:55 +02: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-19 07:29:36 +02:00
|
|
|
}
|
|
|
|
|
2022-07-24 05:52:14 +02: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-22 02:33:20 +01:00
|
|
|
return "obs_qsv11_v2";
|
2022-11-22 02:56:05 +01:00
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_QSV_AV1) == 0) {
|
|
|
|
return "obs_qsv11_av1";
|
2022-07-24 05:52:14 +02: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 09:38:23 +01:00
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_AMD_AV1) == 0) {
|
|
|
|
return "av1_texture_amf";
|
2022-07-24 05:52:14 +02:00
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_NVENC) == 0) {
|
|
|
|
return EncoderAvailable("jim_nvenc") ? "jim_nvenc"
|
|
|
|
: "ffmpeg_nvenc";
|
|
|
|
#ifdef ENABLE_HEVC
|
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_NVENC_HEVC) == 0) {
|
|
|
|
return EncoderAvailable("jim_hevc_nvenc") ? "jim_hevc_nvenc"
|
|
|
|
: "ffmpeg_hevc_nvenc";
|
|
|
|
#endif
|
2022-09-19 10:55:19 +02:00
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_NVENC_AV1) == 0) {
|
|
|
|
return "jim_av1_nvenc";
|
2022-07-24 05:52:14 +02: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-24 05:52:14 +02: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-19 07:29:36 +02: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-19 07:29:36 +02:00
|
|
|
|
|
|
|
videoEncoder = encoder;
|
|
|
|
videoQuality = quality;
|
|
|
|
ffmpegOutput = false;
|
|
|
|
|
|
|
|
if (strcmp(quality, "Stream") == 0) {
|
2022-05-07 05:17:55 +02: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-19 07:29:36 +02:00
|
|
|
usingRecordingPreset = false;
|
|
|
|
return;
|
|
|
|
|
|
|
|
} else if (strcmp(quality, "Lossless") == 0) {
|
|
|
|
LoadRecordingPreset_Lossless();
|
|
|
|
usingRecordingPreset = true;
|
|
|
|
ffmpegOutput = true;
|
|
|
|
return;
|
|
|
|
|
|
|
|
} else {
|
2016-04-18 09:56:51 +02:00
|
|
|
lowCPUx264 = false;
|
|
|
|
|
2022-07-24 05:52:14 +02:00
|
|
|
if (strcmp(encoder, SIMPLE_ENCODER_X264_LOWCPU) == 0)
|
2016-04-18 09:56:51 +02:00
|
|
|
lowCPUx264 = true;
|
2022-07-24 05:52:14 +02: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-19 07:29:36 +02:00
|
|
|
usingRecordingPreset = true;
|
2016-04-18 09:56:51 +02: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 09:56:51 +02: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-19 07:29:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-17 18:26:59 +01:00
|
|
|
#define SIMPLE_ARCHIVE_NAME "simple_archive_audio"
|
2020-12-03 09:59:43 +01:00
|
|
|
|
2015-02-06 12:17:33 +01:00
|
|
|
SimpleOutput::SimpleOutput(OBSBasic *main_) : BasicOutputHandler(main_)
|
|
|
|
{
|
2016-04-18 09:56:51 +02: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-06 03:22:40 +01:00
|
|
|
|
2022-07-24 05:52:14 +02:00
|
|
|
LoadStreamingPreset_Lossy(get_simple_output_encoder(encoder));
|
2015-02-06 12:17:33 +01: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 12:17:33 +01: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-19 07:29:36 +02:00
|
|
|
LoadRecordingPreset();
|
|
|
|
|
|
|
|
if (!ffmpegOutput) {
|
2016-12-09 23:40:04 +01:00
|
|
|
bool useReplayBuffer = config_get_bool(main->Config(),
|
2016-12-07 14:21:44 +01:00
|
|
|
"SimpleOutput", "RecRB");
|
2024-04-27 03:55:47 +02:00
|
|
|
const char *recFormat = config_get_string(
|
|
|
|
main->Config(), "SimpleOutput", "RecFormat2");
|
|
|
|
|
2016-12-09 23:40:04 +01:00
|
|
|
if (useReplayBuffer) {
|
2021-11-26 10:25:39 +01:00
|
|
|
OBSDataAutoRelease hotkey;
|
2016-12-07 14:21:44 +01: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 23:40:04 +01:00
|
|
|
replayBuffer = obs_output_create("replay_buffer",
|
2016-12-07 14:21:44 +01:00
|
|
|
Str("ReplayBuffer"),
|
|
|
|
nullptr, hotkey);
|
|
|
|
|
2016-12-09 23:40:04 +01:00
|
|
|
if (!replayBuffer)
|
|
|
|
throw "Failed to create replay buffer output "
|
|
|
|
"(simple output)";
|
|
|
|
|
|
|
|
signal_handler_t *signal =
|
|
|
|
obs_output_get_signal_handler(replayBuffer);
|
|
|
|
|
|
|
|
startReplayBuffer.Connect(signal, "start",
|
|
|
|
OBSStartReplayBuffer, this);
|
|
|
|
stopReplayBuffer.Connect(signal, "stop",
|
|
|
|
OBSStopReplayBuffer, this);
|
|
|
|
replayBufferStopping.Connect(signal, "stopping",
|
|
|
|
OBSReplayBufferStopping,
|
|
|
|
this);
|
2020-10-13 01:55:01 +02:00
|
|
|
replayBufferSaved.Connect(signal, "saved",
|
|
|
|
OBSReplayBufferSaved, this);
|
2016-12-07 14:21:44 +01:00
|
|
|
}
|
|
|
|
|
2024-04-27 03:55:47 +02:00
|
|
|
bool use_native = strcmp(recFormat, "hybrid_mp4") == 0;
|
2016-12-09 23:40:04 +01:00
|
|
|
fileOutput = obs_output_create(
|
2024-04-27 03:55:47 +02:00
|
|
|
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-19 07:29:36 +02: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),
|
2015-02-06 12:17:33 +01:00
|
|
|
"start", OBSStartRecording, this);
|
2015-07-04 08:00:21 +02:00
|
|
|
stopRecording.Connect(obs_output_get_signal_handler(fileOutput), "stop",
|
2015-02-06 12:17:33 +01:00
|
|
|
OBSStopRecording, this);
|
2016-06-22 10:47:08 +02:00
|
|
|
recordStopping.Connect(obs_output_get_signal_handler(fileOutput),
|
|
|
|
"stopping", OBSRecordStopping, this);
|
2015-02-06 12:17:33 +01: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-22 03:36:26 +02: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 12:17:33 +01:00
|
|
|
void SimpleOutput::Update()
|
|
|
|
{
|
2022-05-07 05:17:55 +02:00
|
|
|
OBSDataAutoRelease videoSettings = obs_data_create();
|
2022-12-17 18:26:59 +01:00
|
|
|
OBSDataAutoRelease audioSettings = obs_data_create();
|
2015-02-06 12:17:33 +01:00
|
|
|
|
|
|
|
int videoBitrate =
|
|
|
|
config_get_uint(main->Config(), "SimpleOutput", "VBitrate");
|
2015-07-02 09:58:28 +02:00
|
|
|
int audioBitrate = GetAudioBitrate();
|
2015-02-06 12:17:33 +01:00
|
|
|
bool advanced =
|
|
|
|
config_get_bool(main->Config(), "SimpleOutput", "UseAdvanced");
|
2020-11-11 18:48:39 +01:00
|
|
|
bool enforceBitrate = !config_get_bool(main->Config(), "Stream1",
|
|
|
|
"IgnoreRecommended");
|
2015-02-06 12:17:33 +01:00
|
|
|
const char *custom = config_get_string(main->Config(), "SimpleOutput",
|
|
|
|
"x264Settings");
|
2016-04-18 09:56:51 +02:00
|
|
|
const char *encoder = config_get_string(main->Config(), "SimpleOutput",
|
|
|
|
"StreamEncoder");
|
|
|
|
const char *presetType;
|
|
|
|
const char *preset;
|
|
|
|
|
2016-09-27 01:29:33 +02:00
|
|
|
if (strcmp(encoder, SIMPLE_ENCODER_QSV) == 0) {
|
2016-04-18 09:56:51 +02:00
|
|
|
presetType = "QSVPreset";
|
2016-09-27 01:29:33 +02:00
|
|
|
|
2022-11-22 02:56:05 +01:00
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_QSV_AV1) == 0) {
|
|
|
|
presetType = "QSVPreset";
|
|
|
|
|
2016-09-27 01:29:33 +02:00
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_AMD) == 0) {
|
|
|
|
presetType = "AMDPreset";
|
2022-07-21 22:02:21 +02:00
|
|
|
|
|
|
|
#ifdef ENABLE_HEVC
|
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_AMD_HEVC) == 0) {
|
|
|
|
presetType = "AMDPreset";
|
|
|
|
#endif
|
2016-09-27 01:29:33 +02:00
|
|
|
|
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_NVENC) == 0) {
|
2022-11-01 04:45:25 +01:00
|
|
|
presetType = "NVENCPreset2";
|
2016-09-27 01:29:33 +02:00
|
|
|
|
2022-05-19 06:53:37 +02:00
|
|
|
#ifdef ENABLE_HEVC
|
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_NVENC_HEVC) == 0) {
|
2022-11-01 04:45:25 +01:00
|
|
|
presetType = "NVENCPreset2";
|
2022-05-19 06:53:37 +02:00
|
|
|
#endif
|
|
|
|
|
2022-11-08 09:38:23 +01:00
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_AMD_AV1) == 0) {
|
|
|
|
presetType = "AMDAV1Preset";
|
|
|
|
|
2022-09-19 10:55:19 +02:00
|
|
|
} else if (strcmp(encoder, SIMPLE_ENCODER_NVENC_AV1) == 0) {
|
2022-11-01 04:45:25 +01:00
|
|
|
presetType = "NVENCPreset2";
|
2022-09-19 10:55:19 +02:00
|
|
|
|
2016-09-27 01:29:33 +02:00
|
|
|
} else {
|
2016-04-18 09:56:51 +02:00
|
|
|
presetType = "Preset";
|
2016-09-27 01:29:33 +02:00
|
|
|
}
|
2016-04-18 09:56:51 +02:00
|
|
|
|
|
|
|
preset = config_get_string(main->Config(), "SimpleOutput", presetType);
|
2022-10-20 18:08:57 +02:00
|
|
|
obs_data_set_string(videoSettings,
|
2022-11-01 04:45:25 +01:00
|
|
|
(strcmp(presetType, "NVENCPreset2") == 0)
|
|
|
|
? "preset2"
|
|
|
|
: "preset",
|
2022-10-20 18:08:57 +02:00
|
|
|
preset);
|
2015-02-06 12:17:33 +01:00
|
|
|
|
2022-05-07 05:17:55 +02:00
|
|
|
obs_data_set_string(videoSettings, "rate_control", "CBR");
|
|
|
|
obs_data_set_int(videoSettings, "bitrate", videoBitrate);
|
2015-02-06 12:17:33 +01:00
|
|
|
|
2022-06-25 19:24:04 +02:00
|
|
|
if (advanced)
|
2022-05-07 05:17:55 +02:00
|
|
|
obs_data_set_string(videoSettings, "x264opts", custom);
|
2015-02-06 12:17:33 +01: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 12:17:33 +01:00
|
|
|
|
2022-05-07 05:17:55 +02:00
|
|
|
obs_service_apply_encoder_settings(main->GetService(), videoSettings,
|
2022-12-17 18:26:59 +01:00
|
|
|
audioSettings);
|
2015-03-08 01:32:00 +01:00
|
|
|
|
2020-11-11 18:48:39 +01:00
|
|
|
if (!enforceBitrate) {
|
2023-08-15 22:43:59 +02:00
|
|
|
blog(LOG_INFO, "User is ignoring service bitrate limits.");
|
2022-05-07 05:17:55 +02: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-11 07:53:42 +02:00
|
|
|
}
|
2016-04-10 12:10:36 +02:00
|
|
|
|
2015-04-17 11:48:06 +02:00
|
|
|
video_t *video = obs_get_video();
|
|
|
|
enum video_format format = video_output_get_format(video);
|
|
|
|
|
2022-04-29 18:45:56 +02:00
|
|
|
switch (format) {
|
|
|
|
case VIDEO_FORMAT_I420:
|
|
|
|
case VIDEO_FORMAT_NV12:
|
|
|
|
case VIDEO_FORMAT_I010:
|
|
|
|
case VIDEO_FORMAT_P010:
|
|
|
|
break;
|
|
|
|
default:
|
2022-05-07 05:17:55 +02:00
|
|
|
obs_encoder_set_preferred_video_format(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-19 07:29:36 +02:00
|
|
|
VIDEO_FORMAT_NV12);
|
2022-04-29 18:45:56 +02:00
|
|
|
}
|
2015-04-17 11:48:06 +02:00
|
|
|
|
2022-05-07 05:17:55 +02: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 12:17:33 +01: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-19 07:29:36 +02:00
|
|
|
void SimpleOutput::UpdateRecordingAudioSettings()
|
|
|
|
{
|
2021-11-26 10:25:39 +01: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-19 07:29:36 +02:00
|
|
|
obs_data_set_int(settings, "bitrate", 192);
|
2016-05-08 20:20:51 +02: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-19 07:29:36 +02:00
|
|
|
|
2022-07-22 15:28:26 +02:00
|
|
|
int tracks =
|
|
|
|
config_get_int(main->Config(), "SimpleOutput", "RecTracks");
|
|
|
|
const char *recFormat =
|
2023-03-26 07:07:25 +02:00
|
|
|
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-19 07:29:36 +02: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 10:25:39 +01: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-19 07:29:36 +02:00
|
|
|
obs_data_set_int(settings, "crf", crf);
|
|
|
|
obs_data_set_bool(settings, "use_bufsize", true);
|
2016-05-08 20:20:51 +02: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-19 07:29:36 +02:00
|
|
|
obs_data_set_string(settings, "profile", "high");
|
|
|
|
obs_data_set_string(settings, "preset",
|
|
|
|
lowCPUx264 ? "ultrafast" : "veryfast");
|
|
|
|
|
2022-05-07 05:17:55 +02: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-19 07:29:36 +02:00
|
|
|
}
|
|
|
|
|
2016-04-18 09:56:51 +02: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 22:19:38 +02:00
|
|
|
if (strcmp(val, "ICQ") == 0) {
|
2016-04-18 09:56:51 +02:00
|
|
|
icq_found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
obs_properties_destroy(props);
|
|
|
|
return icq_found;
|
|
|
|
}
|
|
|
|
|
2022-11-22 02:56:05 +01:00
|
|
|
void SimpleOutput::UpdateRecordingSettings_qsv11(int crf, bool av1)
|
2016-04-18 09:56:51 +02:00
|
|
|
{
|
2022-05-07 05:17:55 +02:00
|
|
|
bool icq = icq_available(videoRecording);
|
2016-04-18 09:56:51 +02:00
|
|
|
|
2021-11-26 10:25:39 +01:00
|
|
|
OBSDataAutoRelease settings = obs_data_create();
|
2016-04-18 09:56:51 +02:00
|
|
|
obs_data_set_string(settings, "profile", "high");
|
|
|
|
|
2022-11-22 02:56:05 +01:00
|
|
|
if (icq && !av1) {
|
2016-05-11 22:19:38 +02:00
|
|
|
obs_data_set_string(settings, "rate_control", "ICQ");
|
2016-04-18 09:56:51 +02:00
|
|
|
obs_data_set_int(settings, "icq_quality", crf);
|
|
|
|
} else {
|
|
|
|
obs_data_set_string(settings, "rate_control", "CQP");
|
2022-11-22 02:33:20 +01:00
|
|
|
obs_data_set_int(settings, "cqp", crf);
|
2016-04-18 09:56:51 +02:00
|
|
|
}
|
|
|
|
|
2022-05-07 05:17:55 +02:00
|
|
|
obs_encoder_update(videoRecording, settings);
|
2016-04-18 09:56:51 +02:00
|
|
|
}
|
|
|
|
|
2016-05-08 20:21:37 +02:00
|
|
|
void SimpleOutput::UpdateRecordingSettings_nvenc(int cqp)
|
2016-04-19 01:12:59 +02:00
|
|
|
{
|
2021-11-26 10:25:39 +01:00
|
|
|
OBSDataAutoRelease settings = obs_data_create();
|
2016-05-08 20:21:37 +02:00
|
|
|
obs_data_set_string(settings, "rate_control", "CQP");
|
2016-04-19 01:12:59 +02:00
|
|
|
obs_data_set_string(settings, "profile", "high");
|
2016-05-08 20:21:37 +02:00
|
|
|
obs_data_set_int(settings, "cqp", cqp);
|
2016-04-19 01:12:59 +02:00
|
|
|
|
2022-05-07 05:17:55 +02:00
|
|
|
obs_encoder_update(videoRecording, settings);
|
2016-04-19 01:12:59 +02:00
|
|
|
}
|
|
|
|
|
2022-09-19 10:55:19 +02:00
|
|
|
void SimpleOutput::UpdateRecordingSettings_nvenc_hevc_av1(int cqp)
|
2022-05-19 06:53:37 +02: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-27 01:29:33 +02:00
|
|
|
void SimpleOutput::UpdateRecordingSettings_amd_cqp(int cqp)
|
|
|
|
{
|
2021-11-26 10:25:39 +01:00
|
|
|
OBSDataAutoRelease settings = obs_data_create();
|
2022-07-21 22:02:21 +02:00
|
|
|
obs_data_set_string(settings, "rate_control", "CQP");
|
|
|
|
obs_data_set_string(settings, "profile", "high");
|
2022-07-24 20:14:17 +02:00
|
|
|
obs_data_set_string(settings, "preset", "quality");
|
2022-07-21 22:02:21 +02:00
|
|
|
obs_data_set_int(settings, "cqp", cqp);
|
2022-05-07 05:17:55 +02:00
|
|
|
obs_encoder_update(videoRecording, settings);
|
2016-09-27 01:29:33 +02: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-19 07:29:36 +02:00
|
|
|
void SimpleOutput::UpdateRecordingSettings()
|
|
|
|
{
|
2016-04-19 01:12:59 +02:00
|
|
|
bool ultra_hq = (videoQuality == "HQ");
|
|
|
|
int crf = CalcCRF(ultra_hq ? 16 : 23);
|
2016-04-18 09:56:51 +02: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-19 07:29:36 +02:00
|
|
|
if (astrcmp_n(videoEncoder.c_str(), "x264", 4) == 0) {
|
2016-04-18 09:56:51 +02:00
|
|
|
UpdateRecordingSettings_x264_crf(crf);
|
|
|
|
|
|
|
|
} else if (videoEncoder == SIMPLE_ENCODER_QSV) {
|
2022-11-22 02:56:05 +01:00
|
|
|
UpdateRecordingSettings_qsv11(crf, false);
|
|
|
|
|
|
|
|
} else if (videoEncoder == SIMPLE_ENCODER_QSV_AV1) {
|
|
|
|
UpdateRecordingSettings_qsv11(crf, true);
|
2016-04-19 01:12:59 +02:00
|
|
|
|
2016-09-27 01:29:33 +02:00
|
|
|
} else if (videoEncoder == SIMPLE_ENCODER_AMD) {
|
|
|
|
UpdateRecordingSettings_amd_cqp(crf);
|
|
|
|
|
2022-07-21 22:02:21 +02: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-19 01:12:59 +02:00
|
|
|
} else if (videoEncoder == SIMPLE_ENCODER_NVENC) {
|
2016-05-08 20:21:37 +02:00
|
|
|
UpdateRecordingSettings_nvenc(crf);
|
2022-05-19 06:53:37 +02:00
|
|
|
|
|
|
|
#ifdef ENABLE_HEVC
|
|
|
|
} else if (videoEncoder == SIMPLE_ENCODER_NVENC_HEVC) {
|
2022-09-19 10:55:19 +02:00
|
|
|
UpdateRecordingSettings_nvenc_hevc_av1(crf);
|
2022-05-19 06:53:37 +02:00
|
|
|
#endif
|
2022-09-19 10:55:19 +02: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-19 07:29:36 +02:00
|
|
|
}
|
2019-10-25 17:56:26 +02: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-19 07:29:36 +02:00
|
|
|
}
|
|
|
|
|
2015-02-06 12:17:33 +01:00
|
|
|
inline void SimpleOutput::SetupOutputs()
|
|
|
|
{
|
|
|
|
SimpleOutput::Update();
|
2022-05-07 05:17:55 +02: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");
|
|
|
|
const char *recFormat =
|
2023-03-26 07:07:25 +02:00
|
|
|
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-19 07:29:36 +02:00
|
|
|
|
|
|
|
if (usingRecordingPreset) {
|
|
|
|
if (ffmpegOutput) {
|
|
|
|
obs_output_set_media(fileOutput, obs_get_video(),
|
|
|
|
obs_get_audio());
|
|
|
|
} else {
|
2022-05-07 05:17:55 +02: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-19 07:29:36 +02: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-19 07:29:36 +02:00
|
|
|
}
|
2015-02-06 12:17:33 +01:00
|
|
|
}
|
|
|
|
|
2017-07-13 12:57:42 +02:00
|
|
|
const char *FindAudioEncoderFromCodec(const char *type)
|
|
|
|
{
|
|
|
|
const char *alt_enc_id = nullptr;
|
|
|
|
size_t i = 0;
|
|
|
|
|
|
|
|
while (obs_enum_encoder_types(i++, &alt_enc_id)) {
|
|
|
|
const char *codec = obs_get_encoder_codec(alt_enc_id);
|
|
|
|
if (strcmp(type, codec) == 0) {
|
|
|
|
return alt_enc_id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2024-07-08 14:07:10 +02:00
|
|
|
std::shared_future<void>
|
|
|
|
SimpleOutput::SetupStreaming(obs_service_t *service,
|
|
|
|
SetupStreamingContinuation_t continuation)
|
2015-02-06 12:17:33 +01:00
|
|
|
{
|
2020-09-03 15:56:03 +02:00
|
|
|
if (!Active())
|
2015-02-06 12:17:33 +01:00
|
|
|
SetupOutputs();
|
|
|
|
|
2019-02-07 07:24:25 +01:00
|
|
|
Auth *auth = main->GetAuth();
|
|
|
|
if (auth)
|
|
|
|
auth->OnStreamConfig();
|
|
|
|
|
2017-07-13 12:57:42 +02: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-07-09 13:25:49 +02:00
|
|
|
auto handle_multitrack_video_result = [&](std::optional<bool>
|
|
|
|
multitrackVideoResult) {
|
|
|
|
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-07-08 14:07:10 +02:00
|
|
|
return SetupMultitrackVideo(
|
2024-06-18 15:12:57 +02:00
|
|
|
service, GetSimpleAACEncoderForBitrate(audio_bitrate), 0,
|
2024-07-08 14:07:10 +02:00
|
|
|
vod_track_mixer, [&, continuation](std::optional<bool> res) {
|
|
|
|
continuation(handle_multitrack_video_result(res));
|
|
|
|
});
|
2020-09-17 07:20:02 +02:00
|
|
|
}
|
2015-02-06 12:17:33 +01:00
|
|
|
|
2020-11-14 17:05:52 +01:00
|
|
|
static inline bool ServiceSupportsVodTrack(const char *service);
|
|
|
|
|
2020-12-03 09:59:43 +01:00
|
|
|
static void clear_archive_encoder(obs_output_t *output,
|
|
|
|
const char *expected_name)
|
|
|
|
{
|
|
|
|
obs_encoder_t *last = obs_output_get_audio_encoder(output, 1);
|
|
|
|
bool clear = false;
|
|
|
|
|
|
|
|
/* ensures that we don't remove twitch's soundtrack encoder */
|
|
|
|
if (last) {
|
|
|
|
const char *name = obs_encoder_get_name(last);
|
|
|
|
clear = name && strcmp(name, expected_name) == 0;
|
|
|
|
obs_encoder_release(last);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (clear)
|
|
|
|
obs_output_set_audio_encoder(output, nullptr, 1);
|
|
|
|
}
|
|
|
|
|
2024-04-18 15:41:36 +02:00
|
|
|
bool SimpleOutput::IsVodTrackEnabled(obs_service_t *service)
|
2020-11-14 17:05:52 +01:00
|
|
|
{
|
|
|
|
bool advanced =
|
|
|
|
config_get_bool(main->Config(), "SimpleOutput", "UseAdvanced");
|
|
|
|
bool enable = config_get_bool(main->Config(), "SimpleOutput",
|
|
|
|
"VodTrackEnabled");
|
2020-12-03 10:31:32 +01:00
|
|
|
bool enableForCustomServer = config_get_bool(
|
|
|
|
GetGlobalConfig(), "General", "EnableCustomServerVodTrack");
|
2020-11-14 17:05:52 +01:00
|
|
|
|
2021-11-26 10:25:39 +01:00
|
|
|
OBSDataAutoRelease settings = obs_service_get_settings(service);
|
2020-11-14 17:05:52 +01:00
|
|
|
const char *name = obs_data_get_string(settings, "service");
|
|
|
|
|
2020-12-03 10:20:37 +01: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 10:20:37 +01:00
|
|
|
else
|
2024-04-18 15:41:36 +02:00
|
|
|
return advanced && enable && ServiceSupportsVodTrack(name);
|
|
|
|
}
|
2020-12-03 10:20:37 +01: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 09:59:43 +01:00
|
|
|
else
|
|
|
|
clear_archive_encoder(streamOutput, SIMPLE_ARCHIVE_NAME);
|
2020-11-14 17:05:52 +01:00
|
|
|
}
|
|
|
|
|
2020-09-17 07:20:02 +02:00
|
|
|
bool SimpleOutput::StartStreaming(obs_service_t *service)
|
|
|
|
{
|
2015-09-11 04:10:40 +02: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-07 01:19:53 +02: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 17:30:54 +02:00
|
|
|
const char *bindIP =
|
|
|
|
config_get_string(main->Config(), "Output", "BindIP");
|
2023-06-16 00:17:24 +02: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 17:50:09 +02:00
|
|
|
bool enableDynBitrate =
|
|
|
|
config_get_bool(main->Config(), "Output", "DynamicBitrate");
|
2016-07-29 17:30:54 +02: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 10:25:39 +01:00
|
|
|
OBSDataAutoRelease settings = obs_data_create();
|
2016-07-29 17:30:54 +02:00
|
|
|
obs_data_set_string(settings, "bind_ip", bindIP);
|
2023-06-16 00:17:24 +02: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 17:50:09 +02: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 17:30:54 +02:00
|
|
|
obs_output_update(streamOutput, settings);
|
|
|
|
|
2015-02-06 12:17:33 +01:00
|
|
|
if (!reconnect)
|
|
|
|
maxRetries = 0;
|
|
|
|
|
2015-09-07 01:19:53 +02:00
|
|
|
obs_output_set_delay(streamOutput, useDelay ? delaySec : 0,
|
|
|
|
preserveDelay ? OBS_OUTPUT_DELAY_PRESERVE : 0);
|
|
|
|
|
2015-02-06 12:17:33 +01: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 17:05:52 +01:00
|
|
|
|
2015-02-06 12:17:33 +01:00
|
|
|
if (obs_output_start(streamOutput)) {
|
2024-04-18 15:41:36 +02:00
|
|
|
if (multitrackVideo && multitrackVideoActive)
|
|
|
|
multitrackVideo->StartedStreaming();
|
2015-02-06 12:17:33 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-04-18 15:41:36 +02:00
|
|
|
if (multitrackVideo && multitrackVideoActive)
|
|
|
|
multitrackVideoActive = false;
|
|
|
|
|
2017-10-06 13:48:24 +02:00
|
|
|
const char *error = obs_output_get_last_error(streamOutput);
|
2018-12-13 00:20:48 +01:00
|
|
|
bool hasLastError = error && *error;
|
|
|
|
if (hasLastError)
|
|
|
|
lastError = error;
|
|
|
|
else
|
|
|
|
lastError = string();
|
2017-10-06 13:48:24 +02:00
|
|
|
|
2023-01-16 06:27:47 +01:00
|
|
|
const char *type = obs_output_get_id(streamOutput);
|
2018-12-13 00:20:48 +01:00
|
|
|
blog(LOG_WARNING, "Stream output type '%s' failed to start!%s%s", type,
|
|
|
|
hasLastError ? " Last Error: " : "", hasLastError ? error : "");
|
2015-02-06 12:17:33 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-12-09 23:40:04 +01:00
|
|
|
void SimpleOutput::UpdateRecording()
|
2015-02-06 12:17:33 +01:00
|
|
|
{
|
2022-07-22 15:28:26 +02:00
|
|
|
const char *recFormat =
|
2023-03-26 07:07:25 +02:00
|
|
|
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 23:40:04 +01: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-19 07:29:36 +02:00
|
|
|
if (usingRecordingPreset) {
|
|
|
|
if (!ffmpegOutput)
|
|
|
|
UpdateRecordingSettings();
|
|
|
|
} else if (!obs_output_active(streamOutput)) {
|
|
|
|
Update();
|
|
|
|
}
|
|
|
|
|
2020-09-03 15:56:03 +02:00
|
|
|
if (!Active())
|
2015-02-06 12:17:33 +01:00
|
|
|
SetupOutputs();
|
|
|
|
|
2016-12-09 23:40:04 +01:00
|
|
|
if (!ffmpegOutput) {
|
2022-05-07 05:17:55 +02: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 23:40:04 +01:00
|
|
|
}
|
|
|
|
if (replayBuffer) {
|
2022-05-07 05:17:55 +02: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 23:40:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
recordingConfigured = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SimpleOutput::ConfigureRecording(bool updateReplayBuffer)
|
|
|
|
{
|
2015-02-06 12:17:33 +01:00
|
|
|
const char *path =
|
|
|
|
config_get_string(main->Config(), "SimpleOutput", "FilePath");
|
2015-05-29 18:45:54 +02:00
|
|
|
const char *format =
|
2023-03-24 12:44:37 +01:00
|
|
|
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 10:43:38 +01:00
|
|
|
const char *filenameFormat = config_get_string(main->Config(), "Output",
|
|
|
|
"FilenameFormatting");
|
|
|
|
bool overwriteIfExists =
|
|
|
|
config_get_bool(main->Config(), "Output", "OverwriteIfExists");
|
2016-12-09 23:42:14 +01:00
|
|
|
const char *rbPrefix = config_get_string(main->Config(), "SimpleOutput",
|
|
|
|
"RecRBPrefix");
|
|
|
|
const char *rbSuffix = config_get_string(main->Config(), "SimpleOutput",
|
|
|
|
"RecRBSuffix");
|
2016-12-07 14:21:44 +01: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 12:17:33 +01: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 15:45:03 +02:00
|
|
|
string f;
|
2015-02-06 12:17:33 +01:00
|
|
|
|
2021-11-26 10:25:39 +01:00
|
|
|
OBSDataAutoRelease settings = obs_data_create();
|
2016-12-09 23:40:04 +01:00
|
|
|
if (updateReplayBuffer) {
|
2020-07-23 15:45:03 +02:00
|
|
|
f = GetFormatString(filenameFormat, rbPrefix, rbSuffix);
|
2023-04-05 00:46:07 +02:00
|
|
|
string ext = GetFormatExt(format);
|
2016-12-07 14:21:44 +01:00
|
|
|
obs_data_set_string(settings, "directory", path);
|
2016-12-09 23:42:14 +01: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 14:21:44 +01: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 15:45:03 +02: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 14:21:44 +01: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 14:21:44 +01:00
|
|
|
}
|
2016-12-09 23:40:04 +01: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 12:17:33 +01:00
|
|
|
|
2016-12-09 23:40:04 +01:00
|
|
|
if (updateReplayBuffer)
|
|
|
|
obs_output_update(replayBuffer, settings);
|
|
|
|
else
|
|
|
|
obs_output_update(fileOutput, settings);
|
2015-02-06 12:17:33 +01:00
|
|
|
|
2016-12-09 23:40:04 +01:00
|
|
|
return true;
|
|
|
|
}
|
2015-02-06 12:17:33 +01:00
|
|
|
|
2016-12-09 23:40:04 +01: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");
|
2017-02-04 05:29:09 +01:00
|
|
|
QMessageBox::critical(main,
|
2017-08-07 00:24:44 +02:00
|
|
|
QTStr("Output.StartRecordingFailed"),
|
|
|
|
error_reason);
|
2016-12-09 23:40:04 +01:00
|
|
|
return false;
|
2017-02-04 05:29:09 +01:00
|
|
|
}
|
|
|
|
|
2016-12-09 23:40:04 +01:00
|
|
|
return true;
|
|
|
|
}
|
2015-02-06 12:17:33 +01:00
|
|
|
|
2016-12-09 23:40:04 +01: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 23:40:04 +01:00
|
|
|
return false;
|
2017-02-04 05:29:09 +01:00
|
|
|
}
|
|
|
|
|
2016-12-09 23:40:04 +01:00
|
|
|
return true;
|
2015-02-06 12:17:33 +01:00
|
|
|
}
|
|
|
|
|
2016-09-09 16:37:54 +02:00
|
|
|
void SimpleOutput::StopStreaming(bool force)
|
2015-02-06 12:17:33 +01: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 16:37:54 +02:00
|
|
|
else
|
2024-04-18 15:41:36 +02:00
|
|
|
obs_output_stop(output);
|
2015-09-07 01:19:53 +02:00
|
|
|
}
|
|
|
|
|
2016-09-09 16:37:54 +02:00
|
|
|
void SimpleOutput::StopRecording(bool force)
|
2015-02-06 12:17:33 +01:00
|
|
|
{
|
2016-09-09 16:37:54 +02:00
|
|
|
if (force)
|
|
|
|
obs_output_force_stop(fileOutput);
|
|
|
|
else
|
|
|
|
obs_output_stop(fileOutput);
|
2015-02-06 12:17:33 +01:00
|
|
|
}
|
|
|
|
|
2016-12-09 23:40:04 +01:00
|
|
|
void SimpleOutput::StopReplayBuffer(bool force)
|
|
|
|
{
|
|
|
|
if (force)
|
|
|
|
obs_output_force_stop(replayBuffer);
|
|
|
|
else
|
|
|
|
obs_output_stop(replayBuffer);
|
|
|
|
}
|
|
|
|
|
2015-02-06 12:17:33 +01:00
|
|
|
bool SimpleOutput::StreamingActive() const
|
|
|
|
{
|
2024-04-18 15:41:36 +02:00
|
|
|
return obs_output_active(StreamingOutput());
|
2015-02-06 12:17:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SimpleOutput::RecordingActive() const
|
|
|
|
{
|
|
|
|
return obs_output_active(fileOutput);
|
|
|
|
}
|
|
|
|
|
2016-12-09 23:40:04 +01:00
|
|
|
bool SimpleOutput::ReplayBufferActive() const
|
|
|
|
{
|
|
|
|
return obs_output_active(replayBuffer);
|
|
|
|
}
|
|
|
|
|
2015-02-06 12:17:33 +01:00
|
|
|
/* ------------------------------------------------------------------------ */
|
|
|
|
|
2015-01-26 22:41:22 +01:00
|
|
|
struct AdvancedOutput : BasicOutputHandler {
|
2019-08-23 00:08:24 +02:00
|
|
|
OBSEncoder streamAudioEnc;
|
2020-11-01 10:54:27 +01:00
|
|
|
OBSEncoder streamArchiveEnc;
|
2022-07-15 22:03:43 +02:00
|
|
|
OBSEncoder streamTrack[MAX_AUDIO_MIXES];
|
2022-12-17 18:26:59 +01:00
|
|
|
OBSEncoder recordTrack[MAX_AUDIO_MIXES];
|
2022-05-07 05:17:55 +02:00
|
|
|
OBSEncoder videoStreaming;
|
|
|
|
OBSEncoder videoRecording;
|
2015-01-26 22:41:22 +01:00
|
|
|
|
2015-08-19 05:58:24 +02:00
|
|
|
bool ffmpegOutput;
|
2015-01-26 22:41:22 +01:00
|
|
|
bool ffmpegRecording;
|
|
|
|
bool useStreamEncoder;
|
2022-12-17 18:26:59 +01:00
|
|
|
bool useStreamAudioEncoder;
|
2017-09-06 02:01:49 +02:00
|
|
|
bool usesBitrate = false;
|
2015-01-26 22:41:22 +01:00
|
|
|
|
|
|
|
AdvancedOutput(OBSBasic *main_);
|
|
|
|
|
|
|
|
inline void UpdateStreamSettings();
|
|
|
|
inline void UpdateRecordingSettings();
|
2015-03-08 01:32:00 +01:00
|
|
|
inline void UpdateAudioSettings();
|
2015-01-26 22:41:22 +01:00
|
|
|
virtual void Update() override;
|
|
|
|
|
2024-04-18 15:41:36 +02:00
|
|
|
inline std::optional<size_t> VodTrackMixerIdx(obs_service_t *service);
|
2020-12-03 09:59:43 +01:00
|
|
|
inline void SetupVodTrack(obs_service_t *service);
|
|
|
|
|
2015-01-26 22:41:22 +01:00
|
|
|
inline void SetupStreaming();
|
|
|
|
inline void SetupRecording();
|
|
|
|
inline void SetupFFmpeg();
|
2020-09-03 15:56:03 +02:00
|
|
|
void SetupOutputs() override;
|
2022-12-17 18:26:59 +01:00
|
|
|
int GetAudioBitrate(size_t i, const char *id) const;
|
2015-01-26 22:41:22 +01:00
|
|
|
|
2024-07-08 14:07:10 +02:00
|
|
|
virtual std::shared_future<void>
|
|
|
|
SetupStreaming(obs_service_t *service,
|
|
|
|
SetupStreamingContinuation_t continuation) override;
|
2015-01-26 22:41:22 +01:00
|
|
|
virtual bool StartStreaming(obs_service_t *service) override;
|
|
|
|
virtual bool StartRecording() override;
|
2017-09-06 02:01:49 +02:00
|
|
|
virtual bool StartReplayBuffer() override;
|
2016-09-09 16:37:54 +02:00
|
|
|
virtual void StopStreaming(bool force) override;
|
|
|
|
virtual void StopRecording(bool force) override;
|
2017-09-06 02:01:49 +02:00
|
|
|
virtual void StopReplayBuffer(bool force) override;
|
2015-01-26 22:41:22 +01:00
|
|
|
virtual bool StreamingActive() const override;
|
|
|
|
virtual bool RecordingActive() const override;
|
2017-09-06 02:01:49 +02:00
|
|
|
virtual bool ReplayBufferActive() const override;
|
2022-07-15 22:03:43 +02:00
|
|
|
bool allowsMultiTrack();
|
2015-01-26 22:41:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static OBSData GetDataFromJsonFile(const char *jsonFile)
|
|
|
|
{
|
|
|
|
char fullPath[512];
|
2021-11-26 10:25:39 +01:00
|
|
|
OBSDataAutoRelease data = nullptr;
|
2015-01-26 22:41:22 +01:00
|
|
|
|
2015-06-24 04:38:01 +02:00
|
|
|
int ret = GetProfilePath(fullPath, sizeof(fullPath), jsonFile);
|
2015-01-26 22:41:22 +01:00
|
|
|
if (ret > 0) {
|
|
|
|
BPtr<char> jsonData = os_quick_read_utf8_file(fullPath);
|
|
|
|
if (!!jsonData) {
|
2018-07-20 10:50:29 +02:00
|
|
|
data = obs_data_create_from_json(jsonData);
|
2015-01-26 22:41:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-20 10:50:29 +02:00
|
|
|
if (!data)
|
|
|
|
data = obs_data_create();
|
2021-11-26 10:25:39 +01:00
|
|
|
|
|
|
|
return data.Get();
|
2018-07-20 10:50:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ApplyEncoderDefaults(OBSData &settings,
|
|
|
|
const obs_encoder_t *encoder)
|
|
|
|
{
|
|
|
|
OBSData dataRet = obs_encoder_get_defaults(encoder);
|
|
|
|
obs_data_release(dataRet);
|
|
|
|
|
|
|
|
if (!!settings)
|
|
|
|
obs_data_apply(dataRet, settings);
|
|
|
|
settings = std::move(dataRet);
|
2015-01-26 22:41:22 +01:00
|
|
|
}
|
|
|
|
|
2022-12-17 18:26:59 +01:00
|
|
|
#define ADV_ARCHIVE_NAME "adv_archive_audio"
|
2020-12-03 09:59:43 +01:00
|
|
|
|
2021-06-10 01:33:59 +02:00
|
|
|
#ifdef __APPLE__
|
|
|
|
static void translate_macvth264_encoder(const char *&encoder)
|
|
|
|
{
|
|
|
|
if (strcmp(encoder, "vt_h264_hw") == 0) {
|
|
|
|
encoder = "com.apple.videotoolbox.videoencoder.h264.gva";
|
|
|
|
} else if (strcmp(encoder, "vt_h264_sw") == 0) {
|
|
|
|
encoder = "com.apple.videotoolbox.videoencoder.h264";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-01-26 22:41:22 +01:00
|
|
|
AdvancedOutput::AdvancedOutput(OBSBasic *main_) : BasicOutputHandler(main_)
|
|
|
|
{
|
|
|
|
const char *recType =
|
|
|
|
config_get_string(main->Config(), "AdvOut", "RecType");
|
|
|
|
const char *streamEncoder =
|
|
|
|
config_get_string(main->Config(), "AdvOut", "Encoder");
|
2022-12-17 18:26:59 +01:00
|
|
|
const char *streamAudioEncoder =
|
|
|
|
config_get_string(main->Config(), "AdvOut", "AudioEncoder");
|
2015-01-26 22:41:22 +01:00
|
|
|
const char *recordEncoder =
|
|
|
|
config_get_string(main->Config(), "AdvOut", "RecEncoder");
|
2022-12-17 18:26:59 +01:00
|
|
|
const char *recAudioEncoder =
|
|
|
|
config_get_string(main->Config(), "AdvOut", "RecAudioEncoder");
|
2024-04-27 03:55:47 +02:00
|
|
|
const char *recFormat =
|
|
|
|
config_get_string(main->Config(), "AdvOut", "RecFormat2");
|
2021-06-10 01:33:59 +02:00
|
|
|
#ifdef __APPLE__
|
|
|
|
translate_macvth264_encoder(streamEncoder);
|
|
|
|
translate_macvth264_encoder(recordEncoder);
|
|
|
|
#endif
|
2015-01-26 22:41:22 +01:00
|
|
|
|
2015-08-19 05:58:24 +02:00
|
|
|
ffmpegOutput = astrcmpi(recType, "FFmpeg") == 0;
|
|
|
|
ffmpegRecording =
|
|
|
|
ffmpegOutput &&
|
|
|
|
config_get_bool(main->Config(), "AdvOut", "FFOutputToFile");
|
2015-01-26 22:41:22 +01:00
|
|
|
useStreamEncoder = astrcmpi(recordEncoder, "none") == 0;
|
2022-12-17 18:26:59 +01:00
|
|
|
useStreamAudioEncoder = astrcmpi(recAudioEncoder, "none") == 0;
|
2015-01-26 22:41:22 +01:00
|
|
|
|
2015-06-24 04:38:01 +02:00
|
|
|
OBSData streamEncSettings = GetDataFromJsonFile("streamEncoder.json");
|
|
|
|
OBSData recordEncSettings = GetDataFromJsonFile("recordEncoder.json");
|
2015-01-26 22:41:22 +01:00
|
|
|
|
2015-08-19 05:58:24 +02:00
|
|
|
if (ffmpegOutput) {
|
2015-01-26 22:41:22 +01:00
|
|
|
fileOutput = obs_output_create(
|
2014-11-01 21:41:17 +01:00
|
|
|
"ffmpeg_output", "adv_ffmpeg_output", nullptr, nullptr);
|
2015-01-26 22:41:22 +01:00
|
|
|
if (!fileOutput)
|
|
|
|
throw "Failed to create recording FFmpeg output "
|
|
|
|
"(advanced output)";
|
|
|
|
} else {
|
2017-09-06 02:01:49 +02:00
|
|
|
bool useReplayBuffer =
|
|
|
|
config_get_bool(main->Config(), "AdvOut", "RecRB");
|
|
|
|
if (useReplayBuffer) {
|
2022-01-08 03:34:40 +01:00
|
|
|
OBSDataAutoRelease hotkey;
|
2017-09-06 02:01:49 +02:00
|
|
|
const char *str = config_get_string(
|
|
|
|
main->Config(), "Hotkeys", "ReplayBuffer");
|
2022-01-08 03:34:40 +01:00
|
|
|
if (str)
|
|
|
|
hotkey = obs_data_create_from_json(str);
|
|
|
|
else
|
|
|
|
hotkey = nullptr;
|
|
|
|
|
2017-09-06 02:01:49 +02:00
|
|
|
replayBuffer = obs_output_create("replay_buffer",
|
|
|
|
Str("ReplayBuffer"),
|
|
|
|
nullptr, hotkey);
|
|
|
|
|
|
|
|
if (!replayBuffer)
|
|
|
|
throw "Failed to create replay buffer output "
|
|
|
|
"(simple output)";
|
|
|
|
|
|
|
|
signal_handler_t *signal =
|
|
|
|
obs_output_get_signal_handler(replayBuffer);
|
|
|
|
|
|
|
|
startReplayBuffer.Connect(signal, "start",
|
|
|
|
OBSStartReplayBuffer, this);
|
|
|
|
stopReplayBuffer.Connect(signal, "stop",
|
|
|
|
OBSStopReplayBuffer, this);
|
|
|
|
replayBufferStopping.Connect(signal, "stopping",
|
|
|
|
OBSReplayBufferStopping,
|
|
|
|
this);
|
2020-10-18 17:57:52 +02:00
|
|
|
replayBufferSaved.Connect(signal, "saved",
|
|
|
|
OBSReplayBufferSaved, this);
|
2017-09-06 02:01:49 +02:00
|
|
|
}
|
|
|
|
|
2024-04-27 03:55:47 +02:00
|
|
|
bool native_muxer = strcmp(recFormat, "hybrid_mp4") == 0;
|
2015-05-29 08:27:06 +02:00
|
|
|
fileOutput = obs_output_create(
|
2024-04-27 03:55:47 +02:00
|
|
|
native_muxer ? "mp4_output" : "ffmpeg_muxer",
|
|
|
|
"adv_file_output", nullptr, nullptr);
|
2015-01-26 22:41:22 +01:00
|
|
|
if (!fileOutput)
|
|
|
|
throw "Failed to create recording output "
|
|
|
|
"(advanced output)";
|
|
|
|
|
|
|
|
if (!useStreamEncoder) {
|
2022-05-07 05:17:55 +02:00
|
|
|
videoRecording = obs_video_encoder_create(
|
|
|
|
recordEncoder, "advanced_video_recording",
|
2014-11-01 21:41:17 +01:00
|
|
|
recordEncSettings, nullptr);
|
2022-05-07 05:17:55 +02:00
|
|
|
if (!videoRecording)
|
|
|
|
throw "Failed to create recording video "
|
2015-01-26 22:41:22 +01:00
|
|
|
"encoder (advanced output)";
|
2022-05-07 05:17:55 +02:00
|
|
|
obs_encoder_release(videoRecording);
|
2015-01-26 22:41:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-07 05:17:55 +02:00
|
|
|
videoStreaming = obs_video_encoder_create(streamEncoder,
|
|
|
|
"advanced_video_stream",
|
|
|
|
streamEncSettings, nullptr);
|
|
|
|
if (!videoStreaming)
|
|
|
|
throw "Failed to create streaming video encoder "
|
2015-01-26 22:41:22 +01:00
|
|
|
"(advanced output)";
|
2022-05-07 05:17:55 +02:00
|
|
|
obs_encoder_release(videoStreaming);
|
2015-01-26 22:41:22 +01:00
|
|
|
|
2020-12-12 02:41:00 +01:00
|
|
|
const char *rate_control = obs_data_get_string(
|
|
|
|
useStreamEncoder ? streamEncSettings : recordEncSettings,
|
|
|
|
"rate_control");
|
|
|
|
if (!rate_control)
|
|
|
|
rate_control = "";
|
|
|
|
usesBitrate = astrcmpi(rate_control, "CBR") == 0 ||
|
|
|
|
astrcmpi(rate_control, "VBR") == 0 ||
|
|
|
|
astrcmpi(rate_control, "ABR") == 0;
|
|
|
|
|
2016-12-22 02:14:24 +01:00
|
|
|
for (int i = 0; i < MAX_AUDIO_MIXES; i++) {
|
2022-12-17 18:26:59 +01:00
|
|
|
char name[19];
|
|
|
|
snprintf(name, sizeof(name), "adv_record_audio_%d", i);
|
2015-01-26 22:41:22 +01:00
|
|
|
|
2022-12-17 18:26:59 +01:00
|
|
|
recordTrack[i] = obs_audio_encoder_create(
|
|
|
|
useStreamAudioEncoder ? streamAudioEncoder
|
|
|
|
: recAudioEncoder,
|
|
|
|
name, nullptr, i, nullptr);
|
|
|
|
|
|
|
|
if (!recordTrack[i]) {
|
2015-01-26 22:41:22 +01:00
|
|
|
throw "Failed to create audio encoder "
|
|
|
|
"(advanced output)";
|
2022-12-17 18:26:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
obs_encoder_release(recordTrack[i]);
|
2022-07-15 22:03:43 +02:00
|
|
|
|
|
|
|
snprintf(name, sizeof(name), "adv_stream_audio_%d", i);
|
|
|
|
streamTrack[i] = obs_audio_encoder_create(
|
|
|
|
streamAudioEncoder, name, nullptr, i, nullptr);
|
|
|
|
|
|
|
|
if (!streamTrack[i]) {
|
|
|
|
throw "Failed to create streaming audio encoders "
|
|
|
|
"(advanced output)";
|
|
|
|
}
|
|
|
|
|
|
|
|
obs_encoder_release(streamTrack[i]);
|
2015-01-26 22:41:22 +01:00
|
|
|
}
|
|
|
|
|
2019-07-04 18:47:56 +02:00
|
|
|
std::string id;
|
2022-07-15 22:03:43 +02:00
|
|
|
int streamTrackIndex =
|
2019-07-04 18:47:56 +02:00
|
|
|
config_get_int(main->Config(), "AdvOut", "TrackIndex") - 1;
|
2022-12-17 18:26:59 +01:00
|
|
|
streamAudioEnc = obs_audio_encoder_create(streamAudioEncoder,
|
|
|
|
"adv_stream_audio", nullptr,
|
2022-07-15 22:03:43 +02:00
|
|
|
streamTrackIndex, nullptr);
|
2022-12-17 18:26:59 +01:00
|
|
|
if (!streamAudioEnc)
|
2019-07-04 18:47:56 +02:00
|
|
|
throw "Failed to create streaming audio encoder "
|
|
|
|
"(advanced output)";
|
2022-12-17 18:26:59 +01:00
|
|
|
obs_encoder_release(streamAudioEnc);
|
2019-07-04 18:47:56 +02:00
|
|
|
|
2020-11-01 10:54:27 +01:00
|
|
|
id = "";
|
|
|
|
int vodTrack =
|
|
|
|
config_get_int(main->Config(), "AdvOut", "VodTrackIndex") - 1;
|
2022-12-17 18:26:59 +01:00
|
|
|
streamArchiveEnc = obs_audio_encoder_create(streamAudioEncoder,
|
|
|
|
ADV_ARCHIVE_NAME, nullptr,
|
2023-03-22 18:29:52 +01:00
|
|
|
vodTrack, nullptr);
|
2022-12-17 18:26:59 +01:00
|
|
|
if (!streamArchiveEnc)
|
2020-11-01 10:54:27 +01:00
|
|
|
throw "Failed to create archive audio encoder "
|
|
|
|
"(advanced output)";
|
2022-12-17 18:26:59 +01:00
|
|
|
obs_encoder_release(streamArchiveEnc);
|
2020-11-01 10:54:27 +01:00
|
|
|
|
2015-07-04 08:00:21 +02:00
|
|
|
startRecording.Connect(obs_output_get_signal_handler(fileOutput),
|
2015-01-26 22:41:22 +01:00
|
|
|
"start", OBSStartRecording, this);
|
2015-07-04 08:00:21 +02:00
|
|
|
stopRecording.Connect(obs_output_get_signal_handler(fileOutput), "stop",
|
2015-01-26 22:41:22 +01:00
|
|
|
OBSStopRecording, this);
|
2016-06-22 10:47:08 +02:00
|
|
|
recordStopping.Connect(obs_output_get_signal_handler(fileOutput),
|
|
|
|
"stopping", OBSRecordStopping, this);
|
2021-10-03 12:06:46 +02:00
|
|
|
recordFileChanged.Connect(obs_output_get_signal_handler(fileOutput),
|
|
|
|
"file_changed", OBSRecordFileChanged, this);
|
2015-01-26 22:41:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void AdvancedOutput::UpdateStreamSettings()
|
|
|
|
{
|
2015-03-08 01:32:00 +01:00
|
|
|
bool applyServiceSettings = config_get_bool(main->Config(), "AdvOut",
|
|
|
|
"ApplyServiceSettings");
|
2020-11-11 18:48:39 +01:00
|
|
|
bool enforceBitrate = !config_get_bool(main->Config(), "Stream1",
|
|
|
|
"IgnoreRecommended");
|
2019-09-10 21:01:10 +02:00
|
|
|
bool dynBitrate =
|
|
|
|
config_get_bool(main->Config(), "Output", "DynamicBitrate");
|
|
|
|
const char *streamEncoder =
|
|
|
|
config_get_string(main->Config(), "AdvOut", "Encoder");
|
2015-03-08 01:32:00 +01:00
|
|
|
|
2015-06-24 04:38:01 +02:00
|
|
|
OBSData settings = GetDataFromJsonFile("streamEncoder.json");
|
2022-05-07 05:17:55 +02:00
|
|
|
ApplyEncoderDefaults(settings, videoStreaming);
|
2015-03-08 01:32:00 +01:00
|
|
|
|
2020-11-11 18:48:39 +01:00
|
|
|
if (applyServiceSettings) {
|
|
|
|
int bitrate = (int)obs_data_get_int(settings, "bitrate");
|
2021-08-25 04:41:43 +02:00
|
|
|
int keyint_sec = (int)obs_data_get_int(settings, "keyint_sec");
|
2015-03-08 01:32:00 +01:00
|
|
|
obs_service_apply_encoder_settings(main->GetService(), settings,
|
|
|
|
nullptr);
|
2023-08-15 22:43:59 +02:00
|
|
|
if (!enforceBitrate) {
|
|
|
|
blog(LOG_INFO,
|
|
|
|
"User is ignoring service bitrate limits.");
|
2020-11-11 18:48:39 +01:00
|
|
|
obs_data_set_int(settings, "bitrate", bitrate);
|
2023-08-15 22:43:59 +02:00
|
|
|
}
|
2021-08-25 04:41:43 +02:00
|
|
|
|
|
|
|
int enforced_keyint_sec =
|
|
|
|
(int)obs_data_get_int(settings, "keyint_sec");
|
|
|
|
if (keyint_sec != 0 && keyint_sec < enforced_keyint_sec)
|
|
|
|
obs_data_set_int(settings, "keyint_sec", keyint_sec);
|
2023-08-15 22:43:59 +02:00
|
|
|
} else {
|
|
|
|
blog(LOG_WARNING, "User is ignoring service settings.");
|
2020-11-11 18:48:39 +01:00
|
|
|
}
|
2015-03-08 01:32:00 +01:00
|
|
|
|
2019-09-10 21:01:10 +02:00
|
|
|
if (dynBitrate && astrcmpi(streamEncoder, "jim_nvenc") == 0)
|
|
|
|
obs_data_set_bool(settings, "lookahead", false);
|
|
|
|
|
2015-04-17 11:48:06 +02:00
|
|
|
video_t *video = obs_get_video();
|
|
|
|
enum video_format format = video_output_get_format(video);
|
|
|
|
|
2022-04-29 18:45:56 +02:00
|
|
|
switch (format) {
|
|
|
|
case VIDEO_FORMAT_I420:
|
|
|
|
case VIDEO_FORMAT_NV12:
|
|
|
|
case VIDEO_FORMAT_I010:
|
|
|
|
case VIDEO_FORMAT_P010:
|
|
|
|
break;
|
|
|
|
default:
|
2022-05-07 05:17:55 +02:00
|
|
|
obs_encoder_set_preferred_video_format(videoStreaming,
|
2015-04-17 11:48:06 +02:00
|
|
|
VIDEO_FORMAT_NV12);
|
2022-04-29 18:45:56 +02:00
|
|
|
}
|
2015-04-17 11:48:06 +02:00
|
|
|
|
2022-05-07 05:17:55 +02:00
|
|
|
obs_encoder_update(videoStreaming, settings);
|
2015-01-26 22:41:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void AdvancedOutput::UpdateRecordingSettings()
|
|
|
|
{
|
2015-06-24 04:38:01 +02:00
|
|
|
OBSData settings = GetDataFromJsonFile("recordEncoder.json");
|
2022-05-07 05:17:55 +02:00
|
|
|
obs_encoder_update(videoRecording, settings);
|
2015-01-26 22:41:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void AdvancedOutput::Update()
|
|
|
|
{
|
|
|
|
UpdateStreamSettings();
|
2015-08-19 05:58:24 +02:00
|
|
|
if (!useStreamEncoder && !ffmpegOutput)
|
2015-01-26 22:41:22 +01:00
|
|
|
UpdateRecordingSettings();
|
2015-03-08 01:32:00 +01:00
|
|
|
UpdateAudioSettings();
|
2015-01-26 22:41:22 +01:00
|
|
|
}
|
|
|
|
|
2020-11-01 10:54:27 +01:00
|
|
|
static inline bool ServiceSupportsVodTrack(const char *service)
|
|
|
|
{
|
|
|
|
static const char *vodTrackServices[] = {"Twitch"};
|
|
|
|
|
|
|
|
for (const char *vodTrackService : vodTrackServices) {
|
|
|
|
if (astrcmpi(vodTrackService, service) == 0)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-07-15 22:03:43 +02:00
|
|
|
inline bool AdvancedOutput::allowsMultiTrack()
|
|
|
|
{
|
|
|
|
const char *protocol = nullptr;
|
|
|
|
obs_service_t *service_obj = main->GetService();
|
|
|
|
protocol = obs_service_get_protocol(service_obj);
|
|
|
|
if (!protocol)
|
|
|
|
return false;
|
|
|
|
return astrcmpi_n(protocol, SRT_PROTOCOL, strlen(SRT_PROTOCOL)) == 0 ||
|
|
|
|
astrcmpi_n(protocol, RIST_PROTOCOL, strlen(RIST_PROTOCOL)) == 0;
|
|
|
|
}
|
|
|
|
|
2015-01-26 22:41:22 +01:00
|
|
|
inline void AdvancedOutput::SetupStreaming()
|
|
|
|
{
|
|
|
|
const char *rescaleRes =
|
|
|
|
config_get_string(main->Config(), "AdvOut", "RescaleRes");
|
2024-01-10 10:05:56 +01:00
|
|
|
int rescaleFilter =
|
|
|
|
config_get_int(main->Config(), "AdvOut", "RescaleFilter");
|
2022-07-15 22:03:43 +02:00
|
|
|
int multiTrackAudioMixes = config_get_int(main->Config(), "AdvOut",
|
|
|
|
"StreamMultiTrackAudioMixes");
|
2015-01-26 22:41:22 +01:00
|
|
|
unsigned int cx = 0;
|
|
|
|
unsigned int cy = 0;
|
2022-07-15 22:03:43 +02:00
|
|
|
int idx = 0;
|
|
|
|
bool is_multitrack_output = allowsMultiTrack();
|
2015-01-26 22:41:22 +01:00
|
|
|
|
2024-01-10 10:05:56 +01:00
|
|
|
if (rescaleFilter != OBS_SCALE_DISABLE && rescaleRes && *rescaleRes) {
|
2015-03-31 22:48:06 +02:00
|
|
|
if (sscanf(rescaleRes, "%ux%u", &cx, &cy) != 2) {
|
|
|
|
cx = 0;
|
|
|
|
cy = 0;
|
|
|
|
}
|
2015-01-26 22:41:22 +01:00
|
|
|
}
|
|
|
|
|
2022-07-15 22:03:43 +02:00
|
|
|
if (!is_multitrack_output) {
|
|
|
|
obs_output_set_audio_encoder(streamOutput, streamAudioEnc, 0);
|
|
|
|
} else {
|
|
|
|
for (int i = 0; i < MAX_AUDIO_MIXES; i++) {
|
|
|
|
if ((multiTrackAudioMixes & (1 << i)) != 0) {
|
|
|
|
obs_output_set_audio_encoder(
|
|
|
|
streamOutput, streamTrack[i], idx);
|
|
|
|
idx++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-07 05:17:55 +02:00
|
|
|
obs_encoder_set_scaled_size(videoStreaming, cx, cy);
|
2024-01-10 10:05:56 +01:00
|
|
|
obs_encoder_set_gpu_scale_type(videoStreaming,
|
|
|
|
(obs_scale_type)rescaleFilter);
|
2020-04-16 23:57:37 +02:00
|
|
|
|
|
|
|
const char *id = obs_service_get_id(main->GetService());
|
|
|
|
if (strcmp(id, "rtmp_custom") == 0) {
|
2021-11-26 10:25:39 +01:00
|
|
|
OBSDataAutoRelease settings = obs_data_create();
|
2020-04-16 23:57:37 +02:00
|
|
|
obs_service_apply_encoder_settings(main->GetService(), settings,
|
|
|
|
nullptr);
|
2022-05-07 05:17:55 +02:00
|
|
|
obs_encoder_update(videoStreaming, settings);
|
2020-04-16 23:57:37 +02:00
|
|
|
}
|
2015-01-26 22:41:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void AdvancedOutput::SetupRecording()
|
|
|
|
{
|
|
|
|
const char *path =
|
|
|
|
config_get_string(main->Config(), "AdvOut", "RecFilePath");
|
2015-11-23 15:36:06 +01:00
|
|
|
const char *mux =
|
|
|
|
config_get_string(main->Config(), "AdvOut", "RecMuxerCustom");
|
2015-01-26 22:41:22 +01:00
|
|
|
const char *rescaleRes =
|
|
|
|
config_get_string(main->Config(), "AdvOut", "RecRescaleRes");
|
2024-01-10 10:05:56 +01:00
|
|
|
int rescaleFilter =
|
|
|
|
config_get_int(main->Config(), "AdvOut", "RecRescaleFilter");
|
2019-07-23 14:20:13 +02:00
|
|
|
int tracks;
|
|
|
|
|
|
|
|
const char *recFormat =
|
2023-03-24 12:44:37 +01:00
|
|
|
config_get_string(main->Config(), "AdvOut", "RecFormat2");
|
2019-07-23 14:20:13 +02:00
|
|
|
|
2023-04-03 15:48:55 +02:00
|
|
|
bool is_fragmented = strncmp(recFormat, "fragmented", 10) == 0;
|
2019-07-23 14:20:13 +02:00
|
|
|
bool flv = strcmp(recFormat, "flv") == 0;
|
|
|
|
|
|
|
|
if (flv)
|
|
|
|
tracks = config_get_int(main->Config(), "AdvOut", "FLVTrack");
|
|
|
|
else
|
|
|
|
tracks = config_get_int(main->Config(), "AdvOut", "RecTracks");
|
|
|
|
|
2021-11-26 10:25:39 +01:00
|
|
|
OBSDataAutoRelease settings = obs_data_create();
|
2015-01-26 22:41:22 +01:00
|
|
|
unsigned int cx = 0;
|
|
|
|
unsigned int cy = 0;
|
2015-05-31 06:45:14 +02:00
|
|
|
int idx = 0;
|
2015-01-26 22:41:22 +01:00
|
|
|
|
2023-05-12 18:16:27 +02:00
|
|
|
/* Hack to allow recordings without any audio tracks selected. It is no
|
|
|
|
* longer possible to select such a configuration in settings, but legacy
|
|
|
|
* configurations might still have this configured and we don't want to
|
|
|
|
* just break them. */
|
2019-06-18 00:52:30 +02:00
|
|
|
if (tracks == 0)
|
|
|
|
tracks = config_get_int(main->Config(), "AdvOut", "TrackIndex");
|
|
|
|
|
2015-01-26 22:41:22 +01:00
|
|
|
if (useStreamEncoder) {
|
2022-05-07 05:17:55 +02:00
|
|
|
obs_output_set_video_encoder(fileOutput, videoStreaming);
|
2017-09-06 02:01:49 +02:00
|
|
|
if (replayBuffer)
|
|
|
|
obs_output_set_video_encoder(replayBuffer,
|
2022-05-07 05:17:55 +02:00
|
|
|
videoStreaming);
|
2015-01-26 22:41:22 +01:00
|
|
|
} else {
|
2024-01-10 10:05:56 +01:00
|
|
|
if (rescaleFilter != OBS_SCALE_DISABLE && rescaleRes &&
|
|
|
|
*rescaleRes) {
|
2015-03-31 22:48:06 +02:00
|
|
|
if (sscanf(rescaleRes, "%ux%u", &cx, &cy) != 2) {
|
|
|
|
cx = 0;
|
|
|
|
cy = 0;
|
|
|
|
}
|
2015-01-26 22:41:22 +01:00
|
|
|
}
|
|
|
|
|
2022-05-07 05:17:55 +02:00
|
|
|
obs_encoder_set_scaled_size(videoRecording, cx, cy);
|
2024-01-10 10:05:56 +01:00
|
|
|
obs_encoder_set_gpu_scale_type(videoRecording,
|
|
|
|
(obs_scale_type)rescaleFilter);
|
2022-05-07 05:17:55 +02:00
|
|
|
obs_output_set_video_encoder(fileOutput, videoRecording);
|
2017-09-06 02:01:49 +02:00
|
|
|
if (replayBuffer)
|
|
|
|
obs_output_set_video_encoder(replayBuffer,
|
2022-05-07 05:17:55 +02:00
|
|
|
videoRecording);
|
2015-01-26 22:41:22 +01:00
|
|
|
}
|
|
|
|
|
2019-07-23 14:20:13 +02:00
|
|
|
if (!flv) {
|
|
|
|
for (int i = 0; i < MAX_AUDIO_MIXES; i++) {
|
|
|
|
if ((tracks & (1 << i)) != 0) {
|
2022-12-17 18:26:59 +01:00
|
|
|
obs_output_set_audio_encoder(
|
|
|
|
fileOutput, recordTrack[i], idx);
|
2019-07-23 14:20:13 +02:00
|
|
|
if (replayBuffer)
|
|
|
|
obs_output_set_audio_encoder(
|
2022-12-17 18:26:59 +01:00
|
|
|
replayBuffer, recordTrack[i],
|
|
|
|
idx);
|
2019-07-23 14:20:13 +02:00
|
|
|
idx++;
|
|
|
|
}
|
2015-05-31 06:45:14 +02:00
|
|
|
}
|
2019-07-23 14:20:13 +02:00
|
|
|
} else if (flv && tracks != 0) {
|
2022-12-17 18:26:59 +01:00
|
|
|
obs_output_set_audio_encoder(fileOutput,
|
|
|
|
recordTrack[tracks - 1], idx);
|
2019-07-23 14:20:13 +02:00
|
|
|
|
|
|
|
if (replayBuffer)
|
2022-12-17 18:26:59 +01:00
|
|
|
obs_output_set_audio_encoder(
|
|
|
|
replayBuffer, recordTrack[tracks - 1], idx);
|
2015-01-26 22:41:22 +01:00
|
|
|
}
|
|
|
|
|
2023-01-29 12:48:01 +01:00
|
|
|
// Use fragmented MOV/MP4 if user has not already specified custom movflags
|
|
|
|
if (is_fragmented && (!mux || strstr(mux, "movflags") == NULL)) {
|
2023-04-03 15:48:55 +02:00
|
|
|
string mux_frag =
|
2023-01-29 12:48:01 +01:00
|
|
|
"movflags=frag_keyframe+empty_moov+delay_moov";
|
|
|
|
if (mux) {
|
2023-04-03 15:48:55 +02:00
|
|
|
mux_frag += " ";
|
|
|
|
mux_frag += mux;
|
2023-01-29 12:48:01 +01:00
|
|
|
}
|
|
|
|
obs_data_set_string(settings, "muxer_settings",
|
2023-04-03 15:48:55 +02:00
|
|
|
mux_frag.c_str());
|
2023-01-29 12:48:01 +01:00
|
|
|
} else {
|
|
|
|
if (is_fragmented)
|
|
|
|
blog(LOG_WARNING,
|
|
|
|
"User enabled fragmented recording, "
|
|
|
|
"but custom muxer settings contained movflags.");
|
|
|
|
obs_data_set_string(settings, "muxer_settings", mux);
|
|
|
|
}
|
|
|
|
|
2015-01-26 22:41:22 +01:00
|
|
|
obs_data_set_string(settings, "path", path);
|
|
|
|
obs_output_update(fileOutput, settings);
|
2017-09-06 02:01:49 +02:00
|
|
|
if (replayBuffer)
|
|
|
|
obs_output_update(replayBuffer, settings);
|
2015-01-26 22:41:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void AdvancedOutput::SetupFFmpeg()
|
|
|
|
{
|
|
|
|
const char *url = config_get_string(main->Config(), "AdvOut", "FFURL");
|
|
|
|
int vBitrate = config_get_int(main->Config(), "AdvOut", "FFVBitrate");
|
2017-02-17 17:25:21 +01:00
|
|
|
int gopSize = config_get_int(main->Config(), "AdvOut", "FFVGOPSize");
|
2015-01-26 22:41:22 +01:00
|
|
|
bool rescale = config_get_bool(main->Config(), "AdvOut", "FFRescale");
|
|
|
|
const char *rescaleRes =
|
|
|
|
config_get_string(main->Config(), "AdvOut", "FFRescaleRes");
|
2015-03-28 08:21:16 +01:00
|
|
|
const char *formatName =
|
|
|
|
config_get_string(main->Config(), "AdvOut", "FFFormat");
|
|
|
|
const char *mimeType =
|
|
|
|
config_get_string(main->Config(), "AdvOut", "FFFormatMimeType");
|
2015-09-16 10:26:48 +02:00
|
|
|
const char *muxCustom =
|
|
|
|
config_get_string(main->Config(), "AdvOut", "FFMCustom");
|
2015-01-26 22:41:22 +01:00
|
|
|
const char *vEncoder =
|
|
|
|
config_get_string(main->Config(), "AdvOut", "FFVEncoder");
|
2015-03-28 08:21:16 +01:00
|
|
|
int vEncoderId =
|
|
|
|
config_get_int(main->Config(), "AdvOut", "FFVEncoderId");
|
2015-01-26 22:41:22 +01:00
|
|
|
const char *vEncCustom =
|
|
|
|
config_get_string(main->Config(), "AdvOut", "FFVCustom");
|
|
|
|
int aBitrate = config_get_int(main->Config(), "AdvOut", "FFABitrate");
|
2018-10-05 05:06:54 +02:00
|
|
|
int aMixes = config_get_int(main->Config(), "AdvOut", "FFAudioMixes");
|
2015-01-26 22:41:22 +01:00
|
|
|
const char *aEncoder =
|
|
|
|
config_get_string(main->Config(), "AdvOut", "FFAEncoder");
|
2015-03-28 08:21:16 +01:00
|
|
|
int aEncoderId =
|
|
|
|
config_get_int(main->Config(), "AdvOut", "FFAEncoderId");
|
2015-01-26 22:41:22 +01:00
|
|
|
const char *aEncCustom =
|
|
|
|
config_get_string(main->Config(), "AdvOut", "FFACustom");
|
2023-02-25 20:26:53 +01:00
|
|
|
|
|
|
|
OBSDataArrayAutoRelease audio_names = obs_data_array_create();
|
|
|
|
|
|
|
|
for (size_t i = 0; i < MAX_AUDIO_MIXES; i++) {
|
|
|
|
string cfg_name = "Track";
|
|
|
|
cfg_name += to_string((int)i + 1);
|
|
|
|
cfg_name += "Name";
|
|
|
|
|
|
|
|
const char *audioName = config_get_string(
|
|
|
|
main->Config(), "AdvOut", cfg_name.c_str());
|
|
|
|
|
|
|
|
OBSDataAutoRelease item = obs_data_create();
|
|
|
|
obs_data_set_string(item, "name", audioName);
|
|
|
|
obs_data_array_push_back(audio_names, item);
|
|
|
|
}
|
|
|
|
|
2021-11-26 10:25:39 +01:00
|
|
|
OBSDataAutoRelease settings = obs_data_create();
|
2015-01-26 22:41:22 +01:00
|
|
|
|
2023-02-25 20:26:53 +01:00
|
|
|
obs_data_set_array(settings, "audio_names", audio_names);
|
2015-01-26 22:41:22 +01:00
|
|
|
obs_data_set_string(settings, "url", url);
|
2015-03-28 08:21:16 +01:00
|
|
|
obs_data_set_string(settings, "format_name", formatName);
|
|
|
|
obs_data_set_string(settings, "format_mime_type", mimeType);
|
2015-09-16 10:26:48 +02:00
|
|
|
obs_data_set_string(settings, "muxer_settings", muxCustom);
|
2017-02-17 17:25:21 +01:00
|
|
|
obs_data_set_int(settings, "gop_size", gopSize);
|
2015-01-26 22:41:22 +01:00
|
|
|
obs_data_set_int(settings, "video_bitrate", vBitrate);
|
|
|
|
obs_data_set_string(settings, "video_encoder", vEncoder);
|
2015-03-28 08:21:16 +01:00
|
|
|
obs_data_set_int(settings, "video_encoder_id", vEncoderId);
|
2015-01-26 22:41:22 +01:00
|
|
|
obs_data_set_string(settings, "video_settings", vEncCustom);
|
|
|
|
obs_data_set_int(settings, "audio_bitrate", aBitrate);
|
|
|
|
obs_data_set_string(settings, "audio_encoder", aEncoder);
|
2015-03-28 08:21:16 +01:00
|
|
|
obs_data_set_int(settings, "audio_encoder_id", aEncoderId);
|
2015-01-26 22:41:22 +01:00
|
|
|
obs_data_set_string(settings, "audio_settings", aEncCustom);
|
|
|
|
|
|
|
|
if (rescale && rescaleRes && *rescaleRes) {
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int val = sscanf(rescaleRes, "%dx%d", &width, &height);
|
|
|
|
|
|
|
|
if (val == 2 && width && height) {
|
|
|
|
obs_data_set_int(settings, "scale_width", width);
|
|
|
|
obs_data_set_int(settings, "scale_height", height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-05 05:06:54 +02:00
|
|
|
obs_output_set_mixers(fileOutput, aMixes);
|
2015-01-26 22:41:22 +01:00
|
|
|
obs_output_set_media(fileOutput, obs_get_video(), obs_get_audio());
|
|
|
|
obs_output_update(fileOutput, settings);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void SetEncoderName(obs_encoder_t *encoder, const char *name,
|
|
|
|
const char *defaultName)
|
|
|
|
{
|
|
|
|
obs_encoder_set_name(encoder, (name && *name) ? name : defaultName);
|
|
|
|
}
|
|
|
|
|
2015-03-08 01:32:00 +01:00
|
|
|
inline void AdvancedOutput::UpdateAudioSettings()
|
2015-01-26 22:41:22 +01:00
|
|
|
{
|
2015-03-08 01:32:00 +01:00
|
|
|
bool applyServiceSettings = config_get_bool(main->Config(), "AdvOut",
|
|
|
|
"ApplyServiceSettings");
|
2020-11-11 18:48:39 +01:00
|
|
|
bool enforceBitrate = !config_get_bool(main->Config(), "Stream1",
|
|
|
|
"IgnoreRecommended");
|
2015-03-27 20:38:38 +01:00
|
|
|
int streamTrackIndex =
|
|
|
|
config_get_int(main->Config(), "AdvOut", "TrackIndex");
|
2020-11-01 10:54:27 +01:00
|
|
|
int vodTrackIndex =
|
|
|
|
config_get_int(main->Config(), "AdvOut", "VodTrackIndex");
|
2022-12-17 18:26:59 +01:00
|
|
|
const char *audioEncoder =
|
|
|
|
config_get_string(main->Config(), "AdvOut", "AudioEncoder");
|
|
|
|
const char *recAudioEncoder =
|
|
|
|
config_get_string(main->Config(), "AdvOut", "RecAudioEncoder");
|
2022-07-15 22:03:43 +02:00
|
|
|
|
|
|
|
bool is_multitrack_output = allowsMultiTrack();
|
|
|
|
|
2021-11-26 10:25:39 +01:00
|
|
|
OBSDataAutoRelease settings[MAX_AUDIO_MIXES];
|
2015-01-26 22:41:22 +01:00
|
|
|
|
2016-12-22 02:14:24 +01:00
|
|
|
for (size_t i = 0; i < MAX_AUDIO_MIXES; i++) {
|
|
|
|
string cfg_name = "Track";
|
|
|
|
cfg_name += to_string((int)i + 1);
|
|
|
|
cfg_name += "Name";
|
|
|
|
const char *name = config_get_string(main->Config(), "AdvOut",
|
|
|
|
cfg_name.c_str());
|
|
|
|
|
|
|
|
string def_name = "Track";
|
|
|
|
def_name += to_string((int)i + 1);
|
2022-12-17 18:26:59 +01:00
|
|
|
SetEncoderName(recordTrack[i], name, def_name.c_str());
|
2022-07-15 22:03:43 +02:00
|
|
|
SetEncoderName(streamTrack[i], name, def_name.c_str());
|
2016-12-22 02:14:24 +01:00
|
|
|
}
|
2015-01-26 22:41:22 +01:00
|
|
|
|
2016-12-22 02:14:24 +01:00
|
|
|
for (size_t i = 0; i < MAX_AUDIO_MIXES; i++) {
|
2020-11-01 10:54:27 +01:00
|
|
|
int track = (int)(i + 1);
|
2022-12-17 18:26:59 +01:00
|
|
|
settings[i] = obs_data_create();
|
|
|
|
obs_data_set_int(settings[i], "bitrate",
|
|
|
|
GetAudioBitrate(i, recAudioEncoder));
|
2020-11-01 10:54:27 +01:00
|
|
|
|
2022-12-17 18:26:59 +01:00
|
|
|
obs_encoder_update(recordTrack[i], settings[i]);
|
|
|
|
|
|
|
|
obs_data_set_int(settings[i], "bitrate",
|
|
|
|
GetAudioBitrate(i, audioEncoder));
|
2019-07-04 18:47:56 +02:00
|
|
|
|
2022-07-15 22:03:43 +02:00
|
|
|
if (!is_multitrack_output) {
|
|
|
|
if (track == streamTrackIndex ||
|
|
|
|
track == vodTrackIndex) {
|
|
|
|
if (applyServiceSettings) {
|
|
|
|
int bitrate = (int)obs_data_get_int(
|
|
|
|
settings[i], "bitrate");
|
|
|
|
obs_service_apply_encoder_settings(
|
|
|
|
main->GetService(), nullptr,
|
|
|
|
settings[i]);
|
|
|
|
|
|
|
|
if (!enforceBitrate)
|
|
|
|
obs_data_set_int(settings[i],
|
|
|
|
"bitrate",
|
|
|
|
bitrate);
|
|
|
|
}
|
2019-07-04 18:47:56 +02:00
|
|
|
}
|
|
|
|
|
2022-07-15 22:03:43 +02:00
|
|
|
if (track == streamTrackIndex)
|
|
|
|
obs_encoder_update(streamAudioEnc, settings[i]);
|
|
|
|
if (track == vodTrackIndex)
|
|
|
|
obs_encoder_update(streamArchiveEnc,
|
|
|
|
settings[i]);
|
|
|
|
} else {
|
|
|
|
obs_encoder_update(streamTrack[i], settings[i]);
|
|
|
|
}
|
2015-01-26 22:41:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdvancedOutput::SetupOutputs()
|
|
|
|
{
|
2022-05-07 05:17:55 +02:00
|
|
|
obs_encoder_set_video(videoStreaming, obs_get_video());
|
|
|
|
if (videoRecording)
|
|
|
|
obs_encoder_set_video(videoRecording, obs_get_video());
|
2022-07-15 22:03:43 +02:00
|
|
|
for (size_t i = 0; i < MAX_AUDIO_MIXES; i++) {
|
|
|
|
obs_encoder_set_audio(streamTrack[i], obs_get_audio());
|
2022-12-17 18:26:59 +01:00
|
|
|
obs_encoder_set_audio(recordTrack[i], obs_get_audio());
|
2022-07-15 22:03:43 +02:00
|
|
|
}
|
2019-08-23 00:08:24 +02:00
|
|
|
obs_encoder_set_audio(streamAudioEnc, obs_get_audio());
|
2020-11-01 10:54:27 +01:00
|
|
|
obs_encoder_set_audio(streamArchiveEnc, obs_get_audio());
|
2015-01-26 22:41:22 +01:00
|
|
|
|
|
|
|
SetupStreaming();
|
|
|
|
|
2015-08-19 05:58:24 +02:00
|
|
|
if (ffmpegOutput)
|
2015-01-26 22:41:22 +01:00
|
|
|
SetupFFmpeg();
|
|
|
|
else
|
|
|
|
SetupRecording();
|
|
|
|
}
|
|
|
|
|
2022-12-17 18:26:59 +01:00
|
|
|
int AdvancedOutput::GetAudioBitrate(size_t i, const char *id) const
|
2015-07-02 09:58:28 +02:00
|
|
|
{
|
2016-12-22 02:14:24 +01:00
|
|
|
static const char *names[] = {
|
2015-07-02 09:58:28 +02:00
|
|
|
"Track1Bitrate", "Track2Bitrate", "Track3Bitrate",
|
2016-12-22 02:14:24 +01:00
|
|
|
"Track4Bitrate", "Track5Bitrate", "Track6Bitrate",
|
2015-07-02 09:58:28 +02:00
|
|
|
};
|
2015-09-22 03:36:26 +02:00
|
|
|
int bitrate = (int)config_get_uint(main->Config(), "AdvOut", names[i]);
|
2022-12-17 18:26:59 +01:00
|
|
|
return FindClosestAvailableAudioBitrate(id, bitrate);
|
2015-07-02 09:58:28 +02:00
|
|
|
}
|
|
|
|
|
2024-04-18 15:41:36 +02:00
|
|
|
inline std::optional<size_t>
|
|
|
|
AdvancedOutput::VodTrackMixerIdx(obs_service_t *service)
|
2015-01-26 22:41:22 +01:00
|
|
|
{
|
2022-07-15 22:03:43 +02:00
|
|
|
int streamTrackIndex =
|
2020-11-01 10:54:27 +01:00
|
|
|
config_get_int(main->Config(), "AdvOut", "TrackIndex");
|
|
|
|
bool vodTrackEnabled =
|
|
|
|
config_get_bool(main->Config(), "AdvOut", "VodTrackEnabled");
|
|
|
|
int vodTrackIndex =
|
|
|
|
config_get_int(main->Config(), "AdvOut", "VodTrackIndex");
|
2020-12-03 10:31:32 +01:00
|
|
|
bool enableForCustomServer = config_get_bool(
|
|
|
|
GetGlobalConfig(), "General", "EnableCustomServerVodTrack");
|
2019-08-23 00:08:24 +02:00
|
|
|
|
2020-12-03 09:59:43 +01:00
|
|
|
const char *id = obs_service_get_id(service);
|
|
|
|
if (strcmp(id, "rtmp_custom") == 0) {
|
2020-12-03 10:31:32 +01:00
|
|
|
vodTrackEnabled = enableForCustomServer ? vodTrackEnabled
|
|
|
|
: false;
|
2020-12-03 09:59:43 +01:00
|
|
|
} else {
|
2021-11-26 10:25:39 +01:00
|
|
|
OBSDataAutoRelease settings = obs_service_get_settings(service);
|
2020-12-03 09:59:43 +01:00
|
|
|
const char *service = obs_data_get_string(settings, "service");
|
|
|
|
if (!ServiceSupportsVodTrack(service))
|
|
|
|
vodTrackEnabled = false;
|
|
|
|
}
|
2024-04-18 15:41:36 +02:00
|
|
|
|
2022-07-15 22:03:43 +02:00
|
|
|
if (vodTrackEnabled && streamTrackIndex != vodTrackIndex)
|
2024-04-18 15:41:36 +02:00
|
|
|
return {vodTrackIndex - 1};
|
|
|
|
return std::nullopt;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void AdvancedOutput::SetupVodTrack(obs_service_t *service)
|
|
|
|
{
|
|
|
|
if (VodTrackMixerIdx(service).has_value())
|
2020-12-03 09:59:43 +01:00
|
|
|
obs_output_set_audio_encoder(streamOutput, streamArchiveEnc, 1);
|
|
|
|
else
|
|
|
|
clear_archive_encoder(streamOutput, ADV_ARCHIVE_NAME);
|
|
|
|
}
|
|
|
|
|
2024-07-08 14:07:10 +02:00
|
|
|
std::shared_future<void>
|
|
|
|
AdvancedOutput::SetupStreaming(obs_service_t *service,
|
|
|
|
SetupStreamingContinuation_t continuation)
|
2020-12-03 09:59:43 +01:00
|
|
|
{
|
2022-07-15 22:03:43 +02:00
|
|
|
int multiTrackAudioMixes = config_get_int(main->Config(), "AdvOut",
|
|
|
|
"StreamMultiTrackAudioMixes");
|
|
|
|
int idx = 0;
|
|
|
|
|
|
|
|
bool is_multitrack_output = allowsMultiTrack();
|
|
|
|
|
2015-02-15 03:10:39 +01:00
|
|
|
if (!useStreamEncoder ||
|
2015-08-19 05:58:24 +02:00
|
|
|
(!ffmpegOutput && !obs_output_active(fileOutput))) {
|
2015-02-15 03:10:39 +01:00
|
|
|
UpdateStreamSettings();
|
|
|
|
}
|
|
|
|
|
2015-03-08 01:32:00 +01:00
|
|
|
UpdateAudioSettings();
|
|
|
|
|
2020-09-03 15:56:03 +02:00
|
|
|
if (!Active())
|
2015-01-26 22:41:22 +01:00
|
|
|
SetupOutputs();
|
|
|
|
|
2019-02-07 07:24:25 +01:00
|
|
|
Auth *auth = main->GetAuth();
|
|
|
|
if (auth)
|
|
|
|
auth->OnStreamConfig();
|
|
|
|
|
2017-07-13 12:57:42 +02: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();
|
|
|
|
}
|
2017-07-13 12:57:42 +02:00
|
|
|
|
2024-04-18 15:41:36 +02:00
|
|
|
const char *audio_encoder_id =
|
|
|
|
config_get_string(main->Config(), "AdvOut", "AudioEncoder");
|
2024-06-18 15:12:57 +02:00
|
|
|
int streamTrackIndex =
|
2024-06-19 21:07:59 +02:00
|
|
|
config_get_int(main->Config(), "AdvOut", "TrackIndex") - 1;
|
2017-07-26 04:01:29 +02:00
|
|
|
|
2024-07-09 13:25:49 +02:00
|
|
|
auto handle_multitrack_video_result = [&](std::optional<bool>
|
|
|
|
multitrackVideoResult) {
|
|
|
|
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, "adv_stream",
|
|
|
|
nullptr, nullptr);
|
|
|
|
if (!streamOutput) {
|
|
|
|
blog(LOG_WARNING,
|
|
|
|
"Creation of stream output type '%s' "
|
|
|
|
"failed!",
|
|
|
|
type);
|
|
|
|
return false;
|
|
|
|
}
|
2017-07-13 12:57:42 +02:00
|
|
|
|
2024-07-09 13:25:49 +02:00
|
|
|
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;
|
|
|
|
}
|
2017-07-13 12:57:42 +02:00
|
|
|
|
2024-07-09 13:25:49 +02:00
|
|
|
obs_output_set_video_encoder(streamOutput, videoStreaming);
|
|
|
|
obs_output_set_audio_encoder(streamOutput, streamAudioEnc, 0);
|
2017-07-13 12:57:42 +02:00
|
|
|
|
2024-07-09 13:25:49 +02:00
|
|
|
if (!is_multitrack_output) {
|
|
|
|
obs_output_set_audio_encoder(streamOutput,
|
|
|
|
streamAudioEnc, 0);
|
|
|
|
} else {
|
|
|
|
for (int i = 0; i < MAX_AUDIO_MIXES; i++) {
|
|
|
|
if ((multiTrackAudioMixes & (1 << i)) != 0) {
|
2024-04-18 15:41:36 +02:00
|
|
|
obs_output_set_audio_encoder(
|
2024-07-09 13:25:49 +02:00
|
|
|
streamOutput, streamTrack[i],
|
|
|
|
idx);
|
|
|
|
idx++;
|
2024-04-18 15:41:36 +02:00
|
|
|
}
|
2024-07-09 13:25:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
};
|
2017-07-13 12:57:42 +02:00
|
|
|
|
2024-07-08 14:07:10 +02:00
|
|
|
return SetupMultitrackVideo(
|
|
|
|
service, audio_encoder_id,
|
|
|
|
static_cast<size_t>(streamTrackIndex),
|
|
|
|
VodTrackMixerIdx(service),
|
|
|
|
[&, continuation](std::optional<bool> res) {
|
|
|
|
continuation(handle_multitrack_video_result(res));
|
|
|
|
});
|
2020-09-17 07:20:02 +02:00
|
|
|
}
|
2017-07-13 12:57:42 +02:00
|
|
|
|
2020-09-17 07:20:02 +02:00
|
|
|
bool AdvancedOutput::StartStreaming(obs_service_t *service)
|
|
|
|
{
|
2015-01-26 22:41:22 +01:00
|
|
|
obs_output_set_service(streamOutput, service);
|
|
|
|
|
2015-09-11 04:10:40 +02:00
|
|
|
bool reconnect = config_get_bool(main->Config(), "Output", "Reconnect");
|
|
|
|
int retryDelay = config_get_int(main->Config(), "Output", "RetryDelay");
|
|
|
|
int maxRetries = config_get_int(main->Config(), "Output", "MaxRetries");
|
2015-09-07 01:19:53 +02: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 17:30:54 +02:00
|
|
|
const char *bindIP =
|
|
|
|
config_get_string(main->Config(), "Output", "BindIP");
|
2023-06-16 00:17:24 +02: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 17:50:09 +02:00
|
|
|
bool enableDynBitrate =
|
|
|
|
config_get_bool(main->Config(), "Output", "DynamicBitrate");
|
2016-07-29 17:30:54 +02: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;
|
|
|
|
}
|
|
|
|
|
2022-07-15 22:03:43 +02:00
|
|
|
bool is_rtmp = false;
|
|
|
|
obs_service_t *service_obj = main->GetService();
|
|
|
|
const char *protocol = obs_service_get_protocol(service_obj);
|
|
|
|
if (protocol) {
|
2024-02-04 12:10:24 +01:00
|
|
|
if (astrcmpi_n(protocol, RTMP_PROTOCOL,
|
|
|
|
strlen(RTMP_PROTOCOL)) == 0)
|
2022-07-15 22:03:43 +02:00
|
|
|
is_rtmp = true;
|
|
|
|
}
|
|
|
|
|
2021-11-26 10:25:39 +01:00
|
|
|
OBSDataAutoRelease settings = obs_data_create();
|
2016-07-29 17:30:54 +02:00
|
|
|
obs_data_set_string(settings, "bind_ip", bindIP);
|
2023-06-16 00:17:24 +02: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 17:50:09 +02: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 17:30:54 +02:00
|
|
|
obs_output_update(streamOutput, settings);
|
|
|
|
|
2015-01-26 22:41:22 +01:00
|
|
|
if (!reconnect)
|
|
|
|
maxRetries = 0;
|
|
|
|
|
2015-09-07 01:19:53 +02:00
|
|
|
obs_output_set_delay(streamOutput, useDelay ? delaySec : 0,
|
|
|
|
preserveDelay ? OBS_OUTPUT_DELAY_PRESERVE : 0);
|
|
|
|
|
2015-01-26 22:41:22 +01:00
|
|
|
obs_output_set_reconnect_settings(streamOutput, maxRetries, retryDelay);
|
2022-07-15 22:03:43 +02:00
|
|
|
if (is_rtmp) {
|
|
|
|
SetupVodTrack(service);
|
|
|
|
}
|
2015-01-26 22:41:22 +01:00
|
|
|
if (obs_output_start(streamOutput)) {
|
2024-04-18 15:41:36 +02:00
|
|
|
if (multitrackVideo && multitrackVideoActive)
|
|
|
|
multitrackVideo->StartedStreaming();
|
2015-01-26 22:41:22 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-04-18 15:41:36 +02:00
|
|
|
if (multitrackVideo && multitrackVideoActive)
|
|
|
|
multitrackVideoActive = false;
|
|
|
|
|
2017-10-06 13:48:24 +02:00
|
|
|
const char *error = obs_output_get_last_error(streamOutput);
|
2018-12-13 00:20:48 +01:00
|
|
|
bool hasLastError = error && *error;
|
|
|
|
if (hasLastError)
|
|
|
|
lastError = error;
|
|
|
|
else
|
|
|
|
lastError = string();
|
2017-10-06 13:48:24 +02:00
|
|
|
|
2023-01-16 06:27:47 +01:00
|
|
|
const char *type = obs_output_get_id(streamOutput);
|
2018-12-13 00:20:48 +01:00
|
|
|
blog(LOG_WARNING, "Stream output type '%s' failed to start!%s%s", type,
|
|
|
|
hasLastError ? " Last Error: " : "", hasLastError ? error : "");
|
2015-01-26 22:41:22 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AdvancedOutput::StartRecording()
|
|
|
|
{
|
2015-08-19 05:58:24 +02:00
|
|
|
const char *path;
|
2016-03-25 10:43:38 +01:00
|
|
|
const char *recFormat;
|
|
|
|
const char *filenameFormat;
|
2015-11-27 12:14:18 +01:00
|
|
|
bool noSpace = false;
|
2016-03-25 10:43:38 +01:00
|
|
|
bool overwriteIfExists = false;
|
2021-10-03 12:06:46 +02:00
|
|
|
bool splitFile;
|
|
|
|
const char *splitFileType;
|
|
|
|
int splitFileTime;
|
|
|
|
int splitFileSize;
|
2015-08-19 05:58:24 +02:00
|
|
|
|
2015-02-15 03:10:39 +01:00
|
|
|
if (!useStreamEncoder) {
|
2015-08-19 05:58:24 +02:00
|
|
|
if (!ffmpegOutput) {
|
2015-02-15 03:10:39 +01:00
|
|
|
UpdateRecordingSettings();
|
|
|
|
}
|
2024-04-18 15:41:36 +02:00
|
|
|
} else if (!obs_output_active(StreamingOutput())) {
|
2015-02-15 03:10:39 +01:00
|
|
|
UpdateStreamSettings();
|
|
|
|
}
|
|
|
|
|
2015-03-08 01:32:00 +01:00
|
|
|
UpdateAudioSettings();
|
|
|
|
|
2020-09-03 15:56:03 +02:00
|
|
|
if (!Active())
|
2015-01-26 22:41:22 +01:00
|
|
|
SetupOutputs();
|
|
|
|
|
2015-08-19 05:58:24 +02:00
|
|
|
if (!ffmpegOutput || ffmpegRecording) {
|
|
|
|
path = config_get_string(main->Config(), "AdvOut",
|
|
|
|
ffmpegRecording ? "FFFilePath"
|
|
|
|
: "RecFilePath");
|
2016-03-25 10:43:38 +01:00
|
|
|
recFormat = config_get_string(main->Config(), "AdvOut",
|
2015-08-19 05:58:24 +02:00
|
|
|
ffmpegRecording ? "FFExtension"
|
2023-03-24 12:44:37 +01:00
|
|
|
: "RecFormat2");
|
2016-03-25 10:43:38 +01:00
|
|
|
filenameFormat = config_get_string(main->Config(), "Output",
|
|
|
|
"FilenameFormatting");
|
|
|
|
overwriteIfExists = config_get_bool(main->Config(), "Output",
|
|
|
|
"OverwriteIfExists");
|
2015-11-27 12:14:18 +01:00
|
|
|
noSpace = config_get_bool(main->Config(), "AdvOut",
|
|
|
|
ffmpegRecording
|
|
|
|
? "FFFileNameWithoutSpace"
|
|
|
|
: "RecFileNameWithoutSpace");
|
2021-10-03 12:06:46 +02:00
|
|
|
splitFile = config_get_bool(main->Config(), "AdvOut",
|
|
|
|
"RecSplitFile");
|
2015-01-26 22:41:22 +01:00
|
|
|
|
2023-04-03 15:48:55 +02:00
|
|
|
string strPath = GetRecordingFilename(path, recFormat, noSpace,
|
|
|
|
overwriteIfExists,
|
|
|
|
filenameFormat,
|
|
|
|
ffmpegRecording);
|
2015-01-26 22:41:22 +01:00
|
|
|
|
2021-11-26 10:25:39 +01:00
|
|
|
OBSDataAutoRelease settings = obs_data_create();
|
2015-08-19 05:58:24 +02:00
|
|
|
obs_data_set_string(settings, ffmpegRecording ? "url" : "path",
|
|
|
|
strPath.c_str());
|
2015-01-26 22:41:22 +01:00
|
|
|
|
2021-10-03 12:06:46 +02:00
|
|
|
if (splitFile) {
|
|
|
|
splitFileType = config_get_string(
|
|
|
|
main->Config(), "AdvOut", "RecSplitFileType");
|
|
|
|
splitFileTime =
|
|
|
|
(astrcmpi(splitFileType, "Time") == 0)
|
|
|
|
? config_get_int(main->Config(),
|
|
|
|
"AdvOut",
|
|
|
|
"RecSplitFileTime")
|
|
|
|
: 0;
|
|
|
|
splitFileSize =
|
|
|
|
(astrcmpi(splitFileType, "Size") == 0)
|
|
|
|
? config_get_int(main->Config(),
|
|
|
|
"AdvOut",
|
|
|
|
"RecSplitFileSize")
|
|
|
|
: 0;
|
2023-04-05 00:46:07 +02:00
|
|
|
string ext = GetFormatExt(recFormat);
|
2021-10-03 12:06:46 +02:00
|
|
|
obs_data_set_string(settings, "directory", path);
|
|
|
|
obs_data_set_string(settings, "format", filenameFormat);
|
2023-04-05 00:46:07 +02:00
|
|
|
obs_data_set_string(settings, "extension", ext.c_str());
|
2021-10-03 12:06:46 +02:00
|
|
|
obs_data_set_bool(settings, "allow_spaces", !noSpace);
|
|
|
|
obs_data_set_bool(settings, "allow_overwrite",
|
|
|
|
overwriteIfExists);
|
2022-07-21 14:04:57 +02:00
|
|
|
obs_data_set_bool(settings, "split_file", true);
|
2021-10-03 12:06:46 +02:00
|
|
|
obs_data_set_int(settings, "max_time_sec",
|
2022-04-11 15:21:03 +02:00
|
|
|
splitFileTime * 60);
|
2021-10-03 12:06:46 +02:00
|
|
|
obs_data_set_int(settings, "max_size_mb",
|
|
|
|
splitFileSize);
|
|
|
|
}
|
|
|
|
|
2015-01-26 22:41:22 +01:00
|
|
|
obs_output_update(fileOutput, settings);
|
|
|
|
}
|
|
|
|
|
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");
|
2017-02-04 05:29:09 +01:00
|
|
|
QMessageBox::critical(main,
|
|
|
|
QTStr("Output.StartRecordingFailed"),
|
2017-08-07 00:24:44 +02:00
|
|
|
error_reason);
|
2017-02-04 05:29:09 +01:00
|
|
|
return false;
|
2015-01-26 22:41:22 +01:00
|
|
|
}
|
|
|
|
|
2017-02-04 05:29:09 +01:00
|
|
|
return true;
|
2015-01-26 22:41:22 +01:00
|
|
|
}
|
|
|
|
|
2017-09-06 02:01:49 +02:00
|
|
|
bool AdvancedOutput::StartReplayBuffer()
|
|
|
|
{
|
2022-01-05 05:42:58 +01:00
|
|
|
const char *path;
|
|
|
|
const char *recFormat;
|
|
|
|
const char *filenameFormat;
|
|
|
|
bool noSpace = false;
|
|
|
|
bool overwriteIfExists = false;
|
|
|
|
const char *rbPrefix;
|
|
|
|
const char *rbSuffix;
|
|
|
|
int rbTime;
|
|
|
|
int rbSize;
|
|
|
|
|
2017-09-06 02:01:49 +02:00
|
|
|
if (!useStreamEncoder) {
|
|
|
|
if (!ffmpegOutput)
|
|
|
|
UpdateRecordingSettings();
|
2024-04-18 15:41:36 +02:00
|
|
|
} else if (!obs_output_active(StreamingOutput())) {
|
2017-09-06 02:01:49 +02:00
|
|
|
UpdateStreamSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateAudioSettings();
|
|
|
|
|
2020-09-03 15:56:03 +02:00
|
|
|
if (!Active())
|
2017-09-06 02:01:49 +02:00
|
|
|
SetupOutputs();
|
|
|
|
|
2022-01-05 05:42:58 +01:00
|
|
|
if (!ffmpegOutput || ffmpegRecording) {
|
|
|
|
path = config_get_string(main->Config(), "AdvOut",
|
|
|
|
ffmpegRecording ? "FFFilePath"
|
|
|
|
: "RecFilePath");
|
|
|
|
recFormat = config_get_string(main->Config(), "AdvOut",
|
|
|
|
ffmpegRecording ? "FFExtension"
|
2023-03-24 12:44:37 +01:00
|
|
|
: "RecFormat2");
|
2022-01-05 05:42:58 +01:00
|
|
|
filenameFormat = config_get_string(main->Config(), "Output",
|
|
|
|
"FilenameFormatting");
|
|
|
|
overwriteIfExists = config_get_bool(main->Config(), "Output",
|
|
|
|
"OverwriteIfExists");
|
|
|
|
noSpace = config_get_bool(main->Config(), "AdvOut",
|
|
|
|
ffmpegRecording
|
|
|
|
? "FFFileNameWithoutSpace"
|
|
|
|
: "RecFileNameWithoutSpace");
|
|
|
|
rbPrefix = config_get_string(main->Config(), "SimpleOutput",
|
|
|
|
"RecRBPrefix");
|
|
|
|
rbSuffix = config_get_string(main->Config(), "SimpleOutput",
|
|
|
|
"RecRBSuffix");
|
|
|
|
rbTime = config_get_int(main->Config(), "AdvOut", "RecRBTime");
|
|
|
|
rbSize = config_get_int(main->Config(), "AdvOut", "RecRBSize");
|
|
|
|
|
|
|
|
string f = GetFormatString(filenameFormat, rbPrefix, rbSuffix);
|
2023-04-05 00:46:07 +02:00
|
|
|
string ext = GetFormatExt(recFormat);
|
2022-01-05 05:42:58 +01:00
|
|
|
|
|
|
|
OBSDataAutoRelease settings = obs_data_create();
|
|
|
|
|
|
|
|
obs_data_set_string(settings, "directory", path);
|
|
|
|
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());
|
2022-01-05 05:42:58 +01:00
|
|
|
obs_data_set_bool(settings, "allow_spaces", !noSpace);
|
|
|
|
obs_data_set_int(settings, "max_time_sec", rbTime);
|
|
|
|
obs_data_set_int(settings, "max_size_mb",
|
|
|
|
usesBitrate ? 0 : rbSize);
|
|
|
|
|
|
|
|
obs_output_update(replayBuffer, settings);
|
|
|
|
}
|
2017-09-06 02:01:49 +02:00
|
|
|
|
|
|
|
if (!obs_output_start(replayBuffer)) {
|
2020-09-04 10:23:06 +02:00
|
|
|
QString error_reason;
|
|
|
|
const char *error = obs_output_get_last_error(replayBuffer);
|
|
|
|
if (error)
|
|
|
|
error_reason = QT_UTF8(error);
|
|
|
|
else
|
|
|
|
error_reason = QTStr("Output.StartFailedGeneric");
|
2022-10-13 02:01:46 +02:00
|
|
|
QMessageBox::critical(main, QTStr("Output.StartReplayFailed"),
|
2020-09-04 10:23:06 +02:00
|
|
|
error_reason);
|
2017-09-06 02:01:49 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-09-09 16:37:54 +02:00
|
|
|
void AdvancedOutput::StopStreaming(bool force)
|
2015-01-26 22:41:22 +01: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 16:37:54 +02:00
|
|
|
else
|
2024-04-18 15:41:36 +02:00
|
|
|
obs_output_stop(output);
|
2015-09-07 01:19:53 +02:00
|
|
|
}
|
|
|
|
|
2016-09-09 16:37:54 +02:00
|
|
|
void AdvancedOutput::StopRecording(bool force)
|
2015-01-26 22:41:22 +01:00
|
|
|
{
|
2016-09-09 16:37:54 +02:00
|
|
|
if (force)
|
|
|
|
obs_output_force_stop(fileOutput);
|
|
|
|
else
|
|
|
|
obs_output_stop(fileOutput);
|
2015-01-26 22:41:22 +01:00
|
|
|
}
|
|
|
|
|
2017-09-06 02:01:49 +02:00
|
|
|
void AdvancedOutput::StopReplayBuffer(bool force)
|
|
|
|
{
|
|
|
|
if (force)
|
|
|
|
obs_output_force_stop(replayBuffer);
|
|
|
|
else
|
|
|
|
obs_output_stop(replayBuffer);
|
|
|
|
}
|
|
|
|
|
2015-01-26 22:41:22 +01:00
|
|
|
bool AdvancedOutput::StreamingActive() const
|
|
|
|
{
|
2024-04-18 15:41:36 +02:00
|
|
|
return obs_output_active(StreamingOutput());
|
2015-01-26 22:41:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AdvancedOutput::RecordingActive() const
|
|
|
|
{
|
|
|
|
return obs_output_active(fileOutput);
|
|
|
|
}
|
|
|
|
|
2017-09-06 02:01:49 +02:00
|
|
|
bool AdvancedOutput::ReplayBufferActive() const
|
|
|
|
{
|
|
|
|
return obs_output_active(replayBuffer);
|
|
|
|
}
|
|
|
|
|
2015-01-26 22:41:22 +01:00
|
|
|
/* ------------------------------------------------------------------------ */
|
|
|
|
|
2023-04-03 15:48:55 +02:00
|
|
|
void BasicOutputHandler::SetupAutoRemux(const char *&container)
|
2020-09-26 17:19:27 +02:00
|
|
|
{
|
|
|
|
bool autoRemux = config_get_bool(main->Config(), "Video", "AutoRemux");
|
2023-04-03 15:48:55 +02:00
|
|
|
if (autoRemux && strcmp(container, "mp4") == 0)
|
|
|
|
container = "mkv";
|
2020-09-26 17:19:27 +02:00
|
|
|
}
|
|
|
|
|
2023-03-29 07:11:35 +02:00
|
|
|
std::string BasicOutputHandler::GetRecordingFilename(
|
2023-04-03 15:48:55 +02:00
|
|
|
const char *path, const char *container, bool noSpace, bool overwrite,
|
|
|
|
const char *format, bool ffmpeg)
|
2020-09-26 17:19:27 +02:00
|
|
|
{
|
2021-02-04 13:01:35 +01:00
|
|
|
if (!ffmpeg)
|
2023-04-03 15:48:55 +02:00
|
|
|
SetupAutoRemux(container);
|
2021-02-04 13:01:35 +01:00
|
|
|
|
2023-04-03 15:48:55 +02:00
|
|
|
string dst =
|
|
|
|
GetOutputFilename(path, container, noSpace, overwrite, format);
|
2021-02-04 13:01:35 +01:00
|
|
|
lastRecordingPath = dst;
|
2020-09-26 17:19:27 +02:00
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
2024-04-18 15:41:36 +02:00
|
|
|
extern std::string DeserializeConfigText(const char *text);
|
|
|
|
|
2024-07-08 14:07:10 +02:00
|
|
|
std::shared_future<void> BasicOutputHandler::SetupMultitrackVideo(
|
2024-06-18 15:12:57 +02:00
|
|
|
obs_service_t *service, std::string audio_encoder_id,
|
2024-07-08 14:07:10 +02:00
|
|
|
size_t main_audio_mixer, std::optional<size_t> vod_track_mixer,
|
|
|
|
std::function<void(std::optional<bool>)> continuation)
|
2024-04-18 15:41:36 +02:00
|
|
|
{
|
2024-07-08 14:07:10 +02:00
|
|
|
auto start_streaming_guard =
|
|
|
|
std::make_shared<StartMultitrackVideoStreamingGuard>();
|
|
|
|
if (!multitrackVideo) {
|
|
|
|
continuation(std::nullopt);
|
|
|
|
return start_streaming_guard->GetFuture();
|
|
|
|
}
|
2024-04-18 15:41:36 +02:00
|
|
|
|
|
|
|
multitrackVideoActive = false;
|
|
|
|
|
|
|
|
streamDelayStarting.Disconnect();
|
|
|
|
streamStopping.Disconnect();
|
|
|
|
startStreaming.Disconnect();
|
|
|
|
stopStreaming.Disconnect();
|
|
|
|
|
|
|
|
bool is_custom =
|
|
|
|
strncmp("rtmp_custom", obs_service_get_type(service), 11) == 0;
|
|
|
|
|
|
|
|
std::optional<std::string> custom_config = std::nullopt;
|
|
|
|
if (config_get_bool(main->Config(), "Stream1",
|
|
|
|
"MultitrackVideoConfigOverrideEnabled"))
|
|
|
|
custom_config = DeserializeConfigText(
|
|
|
|
config_get_string(main->Config(), "Stream1",
|
|
|
|
"MultitrackVideoConfigOverride"));
|
|
|
|
|
|
|
|
OBSDataAutoRelease settings = obs_service_get_settings(service);
|
|
|
|
QString key = obs_data_get_string(settings, "key");
|
|
|
|
|
|
|
|
const char *service_name = "<unknown>";
|
|
|
|
if (is_custom && obs_data_has_user_value(settings, "service_name")) {
|
|
|
|
service_name = obs_data_get_string(settings, "service_name");
|
|
|
|
} else if (!is_custom) {
|
|
|
|
service_name = obs_data_get_string(settings, "service");
|
|
|
|
}
|
|
|
|
|
|
|
|
std::optional<std::string> custom_rtmp_url;
|
|
|
|
auto server = obs_data_get_string(settings, "server");
|
|
|
|
if (strcmp(server, "auto") != 0) {
|
|
|
|
custom_rtmp_url = server;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto service_custom_server =
|
|
|
|
obs_data_get_bool(settings, "using_custom_server");
|
|
|
|
if (custom_rtmp_url.has_value()) {
|
|
|
|
blog(LOG_INFO, "Using %sserver '%s'",
|
|
|
|
service_custom_server ? "custom " : "",
|
|
|
|
custom_rtmp_url->c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
auto maximum_aggregate_bitrate =
|
|
|
|
config_get_bool(main->Config(), "Stream1",
|
|
|
|
"MultitrackVideoMaximumAggregateBitrateAuto")
|
|
|
|
? std::nullopt
|
|
|
|
: std::make_optional<uint32_t>(config_get_int(
|
|
|
|
main->Config(), "Stream1",
|
|
|
|
"MultitrackVideoMaximumAggregateBitrate"));
|
|
|
|
|
|
|
|
auto maximum_video_tracks =
|
|
|
|
config_get_bool(main->Config(), "Stream1",
|
|
|
|
"MultitrackVideoMaximumVideoTracksAuto")
|
|
|
|
? std::nullopt
|
|
|
|
: std::make_optional<uint32_t>(config_get_int(
|
|
|
|
main->Config(), "Stream1",
|
|
|
|
"MultitrackVideoMaximumVideoTracks"));
|
|
|
|
|
|
|
|
auto stream_dump_config = GenerateMultitrackVideoStreamDumpConfig();
|
|
|
|
|
2024-07-08 14:07:10 +02:00
|
|
|
auto continue_on_main_thread = [&, start_streaming_guard,
|
|
|
|
service = OBSService{service},
|
|
|
|
continuation = std::move(continuation)](
|
|
|
|
std::optional<MultitrackVideoError>
|
|
|
|
error) {
|
2024-07-09 13:25:49 +02:00
|
|
|
if (error) {
|
|
|
|
OBSDataAutoRelease service_settings =
|
|
|
|
obs_service_get_settings(service);
|
|
|
|
auto multitrack_video_name = QTStr(
|
|
|
|
"Basic.Settings.Stream.MultitrackVideoLabel");
|
|
|
|
if (obs_data_has_user_value(service_settings,
|
|
|
|
"multitrack_video_name")) {
|
|
|
|
multitrack_video_name = obs_data_get_string(
|
|
|
|
service_settings,
|
|
|
|
"multitrack_video_name");
|
|
|
|
}
|
|
|
|
|
|
|
|
multitrackVideoActive = false;
|
|
|
|
if (!error->ShowDialog(main, multitrack_video_name))
|
2024-07-08 14:07:10 +02:00
|
|
|
return continuation(false);
|
|
|
|
return continuation(std::nullopt);
|
2024-07-09 13:25:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
multitrackVideoActive = true;
|
|
|
|
|
|
|
|
auto signal_handler = multitrackVideo->StreamingSignalHandler();
|
|
|
|
|
|
|
|
streamDelayStarting.Connect(signal_handler, "starting",
|
|
|
|
OBSStreamStarting, this);
|
|
|
|
streamStopping.Connect(signal_handler, "stopping",
|
|
|
|
OBSStreamStopping, this);
|
|
|
|
|
|
|
|
startStreaming.Connect(signal_handler, "start",
|
|
|
|
OBSStartStreaming, this);
|
|
|
|
stopStreaming.Connect(signal_handler, "stop", OBSStopStreaming,
|
|
|
|
this);
|
2024-07-08 14:07:10 +02:00
|
|
|
return continuation(true);
|
2024-07-09 13:25:49 +02:00
|
|
|
};
|
|
|
|
|
2024-07-08 14:07:10 +02:00
|
|
|
QThreadPool::globalInstance()->start(
|
2024-04-18 15:41:36 +02:00
|
|
|
[=, multitrackVideo = multitrackVideo.get(),
|
|
|
|
service_name = std::string{service_name},
|
|
|
|
service = OBSService{service},
|
2024-07-08 14:07:10 +02:00
|
|
|
stream_dump_config = OBSData{stream_dump_config},
|
|
|
|
start_streaming_guard = start_streaming_guard]() mutable {
|
|
|
|
std::optional<MultitrackVideoError> error;
|
2024-04-18 15:41:36 +02:00
|
|
|
try {
|
|
|
|
multitrackVideo->PrepareStreaming(
|
|
|
|
main, service_name.c_str(), service,
|
|
|
|
custom_rtmp_url, key,
|
|
|
|
audio_encoder_id.c_str(),
|
|
|
|
maximum_aggregate_bitrate,
|
|
|
|
maximum_video_tracks, custom_config,
|
2024-06-18 15:12:57 +02:00
|
|
|
stream_dump_config, main_audio_mixer,
|
|
|
|
vod_track_mixer);
|
2024-07-08 14:07:10 +02:00
|
|
|
} catch (const MultitrackVideoError &error_) {
|
|
|
|
error.emplace(error_);
|
2024-04-18 15:41:36 +02:00
|
|
|
}
|
|
|
|
|
2024-07-08 14:07:10 +02:00
|
|
|
QMetaObject::invokeMethod(main, [=] {
|
|
|
|
continue_on_main_thread(error);
|
|
|
|
});
|
|
|
|
});
|
2024-04-18 15:41:36 +02:00
|
|
|
|
2024-07-08 14:07:10 +02:00
|
|
|
return start_streaming_guard->GetFuture();
|
2024-04-18 15:41:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
OBSDataAutoRelease BasicOutputHandler::GenerateMultitrackVideoStreamDumpConfig()
|
|
|
|
{
|
|
|
|
auto stream_dump_enabled = config_get_bool(
|
|
|
|
main->Config(), "Stream1", "MultitrackVideoStreamDumpEnabled");
|
|
|
|
|
|
|
|
if (!stream_dump_enabled)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
const char *path =
|
|
|
|
config_get_string(main->Config(), "SimpleOutput", "FilePath");
|
|
|
|
bool noSpace = config_get_bool(main->Config(), "SimpleOutput",
|
|
|
|
"FileNameWithoutSpace");
|
|
|
|
const char *filenameFormat = config_get_string(main->Config(), "Output",
|
|
|
|
"FilenameFormatting");
|
|
|
|
bool overwriteIfExists =
|
|
|
|
config_get_bool(main->Config(), "Output", "OverwriteIfExists");
|
2024-06-07 18:46:19 +02:00
|
|
|
bool useMP4 = config_get_bool(main->Config(), "Stream1",
|
|
|
|
"MultitrackVideoStreamDumpAsMP4");
|
2024-04-18 15:41:36 +02:00
|
|
|
|
|
|
|
string f;
|
|
|
|
|
|
|
|
OBSDataAutoRelease settings = obs_data_create();
|
|
|
|
f = GetFormatString(filenameFormat, nullptr, nullptr);
|
2024-06-07 18:46:19 +02:00
|
|
|
string strPath = GetRecordingFilename(path, useMP4 ? "mp4" : "flv",
|
|
|
|
noSpace, overwriteIfExists,
|
|
|
|
f.c_str(),
|
2024-04-18 15:41:36 +02:00
|
|
|
// never remux stream dump
|
|
|
|
false);
|
|
|
|
obs_data_set_string(settings, "path", strPath.c_str());
|
2024-06-07 18:46:19 +02:00
|
|
|
|
|
|
|
if (useMP4) {
|
|
|
|
obs_data_set_bool(settings, "use_mp4", true);
|
|
|
|
obs_data_set_string(settings, "muxer_settings",
|
|
|
|
"write_encoder_info=1");
|
|
|
|
}
|
|
|
|
|
2024-04-18 15:41:36 +02:00
|
|
|
return settings;
|
|
|
|
}
|
|
|
|
|
2015-02-06 12:17:33 +01:00
|
|
|
BasicOutputHandler *CreateSimpleOutputHandler(OBSBasic *main)
|
|
|
|
{
|
|
|
|
return new SimpleOutput(main);
|
|
|
|
}
|
2015-01-26 22:41:22 +01:00
|
|
|
|
|
|
|
BasicOutputHandler *CreateAdvancedOutputHandler(OBSBasic *main)
|
|
|
|
{
|
|
|
|
return new AdvancedOutput(main);
|
|
|
|
}
|