We had these advances laying around but didn't use them here. Loading
the glyphs from the fonts is extremely slow, so let's avoid that since
we take the time to cache these already.
When a capture card or video capture source is contained in the scene
collection's list of sources, but the source is not a part of any
scene, it will be first created but then destroyed again in a deferred
fashion (as it has no strong references to it anymore).
This will happen before the capture source has finished its own
initialization, hence why the source pointer can be invalid at that
point.
Not strictly necessary, and does not fix any bug. This just corrects a
nitpick that technically audio encoder packets are start points, but
that they aren't being labeled accordingly as keyframes.
The frame rate used to initialize an AMF encoder should be aligned
with the derived frame rate in video_output_info instead of the global
obs_video_info structure. With this change, IDRs can be aligned when
multiple renditions are being encoded.
Using video_output_info members for the format, colorspace, and range
parameters in addition to the frame rate provides a single source for
this information and obs_video_info is no longer needed.
FFmpeg is already very effective at detecting the correct input format
for socket-style protocols (SRT, RIST, TCP, UDP, etc.). By overriding
the format of SRT and RIST manually to mpegts, the user is being
prevented from using other container formats via these protocols.
In the rare case that libavformat is unable to detect the correct
container format for an SRT or RIST stream, the user may manually
specify that format in the existing format field.
With the FFmpeg options field which was recently added, probe options
may be specified by the user to further tune format detection.
Follow-up to 1d5d4b29e7:
win-wasapi: Handle changes to the default monitoring device
Splits the WASAPINotify class out of win-wasapi.cpp and makes it a
shared object in the plugin, then also creates a callback to reset
audio monitoring if the default output device changes.
Add a COMPAT version of NV_ENC_INITIALIZE_PARAMS_VER, which changed
between SDK 12.0 and 12.1.
If using drivers older than the configured SDK/API requires, fall back
to the compatibility version of the API (11.1).
An example scenario would be encoding in H.264 on driver version 512.15.
SDK 12.1 requires driver version 531.61 on Windows. Currently, in this
scenario, OBS will fall back to the FFmpeg encoder path, which will do
its own driver check, which will fail on this driver version.
With this change, this scenario will instead leverage the existing
compatibility hack to fall back to the compatibility version of the API
without falling back to FFmpeg.
It should be noted that while neat, the compatibility hack that enables
Kepler GPUs to continue to be able to use NVENC in this way is expected
to be removed at some point.
Because 4a8e8bb1bd changed the
NVENCAPI_STRUCT_VERSION define to rely on enc->needs_compat_ver, we must
do the conditional check and define needs_compat_ver before any structs
are initialized because they will check the version when doing so by
calling NVENCAPI_STRUCT_VERSION internally.
In this case, make sure that we define enc->needs_compat_ver before
NV_ENCODE_API_FUNCTION_LIST_VER is called for
NV_ENCODE_API_FUNCTION_LIST.
The MSVC_RUNTIME_LIBRARY property is not propagated to targets which
link against a target which has this property set. Thus the property
needs to be set on the actual virtualcam targets and not the interface
library.
Adding to the previous commit, let's also use obs_output_set_last_error
to provide localized error messages to the user if we run into these
failure cases.
BGRA or other formats that do not use color primaries will not yield
a valid color primary value. Initializing the CFComparisonResult to a
default value and replacing it only if a non-NULL color primary value
was retrieved avoids a possible crash.
PeerConnection::setRemoteDescription validates the input SDP, throwing
an exception whenever it is invalid.
Currently, instead of handling the exception, we just crash.
Instead, add an exception handler which logs a short description of the
issue as well as the error message from the exception.
Some devices will report different framerate ranges for formats that
are identical apart from color primaries. Without taking these into
account, only framerates for one color primary variant would be used
to populate the framerate dropdown in the property view of the camera
source.
Checking for a difference in color primaries when iterating over all
available formats for a device thus requires checking for this
variation and adding the additional frame rate range as well.
Fixes several possible crash issues that might occur on Intel-based Macs
and older macOS versions:
On modern macOS versions (13+) allocated memory is zero-allocated by
default which makes NULL pointer checks work correctly after allocation.
On older macOS versions this is not the case, so the OBSAVCaptureInfo
struct needs to be zero-allocated to ensure the guards in the tick and
render functions bail out correctly.
On Intel-based Macs and/or older macOS versions passing a reference to
the OBSAVCapture instance inside the OBSAVCapture struct can lead to a
crash because of a possible circular reference that cannot be resolved
at runtime.
Passing only a reference of the OBSAVCapture to libobs and incrementing
the retain count at source creation (decrementing in when the source is
destroyed) avoids this issue entirely.
The uninit function prematurely released the memory allocated for the
channel map setting, which exists in the scope of source life cycle
(compared to channel names which are valid during the life cycle of a
configured device).
Splitting up the clean-up for both (memory for channel names is
released when the device is uninitialized, memory for channel map
setting is released when the source is removed) ensures that the memory
is released but pointers don't become unexpectedly invalid.
OBS handles up to 8 channels of audio, which requires the CoreAudio
input callback to omit/ignore any audio data from channels above that
count and also report a maximum amount of 8 channels to match the
speaker setup given to swresample by libobs.
Some devices do not support all color formats at all resolutions, but
the capture card source automatically uses an available color format
and compares it against the available format for a specific resolution.
Without being able to change this format, some resolutions do not
work as CMIO will not be able to find a compatible format. Thus the
color format needs to be manually selected for capture card sources
as well.
Previously, we always assumed we could push more frames before an encoded
packet would be available. Actually, we can get EAGAIN when the
frame queue is full and before any encoded packets have been completed.
Instead, attempt to read packets more often as the worst that can
happen is we get EAGAIN again.
After adding proper adapter enumeration the linux code ends up entering
the texture encoding paths, but these paths are not correctly
implemented on linux yet.
fixes#10221
Frame rate should be defined before AMF encoder initialization,
because this information is used for setting vui_time_scale in SPS.
If frame rate isn't defined before initialization,
then AMF encoder set default frame rate into VUI header (30 fps).
This commit also modifies build-aux to update libdatachannel.
This commit also modifies obs-webrtc to avoid a compiler error.
Notable changes:
* deps.ffmpeg: Update libdatachannel to 0.20.1
* deps.macos: Remove Carla
* deps.macos: Add uthash to macOS deps
* deps.windows: Remove Carla
* deps.windows: Add uthash to Windows deps
To avoid a compiler error, this commit also bumps the configured NVENC
version to match the updated version in the deps package.
Notable changes:
* deps.ffmpeg: Update zlib to 1.3
* deps.ffmpeg: Update SVT-AV1 to 1.8.0
* deps.ffmpeg: Update aom to 3.8.0
* deps.ffmpeg: Update libsrt to 1.5.3
* deps.ffmpeg: Update nv-codec-headers to 12.1.14.0
* deps.ffmpeg: Update AMF to 1.4.32
* deps.ffmpeg: Update FFmpeg to 6.1
* deps.macos: Update LuaJIT to 2.1 c525bcb902
* deps.macos: Update FreeType to 2.13.2
* deps.macos: Update Asio to 1.29.0
* deps.macos: Update nlohmann JSON to 3.11.3
* deps.macos: Update Sparkle to 2.5.2
* deps.macos: Update Syphon Framework to 5.0 39e31383ff
* deps.windows: Update FreeType to 2.13.2
* deps.windows: Update curl to 8.5.0
* deps.windows: Update LuaJIT to 2.1 c525bcb902
* deps.windows: Update Asio to 1.29.0
* deps.windows: Update nlohmann JSON to 3.11.3
* deps.windows: Update VPL to v2.10.1
* deps.qt: Update Qt6 to 6.6.1 for Windows
* deps.qt: Update Qt6 to 6.6.1 for macOS
If a user sets both AdaptiveMiniGOP=true and EnablePreAnalysis=true
in the AMF/FFmpeg options field, AMF will adaptively insert
B-pictures, and no longer uses the fixed B pattern.
For a fixed B-frames pattern, it is expected that increasing B-frames
can cause a quality drop for certain content such as with high motion.
AdaptiveMiniGOP is recommended when using B-frames to improve the
quality in such cases. AdaptiveMiniGOP is dependent on PreAnalysis
which means that trying to enable it without having PreAnalysis turned
ON will have no negative effect (AdaptiveMiniGOP won't be enabled).
This will allow consumers of obs_pipewire to handle the device
registry themselves. This is not useful for the screencast code
since there's always only one node in the registry, but it will
be used by the camera and audio code to list hardware devices.
Makes it so that slideshows can have as many files as desired, and
lazily decodes image data in a separate thread to prevent decoding from
stalling the video thread.
macOS 14.2 changed internal defaults of SCK requiring the inclusion
of the menu bar and child windows to be enabled explicitly.
This will have a slight negative impact on capture performance but is
required to restore behavior of prior macOS versions.
Removes flag guard to enable HDR streaming for HEVC over enhanced-RTMP.
This functionality is currently only supported by YouTube. See
github.com/veovera/enhanced-rtmp for the enhanced-RTMP spec.
Sends color metadata before the video header for RTMP streams. Only
applicable to HDR RTMP streams. Ensures the server sees the correctly
configured color metadata first, in cases where the decoder config in
the video header has incorrect or missing color information. Mitigates a
bug that users with outdated AMD drivers may encounter.
find_qt was necessary during the transitional period between Qt5 and
Qt6. With Qt6 being the only supported Qt version (for open source) for
the time being, code complexity can be reduced for easier maintenance.
This commit adds the screencast-specific 'cursor_visible' field
in an anonymous struct within the constructor struct.
This slightly improves the connection code by properly treating
construction-time information in a constructor struct. It allows
removing the extra function call that sets cursor visibility from
the Screencast portal code.
Admittedly that's not much, but again, this will be an important
distinction when introducing the Camera portal code, since some
camera properties will need to trigger renegotiation.
So that we can expand the number of construct-time connection
properties without changing the function signature every time.
This is mostly an ergonomic change for now, but it'll be very
useful when introducing the Camera portal code.
While adding or updating files locked this mutex, the graphics thread
did not. As the update operation is not atomic, the graphics thread
might access the darray in the middle of an update, resulting in access
to freed memory (crash) if the files were updated at the same time.
In some scenarios ScreenCaptureKit will not call our completion handler
when an internal ReplayKit error occurred. This seems to be more common
when a <nil> display id is provided as the content filter for
ScreenCaptureKit.
The issue was reported to Apple as FB13455947, but it is good practice
for us to check for an invalid display ID before even attempting to start
a capture stream.
On Windows, the VST plugins' window sizes are rendered larger than the
actual content on displays that have UI scale factor. The sizes are
larger by the scale factor, for example, 100x100 content will have a
200x200 window on a 200% scaled screen, and 150x150 on a 150% scaled
screen. This change adjust the window size to fit the content size.
When an encoder was not created in create_encoder, the appropriate
OSStatus value is returned but the calling code expects a boolean
return value.
The negative OSStatus code sent on error is thus interpreted as a
truthy value and the error is not detected. Changing the call signature
to correctly return an OSStatus (and change the caller to detect
error situations) fixes this.
Fixes for using FFmpeg 6.1 due to deprecations. Uses `#if` macros to
allow builds for using older versions of FFmpeg.
This commit replaces usage of `av_stream_add_side_data(...)` with
`av_packet_side_data_add(...)`, as the former was deprecated in favor of
the latter.
The FFmpeg commit that deprecated `av_stream_add_side_data(...)` is [1].
The FFmpeg commit that introduced `av_packet_side_data_add(...)` is [2].
Note that the deprecation commit is after the new API function. The
commit in between [3] appears to be changes that migrates to the usage
of the new API function.
[1]: avformat/avformat: use the side data from AVStream.codecpar
5432d2aaca
[2]: avcodec/packet: add generic side data helpers
74279227dd
[3]: avcodec/codec_par: add side data to AVCodecParameters
21d7cc6fa9
If an output has already stopped, but its StopRecording function was
called again, then ffmpeg_mux_stop would be called and set stopping to
true. On the next output start, OBS would output 1 frame, see that
stopping is true, and then stop the output.
This was most easily observed using an Output Timer to record prior to
93f5b45be8.
Initialize stopping to false with the other state flags to ensure that
the output has a clean starting state.
Flag was added in CMake 2.0 update and is incompatible with incremental
linking enabled by default for Debug configuration (MSVC default).
The original error that necessitates adding LTCG is not present with
current obs-deps anymore, so remove it instead and disable the
hard-coded default library directive in Debug configuration.
We use a size_t that can be 64bit while EGL uses 32bit for the
underlying value. Writes from our graphics function can leave high bits
uninitialized and cause iteration of the format list to overlfow.
fixes#9844
This race condition is caused when one thread creates a swap chain,
which calls OBS_CreateSwapchainKHR, at the same time another thread
calls OBS_CreateImageView.
OBS_CreateSwapchainKHR allocates swap data, publishes this into the
data->swaps linked list, then initializes it. Meanwhile,
OBS_CreateImageView is iterating the swaps linked list, to see if the
image matches any swap chain images. Due to the order in
OBS_CreateSwapchainKHR, there's no guarantee this data is initialized
so it often ends up running out of bounds on the swap_images array.
The fix is simply to defer the swap data publish to after init.
Splits the WASAPINotify class out of win-wasapi.cpp and makes it a
shared object in the plugin, then also creates a callback to reset
audio monitoring if the default output device changes.
The previous commit sets the default configuration to 2 seconds, meaning
that the 0 second default interval no longer happens per default. If
someone explicitly sets the interval to 0 seconds ("auto"), we should
allow them to do that.
0 seconds means "auto" according to the documentation, but this appears
to be broken in many configurations (more than just CRF mode on Apple
Silicon). With some encoders it means that the encoder sets a keyframes
every 31st frame, other times it just doesn't set any keyframes at all
after the first one, only rarely does the "auto" interval actually
appear to work.
Lets just set the default to 2 seconds and be happy. In theory this is
the maximum keyframe interval and encoders are allowed to set more if
they so wish, but they never appear to do so.
This pattern uses fewer instructions and also avoids using max, which
does not work on infinity.
Also remove unreferenced techniques from scale filters.
Nothing about WHIP requires CBR (and many things that use it use VBR),
and there's no specific upstream service to care about it (WHIP is a
protocol, not a service, despite being exposed as a "service" in OBS),
so let's stop forcing it to be CBR and allow the user to choose other
rate control methods.
We were passing the core pipewire pointer where renegotiation expected
the stream pointer. Somehow this worked, probably because the two are
very close.
fixes#9733
Calling update_targetusage in update_params only updates the setting
when an encoder session is initialized. Calling update_targetusage in
rate_control_modified, like update_latency and update_enhancements, will
update the setting when the Settings window is loaded. This will cause
the updated setting to be reflected in the UI.
8dd20dfd33 introduced an explicit check
for the available macOS SDK, meaning that we can be sure that the macOS
13.1 SDK is available. As such, we do not require ifdef guards for the
availability of functions that are older than 13.1.
After the cmake 3.0 rebuild glad was transitioned to a static library.
This lead to the glad symbols being uninitialized and crashes when they
are used in some cases.
Adds a switch to distinguish between the possible results that could
occur. While we expect to received RequestCompleted for our camera
extension (RequestWillCompleteAfterReboot is usually more of a network
extension thing), we can't be sure that this always is what we receive
unless we check it.
OSSystemExtensionErrorRequestCanceled is called when the activation
delegate returns OSSystemExtensionReplacementActionCancel on request
actionForReplacingExtension withExtension. As per the previous (parent)
commit we no longer request cancellation, so we can be sure that
receiving a "cancelled" error is an actual error and not something that
is supposed to happen.
This commit also removes the "error" from the log prefix, as the message
sent may also be a warning instead, and the LOG_LEVEL conveys the
severity of the log line anyways.