Fixes issue #10369.
Since the update to FFmpeg 6.1, streams to a Media Source are broken
if hardware decoding is enabled (both RTMP or SRT have been reported).
The video is black although the audio is decoded fine.
The manual copy of metadata introduced in commit [1] does not work any
more for some unfathomable reasons.
As a fix we call instead the av_frame_copy_props function used in FFmpeg
app in a similar context (hardware decoding) [2].
The metadata are copied without issues.
There is no need to guard the use of that function since it was
introduced 9 years ago in avutil/frame.c.
[1] 22fde5cdcd
[2] https://github.com/FFmpeg/FFmpeg/master/fftools/ffmpeg_dec.c
Signed-off-by: pkv <pkv@obsproject.com>
The optimization silences the warning about type limits on platforms
with `char` type as `unsigned char`.
The original condition is semantically identical to the optimized one
because the signed-to-unsigned cast is well-defined in C standard.
Inlined functions in Python's header files result in unresolvable
symbols at link time when building in Debug config on Windows.
This downgrades the upper limit on Windows to 3.10 again until a proper
fix can be found.
macOS is unaffected because it can link binaries with dynamic runtime
lookup.
Prior code would not only iterate over possible versioned python DLL
names, but also replace possible named subdirectories contained in the
path string.
This commit changes the same code to only change the filename and leave
the path prefix intact.
Fixes for using FFmpeg 6.1 due to deprecations. Uses `#if` macros to
allow builds for using older versions of FFmpeg.
AVFrame.key_frame was replaced with a flag in AVFrame.flags. The commit
adding the flag is [1] in FFmpeg's repository, and the deprecation is in
commit [2].
In summary of the "key_frame" change, AVFrame.key_frame is deprecated,
and AVFrame.flags indicates with a bit flag if it is a key frame (with
the enum/defined AV_FRAME_FLAG_KEY).
[1]: avutil/frame: add a keyframe flag to AVFrame
cc11191fda
[2]: avutil/frame: deprecate key_frame
3e06f6f040
Fixes for using FFmpeg 6.1 due to deprecations. Uses `#if` macros to
allow builds for using older versions of FFmpeg.
The change in deps/media-playback/media-playback/decode.c is due to
FFmpeg moving "side_data" into AVCodecParameters which is mentioned in
commit [1] in FFmpeg's repository.
In summary of the "side_data" change, AVStream.side_data is deprecated
and replaced with AVStream.codecpar->coded_side_data, and
AVStream.nb_side_data is replaced with
AVStream.codecpar->nb_coded_side_data.
[1]: avcodec/codec_par: add side data to AVCodecParameters
21d7cc6fa9
Python automatically creates bytecode caches which end up inside the
application bundle of OBS Studio on macOS. These directories will lead
to a hash mismatch when Sparkle attempts to apply a delta update (to
ensure that the patch can be applied).
As the added directories will make the hash check fail, having a valid
Python framework configured in OBS Studio (even without any script
added) will thus prevent Sparkle from using delta updates.
This commit adds a utility to connect to a TCP endpoint that may
be dual-stack IPv4/IPv6 using fast fallback. It will attempt the
prefered address family first, followed by the other 200ms later.
The first to connect will be the socket that is handed back
to the caller.
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.
clang expects an empty prototype to explicitly use `void`.
Also silences the warning in `libobs-opengl`, `obsglad`, `caption`,
`mac-syphon` and `obs-x264-test`.
Adds a check to make sure that delayed preload is ignored if the stinger
is restarted/interrupted. Just adds this check to the previous commit to
make sure that it doesn't redundantly try to preload a frame when
playback is restarted.
The `mp_media::obsframe` varaible is a variable used to store the
current frame, or the first frame on stop. However, it's never cleared,
and while decoding a frame, it's invalid. The variable was added for
delayed preloading of the first frame for stingers.
Now, for more context, when media sources stop, it stores the first
frame of the video so it can set the source's current async texture to
that frame, effectively preloading the first frame into the backend,
making it so that when you play back that media, it's able to start
playback instantly without having to wait for the thread to play back
that frame, causing seamless playback.
Normally, preload happens right when first frame is finished decoding,
thus it wasn't a problem before these variables and delayed preloading
was added. However, with stingers, I delayed that preload further
because stingers are kind of a special case because the stinger does not
clear itself right away on stop. Because of that, it was causing it to
flash the first frame at the end of the stinger. This is why `obsframe`
and `request_preload` were added: it's a way of signaling the media
source to preload the first frame when the stinger itself is fully
completed. It was added to fix that stinger bug.
However, if the user interrupts playback of the stinger (e.g. swaps to
another scene while in the middle of the transition), that
`request_preload` might still be queued and happen while the media
source is still decoding, and thus, while `obsframe` is invalid.
I realize that we should probably refactor and clean up the
media-playback lib.
Instead of using a non-debuggable macro function, keep function
references and desired function names in a static array that can then
be iterated over to add desired functions.
This allows for proper debugging as well as makes the combination of
function and function name more explicit.
It's possible that frame_ready is false when this function is called,
which implies that the mp_decode frame field is not valid. However we
dereference the frame by counting the number of audio channels before
checking the value of frame_ready, causing a crash.
Every time a media player instance would be initialized, it would
create a new `Set FFmpeg options:` log message. With lots of looping
media sources, this gets incredibly spammy. It's already being logged
by the media source itself, so this line is pretty much unnecessary.