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.
Current code assumes that a newer version of the extension is always
better. However that's not true - when the user installs an old version
of OBS, we should also install the old version of the camera extension
to have a version compatible with the installed OBS.
For normal users this method is only called when the versions in the
Info.plist do not match. In system extensions developer mode it's called
every time an installation is requested (meaning on every start), which
is probably desired as well; and by never returning
"ReplacementActionCancel" we can now always treat "ErrorRequestCanceled"
as an error and not something that we requested to happen.
Add:
Counter-Strike 2, UWP applications, Gaming Services applications,
Microsoft 365(Excel, PowerPoint, Word, Access, OneNote, Outlook,
Publisher and 365 software), Adobe After Effects,
Adobe Character Animator, Adobe Photoshop, Adobe Premiere Pro, Steam,
Epic Games Launcher, Ubisoft Connect, Tencent GUI applications, WeChat
and YY.
Tweak:
Change "Electron" name to "Chromium";
Change "%name% cannot be captured via Game Capture." to
"%name% cannot be captured using Game Capture.".
Remove:
Chrome and Edge (reason is based on Chromium).
These days you might capture card a 175Hz monitor with a framerate
defined as 10000000/57143 that doesnt fit in a short. And reporting a
negative FPS in that case isnt very helpful.
For Target Usage, instead of doing string comparisons against long
descriptive strings, use translatable strings for descriptive UI text
and simple designations for values used for comparisons and storage.
This is similar to what we do for NVENC Presets.
On Windows 10 and up, D3D11 should never fail, so the D3D9 code should
no longer be possible to hit. As far as I can tell, this code was mostly
for Windows 7/8/8.1 and it was part of the initial implementation. It
should no longer be needed.
On Windows 10 and up, D3D11 should never fail, so the D3D9 code should
no longer be possible to hit and should no longer be needed.
Revert "obs-qsv11: Use d3d9 allocator on Win7"
This reverts commit b276b1633e.
This reverts the changes to Windows where Release() was called every
time, since we need share a single DX context across multiple encoders.
Instead introduce a ReleaseSessionData() function and some platform
specific session data that will be passed to it. We use this to track
the VA-API display and fd to release them at the right time. Leaking
displays will also lead to cache pollution in the intel-media-driver
crashing users so we cannot do that.
fixes#9611
The current code assumes that a display UUID can be created with the
stored ID, but that's not always the case, e.g. when the user doesn't
have the display connected. As such, we need to null check this, and
fall back to the invalid ID (0) when the ID cannot be migrated.
The current code also only migrates on source creation, which yields
weird behaviour where if the user opens properties and then cancels it
would still show the first display, but only for the session. This is
why the code was factored out of the creation function and now is always
used when an ID needs to be acquired from OBS Data settings, including
when the source is updated.
qrcodegen is built on obs-deps for macOS and Windows, with the
generated CMake package calling the dependency qrcodegen (not
libqrcoden) and associated target qrcodegen::qrcodegen.
This change updates the finder (required for Linux) to create the same
targets so consumers do not need to differentiate between different
variations of the same dependency on Linux.
Also updates obs-websocket to 5.3.1 to bring in associated CMake
changes.
libdatachannel is now built with MSVC instead of MinGW so we are able to
use C++ API instead.
The C++ is preferred by upstream and what the project is written in. The
C API provides a subset of features and has a performance penalty.
For some reason, using MFX_SCENARIO_GAME_STREAMING causes the keyframe
quants to be higher than other frames, which is not desirable. In turn,
this causes bitrate to be higher than the target bitrate for a sustained
period of time after each keyframe.
Not setting the scenario removes this behavior and returns CBR to
somewhat reasonable levels of consistency.
Co-authored by: Chris (Flaeri) <flaeri@otterbro.com>
Fixes problems with the astrcmpi logic, as well as a typo that said
"vertfast" instead "veryfast".
Also makes the method a void because it always returns true and isn't
checked anyways.
These effects can remain enabled between devices (so enabling it on one
device can mean it's later also enabled on another device), leading to
cases of capture cards getting blurred.
Logging that the effects are enabled should make it easier to spot this
in support.
This recent commit [1] broke SRT & RIST streaming because
obs_output_video now returns a NULL pointer for encoded outputs.
This fixes it by retrieving the pointer from the encoder.
[1] fb57eff212
Co-authored-by: tt2468 <tt2468@gmail.com>
Signed-off-by: pkv <pkv@obsproject.com>
Trying to use the display server as the QSV device was found to be
generally wrong in beta, so instead lets save defaults from the earlier
device enumeration similar to obs-ffmpeg-vaapi which is known to work
well.
This fixes a bug when swapping NVIDIA effects.
The update signal triggers a destruction of the previous effect, but the
effect would still run, potentially causing a crash.
The mutex added in the NVIDIA processing function prevents that.
Signed-off-by: pkv <pkv@obsproject.com>
The code assumed MFXCreateSession would always succeed, but it fails on
systems with no QSV implementations, causing a crash when we call
MFXClose later. Additional success checks for the other API calls were
also added.
Setting AdaptiveCQM to ON when LowPower is OFF crashes the
intel-oneapi-gpu implementation on Linux when using the AV1 encoder.
But using the same LowPower settings as Windows works so lets drop the
current guards.
We need to check for new versions of the NVIDIA Effects redistributables
because mismatched versions of the AUDIO and VIDEO sdk can have
different CUDA versions of the deps, which has caused crashes in obs.
It'd be way better that NVIDIA either ships a single installer with both
audio and video effects or that they auto-install with the drivers.
But meanwhile, we provide a warning to users which requires us to keep
in sync with what's released.
Signed-off-by: pkv <pkv@obsproject.com>
VPL does not have a consistent initialization process for the various
backends it dispatches to. So this resolves the new VPL dispatcher
failing to initialize the video session when it dispatches to
intel-mediaSDK backend. On the oneVPL-intel-gpu backend VA-API sessions
are correctly initialized so this wasnt noticed when tested on newer
hardware.
MFXEnumImplementations expects the adapter index to be within a range of
valid Intel adapters produced by MFXLoad and the config filter. If a
system has one non-Intel high performance GPU and one Intel iGPU, OBS
and the test app will see the Intel iGPU as index 1 due to high
performance hints, but MFXEnumImplementations will expect only one valid
index, 0. In this scenario, passing a value of 1 to
MFXEnumImplementations will cause it to abort and return
MFX_ERR_NOT_FOUND (Provided index is out of possible range). This causes
subsequent capabilities testing to fail.
To avoid this, let's track how many non-Intel adapters we see and
subtract that number from adapterIdx to only pass valid index to
MFXEnumImplementations.
Enable Low Power Look-ahead (VDENC LA) after Intel Arc Graphics. Change
LA_DEPTH defaults (60 frames for normal latency and 30 frames for low
latency). Keep VME Look-ahead only for certain Intel platforms (ICL,
TGL, ADL, and RPL). Disable VME LA for HEVC
* Change GopPicSize default to 240
* Remove GopOptFlag
* Change keyint_sec default from 3 to 0
* Reduce keyint_sec minimum value from 1 to 0 (for auto)
Due to a particular... plugin we all know and love, the new
QCefWidget::executeJavascript() function may not actually be present as
it should be. So, we have to verify that it's available, and only use it
in that case.
(This commit also modifies obs-ffmpeg)
This change was meant for track matte stingers to prevent the last frame
from having risk of flashing due to their transparent nature, but this
code had a negative side effect on normal stingers as well.
Fixesobsproject/obs-studio#8981
Our solution for adding TRANSFER_SRC usage for imageless framebuffers
was triggering validation errors when combined with image view usage
overrides. Add TRANSFER_SRC onto usage overrides for swap chain image
views to fix mismatches.
The functions `aja::lower` and `aja::replace` overwrite the 1st argument
and just return the reference to the 1st argument. It is not necessary
to use the return value.
Rendezvous mode with SRT protocol is used to punch through firewalls.
Although caller or listener mode are much more widespread, it is
sometimes in use. The rendezvous mode was broken in obs because we
would bind to the remote IP, instead of a local IP. This fixes the bug.
Note that there is also a bug in libsrt preventing our code to work.
But Version 1.5.2+ of libsrt fixes that.
Signed-off-by: pkv <pkv@obsproject.com>
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.
Adds a custom User-Agent header to REST requests identifying OBS as the
client.
Randomizes SSRCs to avoid potential issues with servers that do not
rewrite them before forwarding.
Previously would always end up with OBS_MEDIA_STATE_ENDED whether the
video reaches the end or the user stops the source (state is set to
STOPPED, but becomes ENDED right after). This fixes it so that if the
user stops the source, it will remain stopped.
The D-Bus signal subscription is a very boring aspect of the
portals infrastructure that shouldn't really matter when reading
the code of pipewire.c.
Move it out to its natural place, portal.c.
Cameras and audio streams will use the async output routines, but
not screencasting. This needs to be handled differently in the
processing callback.
As it is, the code is starting to get a bit messy, as we're now
dealing with two different frame processing approaches. Later on,
this code will be cleaned up and split in more logical pieces.
Co-authored-by: Georges Basile Stavracas Neto
<georges.stavracas@gmail.com>
So far we've been treating format info on a per-connection basis,
but now that a single connection is capable of hosting multiple
streams, and each stream might negotiate a different format, it
is necessary to move format info to each stream individually.
Sorry, this is a painful commit to review :(
Until now, the only consumer of the PipeWire code is the screen
cast portal code. This portal code only ever has one PipeWire
connection, and one PipeWire stream, every time a monitor or a
window is selected. This is reflected on obs_pipewire, which only
handles a single stream for any given connection.
For cameras and audio, however, a single PipeWire connection can
and most likely always will provide multiple streams. For example,
computers with multiple webcams will have one PipeWire connection
reporting multiple PipeWire nodes, one node for each camera.
This commit breaks this one-stream-per-connection assumption, and
makes obs_pipewire_connect_stream() return an independent object
(obs_pipewire_stream) that represents a single stream.
The screencast portal code continues to only ever have one connection
and one stream.
This moves the existing adapter checking into the platform layer and
moves the Windows implementation to its platform implementation and adds
a Linux implementation based on directly querying VA-API.
Unlike Windows, this check takes ~1ms so we have no need to spin out
another thread to perform the work. This also fixes up some of the CPP/C
mixing going on in common_utils."h" to allow us to call common functions
from C files.
The CMake 3.0 path used the old syntax for logging if the module was
disabled. Update this to use target_disable to match the syntax in other
CMake 3.0 paths.
Default ffmpeg initial buffer fullness (75%) is too low
and results in significantly lower video quality on AMD cards.
Changing it to 100% fixes the quality and also matches what
AMF encoder is doing.
This cleans up the fairly arbitrary Windows includes and types and
unused functions from the common code and replaces them with platform
independent equivalents, or platform specific implementations in
common_utils.
This removes the Windows 8 support to avoid adding an additional
platform function to query this. OBS only supports Windows 10
officially, so it's about time we removed it.
Replace the checks based on D3D11 and D3D9 to check a more informative
variable aptly named UseTexAlloc for which memory allocator should be
used within the encoder.
The query being done will ovewrite ALL invalid parameters. This results
in invalid parameters that are not LowPower settings being overwritten
with 0 either introducing different errors or possibly different
behavior.
This log line was introduced in 239e9273d and looks like it was for
debugging purposes. It always prints an error message when an SCK audio
capture source was successfully created.
To avoid passing `struct darray *` type, which cannot hold the type
information, this commit defines array types and uses that types on the
function parameters.
To avoid passing `struct darray *` type, which cannot hold the type
information, this commit defines array types and uses that types on the
function parameters.
Passing struct darray type will loose the actual type of the contents.
Uses a defined type of `DARRAY(struct encoder_packet)` to carry the
type when crossing functions.
For mpegts output, used in rtmp-custom service, encoder settings
require:
- ADTS with fdk-aac.
For all non-rtmp protocols, one also requires:
- video encoder header repetition;
This future proofs the code against protocol addition.
Additionally, I've added a check against NULL audio settings, which was
in my fork but that I forgot to add in the PR [1].
[1] https://github.com/obsproject/obs-studio/pull/6163
Signed-off-by: pkv <pkv@obsproject.com>
Improve complicated Objective-C implementations in
mac-screen-capture implementation.
- Use `for` instead of overuse of block based iteration code.
- Use `YES` and `NO` for `BOOL` type instead of wrong `TRUE`, `FALSE`,
`true`, `false`.
- Use `length` to check empty string, omit unnecessary `nil` checks.
`screen_capture_build_content_list` or similar calls uses updated
`sc->show_hidden_windows` or similar flags, but these are not set
before calling these functions.
Some options do not require a media source restart. Saving source
unchanged source settings should also not trigger a restart.
I tried to also make it so speed changes do not require a restart by
manipulating the elapsed timestamp for the source, but it sometimes
causes the first few milliseconds after saving settings to be rough or
slightly distorted. I am also unsure whether a/v frame buffers should be
cleared on a speed change (and how to) so I made it so restarts are
required for speed changes. Chiyo also mentioned that successive quick
speed changes will cause maximum audio buffering (which I was able to
reproduce once).
Nonlocal file playback is unaffected, and will cause the media source to
restart because I am not aware of the possible consequences and because
there's no restart button for it.
Changing "Apply alpha in linear space" is only visible after a few
milliseconds (when mp_media_next_video is called for new frames).
If `is_stinger` and `full_decode` are toggled during runtime, even
though it shouldn't be possible as they are not accessible in the UI,
a media restart will be triggered.
Creation of Info.plist files through Xcode is more canonical and
future-proof, as it will automatically pick up changes/updates
introduced by Apple. Non-standard keys can still be added via a
template file, which will then be extended by Xcode with the default
keys.
Compiler extensions are disabled before the first `project` call to
force CMake into considering compilers to not support GNU extensions
(even though clang and gcc do).
Also sets common clang compiler options so they can be used across all
supported platforms.
`openmp-simd` support is enabled by default as there is no performance
penalty on x86_64 systems and intrinsics are enabled on arm64.
Also implements CMake's `CMAKE_COMPILE_WARNING_AS_ERROR` flag to
enable the desired behavior and configuration time.
The FTL SDK is outdated and not actively maintained - the warnings are
known and acknowledged, so there is no need to further pollute the
build output with them.
clang expects an empty prototype to explicitly use `void`.
Also silences the warning in `libobs-opengl`, `obsglad`, `caption`,
`mac-syphon` and `obs-x264-test`.
Updates the syphon to use the Syphon.framework from obs-deps instead of
the submodule.
The submodule however was not updated in 9 years and additionally had
custom patches, compared to the obs-deps release that's built on the
current git commit of Syphon, meaning that some code changes are
necessary. It would be nice to split the code and cmake changes into
multiple commits (where the first would update the submodule and contain
the plugin code changes, and the second switch the cmake away from the
submodule to the obs-deps release), but it really doesn't make sense to
update the submodule first if it gets removed anyways.
Adds a subclass for SyphonClientBase that is responsible for receiving
the frames. This has the advantage that it doesn't need an OpenGL
context like the existing SyphonOpenGLClient, and can just return an
IOSurface directly (without some kind of middleman).
The obs-webrtc PR was merged before 79822a58c, but the PR of 79822a58c
was not rebased on latest master before being merged. As such, the
usages of the obs_output_*2 functions was not removed by that PR.
Effectively reverting parts of d314d47, this commit removes the new
functions that got added to remove the flags parameter. Instead, it just
marks the parameter as unused and documents this. Having what is
effectively an API break just to remove a parameter is a bit overkill.
The other parts of d314d47 which cleaned up the usage of the flags
parameter are untouched here.
This adds a WHIP output & associated service.
- Code inspiration from DDRBoxman
- Implemented by Sean DuBois & tt2468
- Various fixes and contributions by pkv.
Co-authored-by: tt2468 <tt2468@irltoolkit.com>
Co-authored-by: DDRBoxman <colin@recursivepenguin.com>
Co-authored-by: pkv <pkv@obsproject.com>
Signed-off-by: pkv <pkv@obsproject.com>
ee3c2d0 introduced a local copy of the CGDisplayStream.h header as the
macOS 13.3 SDK erroneously declared functions as unavailable on older
systems. This has been fixed in the macOS 14 SDK with the functions
correctly being declared as available on 10.8, so we can use the system
header again, and in the future remove the local copy once our minimum
compile version is new enough.