"New Socket Loop" and "Low Latency Mode" RTMP options are only available
on Windows.
Those options should be ignored and forced-disabled on non-Windows
builds.
The empty clause was originally introduced to set a cutoff settings as a
hack at a commit ae862c16a and later removed at a commit a89470d2e. At
this time, the clause became empty but another commit aa58b9cf5 reuse
the clause and finally a commit 9baedb1c6 removes so that the clause is
empty now.
Use hex for modifiers because they are generally formed from a high byte
and low bytes. This makes it easier to see these bytes and identify
unusual modifiers.
If we receive an empty cursor bitmap - one without valid size - we
should hide the cursor. Do so by clearing the texture.
This fixes visible cursors when recording various games with Wayland
compositors.
Closes https://github.com/obsproject/obs-studio/issues/4895
This reverts commit aa58b9cf5f.
FFmpeg has reverted their default AAC encoder from fast to twoloop,
which has much better rate control management, making it closer to CBR,
and it sounds much better.
All presentation time stamps are rounded to whole seconds during the
conversion from nanoseconds to seconds, because of the immediate cast
to `int64_t`. This results in the same presentation time stamp being
send to consumers for a whole second.
In previews/live streams this isn't super visible as last frame is
often assumed to be the newest and the stream is updated. It's more
problematic when recording since APIs like Apple's AVFoundation don't
allow duplicate presentation time stamps or it can look like frames are
produced in huge bursts once per second.
In this PR `CMTimeMakeWithSeconds` is used instead of `CMTimeMake` to
make sure the conversion is done correctly and simplify the calculation
we have to do a little.
The `fillFrame` method of the mac-virtualcam plugin is creating samples
directly using the value from `mach_absolute_time()` as `hostTime`.
This assumes this value is in nanoseconds, while it is in fact in mach
tick units. On Intel Macs mach tick units will be exactly 1 nanosecond
resulting in valid values, but on Apple Silicon macs this is no longer
the case.
This results in sample buffers with the placeholder image that have
much lower presentation time stamps than the samples containing content
produced by OBS. In previews/live streams this shows due to the last
content sample being shown frozen until the whole buffer is filled with
samples containing the placeholder image. Applications recording the
video stream are even more confused and crash or record videos with
wildly incorrect lengths.
In this PR `clock_gettime_nsec_np` is used to convert from mach tick units
to nanoseconds. This will make sure the `hostTime` value is correct on
both Apple Silicon and Intel macs. Making sure we produce stable
presentation time stamps from the virtual camera plugin at all times.
Some compositors send buffer crop information even when the crop
matches the buffer size. It doesn't really matter in practice,
but it's good hygiene to check for the effective crop instead of
simply checking if crop exists.
Move code into auxiliary functions, to improve the legibility of the
draw function. It also gets rid of these pesky switch fallthroughs.
No functional changes.
In the non-DMA path, we are logging an error message saying that
the DMA format is wrong. That's not the DMA format, it's the raw
buffer format.
Fix the message.
Also modifies libobs & deps/media-playback.
AV_CODEC_CAP_TRUNCATED was removed in avcodec 60 [1].
We ifdef the code depending on it to allow compilation.
[1] avcodec: remove FF_API_FLAG_TRUNCATED
3ceffe7839
Signed-off-by: pkv <pkv@obsproject.com>
This is an option that while very powerful also provides a footgun for
users if they don't have enough memory. It will be helpful for support
volunteers to be able to see if the option has been enabled.
Stingers -- and especially track matte stingers -- are currently subject
to real time decoding, which can be detrimental in a production
environment where a stinger video may not be able to decode in a timely
fashion.
To remedy this, this change adds an option to fully decode stingers
immediately and cache the decoded video/audio in RAM for playback to
greatly improve stinger performance.
PipeWire allows since 0.3.62 [1] to attach metadata to a buffer
describing a transformation of the buffercontent. Clients should then
undo that transformation to import it correctly.
We can enable this feature using macro guards and runtime server version
checks on supported systems.
[1] https://gitlab.freedesktop.org/pipewire/pipewire/-/merge_requests/1423
Existing code made use of macros which broke parsing in Xcode and
complicated debugging as crucial code was executed within macros and
not actual source code.
Use of mutable CoreFramework data structures (which were never mutated)
is replaced by use of faster non-mutable variants.
When an allocator needs to be used, `kCFAllocatorDefault` is specified
explicitly.
VideoToolbox session properties are also set in bulk instead of
multiple consecutive calls.
Also simplifies detection of Apple Silicon hosts to make code more
readable.
CMake build framework 3.0 introduces more strict typing checks, which
require additional code fixes to silence.
* Fixes warnings about implicit casts
* Fixes warnings about weak references used multiple times inside
blocks
When bitrate is updated, a check against 'lookahead' setting is done.
If 'lookahead' is enabled, the bitrate update is disabled.
We indeed used to observe crashes with nvenc when frequent bitrate
resettings were effected while lookahead option was enabled.
But recent tests have shown that the issue is gone.
As a result this commit allows 'lookahead' with bitrate live update.
Signed-off-by: pkv <pkv@obsproject.com>
FFmpeg wipes priv_data if the encoder fails to start, so we need some
way of knowing if the GPU index was non-zero. This is a bit ugly but the
best way to do it for now.
This writes the result of nvEncGetLastErrorString to the last encoder
error instead of just the log file. This makes it user-visible, which
should help users diagnose and solve the problem.
Also strips off leading colons from NVENC error strings as these can
look odd given our format string. An example of such an error:
::NV_ENC_TWO_PASS_FULL_RESOLUTION is only supported multipass encoding
on this architecture.
Receiving buffers flagged as corrupted, or empty, is a casualty of
how things are implemented in various compositors, and it's not
a critical situation to be afraid of. We can expect a few buffers
to be flagged as corrupted here and there, and that's fine.
Demote these warnings to debug messages, as they're still useful
for debugging.
A trivial cosmetic change. This groups the constructor and
destructor together. Two sides of the same coin, yin and yang,
bound by their nature, and linked by their position in code.
This commit introduces an important distinction in the initialization
process that is essential to future camera and audio work: it splits
creating and connecting to the PipeWire socket, from connecting to
specific PipeWire nodes.
Right now, for the only consumer in existence - the ScreenCast portal
code - this distinction is irrelevant, but from an API perspective it
just makes sense to model it this way.
We don't actually need to restore the node id anymore, since this
is handled by the screencast-portal.c code now.
Remove the pipewire_node field, and just create the stream directly
from the passed file descriptor now.
This separation of obs_pipewire_create() and play_pipewire_stream()
was an artifact of how the original code was written, and there is
no reason to keep this separation anymore. Inlining it will help
future commits too.
And let each portal pass the stream properties relevant to them.
This makes the pipewire.c more independent of the actual portal
by providing a wrapper to create a stream. This will be relevant
later, when linux-pipewire introduces more portals like the Camera
one.
When the linux-pipewire plugin is unloaded, make sure to cleanup
the D-Bus proxy for the ScreenCast portal too. This effectively
doesn't change anything, but it's always good to keep up with the
code hygiene.
Copying the encoder list takes a while which blocks the main thread.
Doing the copying asynchronously removes instead of blocking the main
thread improves startup performance by about 60ms.
The aac spec has a list of default channel layouts that are implemented
by all aac encoders / decoders.
Unfortunately 2.1 is not in that list. When I wrote the surround sound
support into OBS, as a workaround I decided to encode 2.1 as
AV_CH_LAYOUT_SURROUND = FL+FR+FC.
The LFE channel is encoded as a regular audio channel which uses more
bits but this allows compatibility with all aac decoders.
Recently we updated to the new channel layout API of FFmpeg, but the
mapping of 2.1 to AV_CH_LAYOUT_SURROUND was forgotten in the FFmpeg
native aac encoder. This is remedied here.
Signed-off-by: pkv <pkv@obsproject.com>
The `srt_bstats()` function is not guaranteed to zero the stats object
before filling in stats. If a socket was connected, then disconnected,
without any data being sent over it, the stats object would remain
uninitialized, and weird results could occur.
The gain should be positive for an upward compressor. Initially, the
gain would be zeroe'd below -60 dB to ensure noise is not amplified by
the upward compressor. This created a discontinuity at -60 dB since
just above -60 dB, the audio is boosted by +20 dB (at default
settings). This was fixed in commit 50db097 which decreased smoothly
the gain so that it's 0 dB at -60 dB. However that commit forgot to
limit the gain decrease which was negative below -60 dB.
This is fixed by the current commit.
Additionally initialization allowed -inf gain. We hard limit to positive
gains only as they should be for an upward compressor.
The bugfix was found by R1ch and put in form by pkv.
Co-authored-by: pkv <pkv@obsproject.com>
Signed-off-by: pkv <pkv@obsproject.com>
The upward compressor has a -60 dB threshold to stop increasing the
gain. At the threshold, the gain was not continuous, which is not ideal.
Co-authored-by: pkv <pkv@obsproject.com>
Signed-off-by: pkv <pkv@obsproject.com>
PipeWire supports two flags to signal an invalid buffer:
SPA_META_HEADER_FLAG_CORRUPTED signals that the whole buffer is invalid
and should not be used
SPA_CHUNK_FLAG_CORRUPTED signals that one single buffer plane is invalid
Skipping a buffer because of size 0 was moved to only the SHM case.
For DMA-BUFs the size of a single plane is not relevant and should be
ignored [1].
Compatibility note:
GNOME pre 43 sets the chunk size to 0 when a buffer copy failed.
Luckily GNOME doesn't use the META_Header and thus we can detect if we
should use the new or old style of invalid buffer detection.
This workaround should be dropped when reasonable.
[1] https://docs.pipewire.org/page_dma_buf.html
- Don't repeatedly query version at runtime in case a user installs the
SDK while OBS is running
- Restore default DLL search directory
- Don't show outdated SDK message if the SDK is not found
- Protect minimum version macro with brackets
The DAL plugin-based virtualcamera shares data between OBS and the
plugin using an IOSurface. IOSurface locks are necessary to ensure
race conditions between data generation (OBS side) and consumption
(virtual camera side) and also that an IOSurface is not offloaded to
GPU memory when it is indeed needed in CPU memory.
Also moves the invalidation of the NSMachPort for the frames to after
the IOSurface data has been converted into a pixelbuffer and added to
the frame queue of the virtual camera, as an early invalidation will
cut off access to the pixel data shared with the DAL plugin.
Now uses GetIfEntry2 which supports 64-bit values for reporting speed, so
10+ gbps adapters are now reported correctly in the log. Also added an
additional log line if the interface error counters are non-zero to possibly
help identify physical faults. Finally the transmit and receive speeds are
logged independently so that asynchronous mediums such as Wi-Fi that might
have good RX but poor TX can be better diagnosed.
Remove code forcing x264 and ffmpeg aac encoder. People using custom
ffmpeg output should be able to use other video and audio encoders when
streaming with RTMP, given its h264 or aac.
This fixes a bug reported by R1ch internally.
If someone uses NVIDIA noise suppression filter and later uninstalls
the SDK, there can be a crash because the filter tries to load the
models.
Signed-off-by: pkv <pkv@obsproject.com>
Whe using a software renderer there will be no formats available for
using with dmabufs. We should only consider those formats wrt. to
modifiers and as such move this check after adding general support for
that format.
fixes#7985
If the display wasn't found, the timer was not reset, causing the code
to execute on every single tick, stalling the graphics thread and using
excessive CPU.
On systems with multiple graphics adapters, one card can be configured
as power saving, and another card can be configured as performance.
Sometimes, OBS and the encoder test subprocesses will not be configured
the same way, so it's necessary to provide adapter order to the encoder
test subprocesses.
This change ensures the adapter order by passing the LUIDs to the test
subprocesses. The adapter indexes will then be updated accordingly.
This call will fail on multi-adapter systems, and isn't used anyway, so
just remove it. Not sure why it was called in the first place; pretty
sure it was unintended and was likely just copied over from the D3D11
subsystem code.
This fixes a bug where the upward compressor would hard limit above the
threshold.
Also this changes detection to RMS instead of peak for the upward
compressor.
This sounds better than peak (tested on regular mike and a test tone).
Signed-off-by: pkv <pkv@obsproject.com>
Fixes#7848
Currently OBS_OUTPUT_INVALID_STREAM is emitted when a wrong password is
used. This commit expands the signal emission to case of timeouts.
Signed-off-by: pkv <pkv@obsproject.com>
When this detection helper was originally written, it incorrectly set
the hardware implementation value. This fixes it to use the correct one
based upon the index.
Neither the mfxExtMasteringDisplayColourVolumme and
mfxExtContentLightLevelInfo structures appear to be supported when using
AV1, so if using AV1, do not include these structures.
It's unknown as to why AV1 fails to initialize when using either of
these extended structures as part of its configuration parameters.
Either they're completely unsupported or there's a member variable that
causes initialization to fail.
This simplifies encoder initialization and prevents it from requiring
any sort of unnecessary Direct3D or encoder initiazation tests while OBS
is actually running.
The 6.4 runtime rely on Freedesktop 22.08 which provide a more recent
version of Mesa and PipeWire.
The switch to 22.08 also requires to migrate paths of VST 2 plugins.
8985c0f - Add ability to mute individual browser docks/panels
c9d1e37 - Don't use app binary directory for logging
7142b21 - Add ability to directly open Dev Tools for Panels
In updated versions of FFmpeg (5.1.x) and SVT-AV1 (1.2.0/1.3.0), the
rate contol mode selection mechanism has changed, causing CBR to throw
an "Invalid Parameter" error and the encoder will fail to start. This
appears to be caused by us specifying rc_max_rate, which will also fail
on FFmpeg CLI. Adjust how we manage rate control methods, appropriately
version-gated, to work with both our current dependency versions and the
versions that we'd like to use.
(Jim note: The missing description of this commit is that basically, the
CAP_MAX_THROUGHPUT value returns a different result based upon what the
other settings are currently set to. It didn't operate the way it was
originally programmed.)
P6 seems to invoke lookahead, which causes lag for some older GPUs and
interferes with game performance. So let's just use P5 by default for
now. Shouldn't really affect recording anyway.
The index is not reliable. The id persists better, so use that.
Also remove matching against the first monitor if the expected monitor
is not available. That feature seems like a good way to get doxxed by
accident.
This reverts commit bcb73cb599.
Annoyingly, this breaks WebEx, likely due to their own bug. This only
breaks Discord under very specific circumstances due to their own bug,
so if I'm going to choose between Discord breaking under very specific
circumstances that rarely occur versus choosing WebEx not working at
all, I'm going to just let Discord be broken under specific/rare
circumstances.
I hate DirectShow.
Also modifies UI.
This allows the direct use of passphrase (SRT & RIST) used for
encryption, user + password (RIST) as well as streamid (SRT).
Previously, these parameters had to be set in the URL in the form:
URL?option1=value1&option2=value2.
They still can but there is also the option to set them in the stream
key and username/password fields.
SRT:
- the stream_id is set in the stream key (more info on it: [1]);
- the encryption passphrase is set in the password auth field.
RIST:
- the encryption passphrase is set in the stream key;
- the srp_username and srp_password are set in the user/password auth
fields [2].
Additionally, some error logging has been added when there's a
disconnect caused by a wrong password.
Lastly, this solves a bug when auto-reconnect is set and a wrong
passphrase is provided for srt; the output would keep trying to
reconnect. With this commit, an OBS_OUTPUT_INVALID_STREAM signal is
emitted and the stream is immediately stopped.
[1] https://github.com/Haivision/srt/blob/master/docs/features/access-control.md
[2] https://code.videolan.org/rist/librist/-/wikis/Authentication-and-the-ristsrppasswd-Utility
Signed-off-by: pkv <pkv@obsproject.com>
The dynamic increment timeout does not need to be 30 seconds. Change it
to 4 seconds instead to make dynamic bitrate something that people
actually want to use.
SCK has too many open issues on macOS 12 to enable full functionality
on that version. Window Capture has the biggest performance uplift and
so far the least amount of quirks, so leave this variant (with the
"Beta" qualifier) for macOS versions before Ventura.
This adds a slider to set variable mask refresh rate.
This is useful to alleviate the GPU load so that the mask generation
can optionally be done every n frames (n = 1-4).
Signed-off-by: pkv <pkv@obsproject.com>
The AI detection is improved by enabling temporal processing for the
NVIDIA Background Removal filter.
This requires NVIDIA Video Effects version >= 7.1.0.
Fixes issue #7639 (VRR issue with previous sdk versions).
Signed-off-by: pkv <pkv@obsproject.com>
This warns the user if the SDK version is outdated and suggests to
upgrade through a warning in the Properties window of the
filter.
Also removed the label RTX from the logs, just keeping NVIDIA Audio.
Signed-off-by: pkv <pkv@obsproject.com>
This checks if the redistributable for NVIDIA Video FX is the latest.
If it is not, a warning is displayed in the Property window for the
filter.
Also removed the label RTX from the logs, just keeping NVIDIA Video FX.
The NVIDIA Video FX loader has been updated to sdk 7.1.0.
The new functions of the sdk are not loaded though.
Signed-off-by: pkv <pkv@obsproject.com>
This fixes deprecation warnings since the channels member of
AVCodecContext is marked as deprecated [1], as well as the channels
member of AVFrame [2].
In all instances where a warning appear, a switch to the new API is
done.
[1] lavc: switch to the new channel layout API
FFmpeg/FFmpeg@548aeb9
[2] Bump minor versions after the channel layout changes
FFmpeg/FFmpeg@cdba98bb80
Signed-off-by: pkv <pkv@obsproject.com>
The channel_layout API was overhauled by FFmpeg [1-4]. The previous
bitmask channel_layout is replaced by a struct ch_layout which combines
the number of channels, a bitmask and other infos. This struct must now
be supplied to AVframes since avutil >= 57.24.100 and to
AVCodecContext since avcodec 59.24.100 per (1].
This commit provides the required info to obs-ffmpeg-mpegts.
[1] Bump minor versions after the channel layout changes
FFmpeg/FFmpeg@cdba98b
[2] lavc: switch to the new channel layout API
FFmpeg/FFmpeg@548aeb9
[3] avutil/channel_layout: Add a new channel layout API
FFmpeg/FFmpeg@086a804
[4] avframe: switch to the new channel layout API db6efa18
FFmpeg/FFmpeg@db6efa1
Signed-off-by: pkv <pkv@obsproject.com>