Commit Graph
555 Commits
Author SHA1 Message Date
jpark37 a4083c56b5 obs-ffmpeg: Use top-left chroma location for HDR
As specified in the HEVC spec. VLC now reports top-left instead of left.
2022-07-31 00:10:50 -07:00
Kurt Kartaltepe 8cb57aac1f obs-ffmpeg: Mark rist/srt required
When compiling with the new flag these are required, if we dont fail
here we instead get a more cryptic failure that the targets are
unassigned later in the file. This should make it easier to find the
flag to turn off or packages being searched for.
2022-07-30 20:33:54 -07:00
pkv 039d7347a3 obs-ffmpeg: Allow use of old mpegts output
By default, new mpegts output is used; but to allow CI on linux not
to be broken, we allow use of old mpegts output.
Up to ubuntu 22.04 there is no librist package available.
A manual compile is then required but the CI scripts would need to be
updated.
This also allows easy fallback in case of fatal bugs in new output.

Signed-off-by: pkv <pkv@obsproject.com>
2022-07-30 17:03:20 +02:00
pkv e7d097cab8 obs-ffmpeg: Native SRT/RIST for mpegts output
Currently the ffmpeg_mpegts_muxer output is integrated with ffmpeg-mux.
Both use obs native encoders in contrast with obs-ffmpeg-output which
relies on avcodec library.
This allowed easy implementation of SRT, RIST & HLS protocols through
avformat library.
The main drawback is that obs-ffmpeg-mux exe doesn't allow for easy
debugging nor logging of the protocols.
It was written initially as a separate binary designed for recording so
that if obs fails for some reason, the recording can still terminate
gracefully.

In this commit the ffmpeg_mpegts_muxer is rewritten so that a pipe to
the ffmpeg-mux binary is not used any more.
The muxing to mpegts is still delegated to avformat.
But it can be traced more easily in all its steps.
Also the protocol part for SRT & RIST is implemented natively.
Custom avio_contexts for SRT & RIST are used to that end.
This allows to pass our own implementation of librist and libsrt
libraries instead of relying on avformat. This is very advantageous :
- this allows better logging.
- this allows better bug fixing and maintainance without having to rely
on hypothetical upstream fixes.

One immediate bonus of native implementation is that fixes bugs which
were not previously fixable.

Fixes: SRT & RIST auto-reconnect partly broken  #6749
Fixes: SRT: OBS unusable and uncloseable after starting stream to
invalid srt server #5791

Signed-off-by: pkv <pkv@obsproject.com>
2022-07-30 17:03:10 +02:00
gxalpha 8fd2f164b7 obs-ffmpeg: Enable file splitting with obs_data directly
Also modifies UI accordingly.

This can enable file splitting even if no time or storage limit is set.
2022-07-30 15:21:08 +02:00
gxalpha ae3c9b3628 obs-ffmpeg: Add proc handler for manual file splitting 2022-07-30 18:50:13 +10:00
jpark37 5ae7a92101 obs-ffmpeg: Set MaxCLL/MaxFALL for AMF 2022-07-29 23:23:25 -07:00
tududweb 07b0786892 obs-ffmpeg: Fix frame remain after changing file
After changing the media source from video file to audio file,
the last video's frame (preloaded) maybe still rendered.

This commit ensures that when media source changed to
another one without video, clean the source's video output,
by simply add judgement to check whether the media has video.
2022-07-28 11:33:02 -07:00
jp9000 b23fd86822 obs-ffmpeg: Add HEVC to supported HLS codecs 2022-07-26 09:23:35 -07:00
jp9000 f6f6690ccf obs-ffmpeg: Fix AMD falling back to wrong preset
If the API to query the maximum throughput isn't available, it was
intended to fall back to balanced. This code caused it to vall back to
speed instead because if the API isn't available, max_throughput will be
0. This fixes it to make it only fall back to balanced instead.
2022-07-24 11:18:18 -07:00
tytan652 17ba8359e4 deps,libobs,plugins: Fix discarded-qualifiers warnings with FFmpeg 5 2022-07-22 08:50:36 -04:00
Vainock eb06594381 Use property suffixes for units everywhere 2022-07-22 08:24:51 -04:00
Richard Stanway 88226db6b3 obs-ffmpeg: Fix AMF AVC / HEVC check logic 2022-07-22 00:45:34 +02:00
OvchinnikovDmitriiandJim 4e140d2ffe obs-ffmpeg: Add texture-based hardware AMD encoder
Adds support for texture-based AMD encoding, with both H264, HEVC, and
HDR support. Falls back to FFmpeg when texture-based encoding cannot be
used for whatever reason.

(Jim note: This is based upon obsproject/obs-studio#4538 by AMD/Luxoft
with fewer files, FFmpeg fallback for software encoding, and HDR
support. I also went to lengths to ensure that FFmpeg command line
parameters also works with it)

Co-authored-by: Jim <obs.jim@gmail.com>
2022-07-21 15:29:25 -07:00
tytan652 fcc94634d9 obs-ffmpeg: Remove unused parameter 2022-07-20 08:22:04 +02:00
Norihiro Kamae 7e3656ab33 plugins: Cleanup unused-parameters
- Remove unnecessary UNUSED_PARAMETER
- Add OBS_UNUSED attribute to unused parameters
- Also removes unused variables
2022-07-19 11:01:00 -04:00
jpark37 5738f63549 obs-ffmpeg: Fix type mismatch 2022-07-18 03:52:04 -07:00
jpark37 9f0769cc82 obs-ffmpeg: Suppress NVENC preset warnings for now
Top men are working on upgrading the presets.
2022-07-18 03:52:04 -07:00
jpark37 8bb03a1136 obs-ffmpeg: Fix warning about useless llabs call 2022-07-11 22:07:10 -07:00
PatTheMav 62c6a6d223 obs_ffmpeg: Explicitly mark variables as unused 2022-07-10 09:59:55 +10:00
PatTheMav 3f2aad12cd obs-ffmpeg: Disable compiler warnings about non-exhaustive switch cases 2022-07-10 09:59:55 +10:00
pkv b9237aed29 obs-ffmpeg: Fix srt/rist not working
This fixes a bug where the new circular buffer code is hit by protocols
such as rist or srt although the buffer was meant for files.

Signed-off-by: pkv <pkv@obsproject.com>
2022-07-09 16:29:04 -07:00
MagicBear f54f8ee714 obs-ffmpeg: Add NVIDIA Tesla NVENC support 2022-07-09 15:49:26 -07:00
mvji 16f5fe5ee2 obs-ffmpeg: Add m4v extension to open file dialog 2022-07-09 13:45:29 -04:00
Richard Stanway 17c39ccb07 obs-ffmpeg, obs-outputs: Check return of obs_encoder_get_extra_data
A race condition can occur in obs-outputs where the send_thread is in
the process of (re)connecting but the encoder was shut down in the
meantime. This causes the expected header data to be garbage, resulting
in a crash.
2022-06-25 16:03:12 -07:00
tytan652 6cc7cf3d55 obs-ffmpeg: Remove codec property from VAAPI encoder
Encoders have only one codec so this property is not needed.

Also rename the encoder to "FFMPEG VAAPI H.264".
2022-06-11 16:09:11 -07:00
Richard Stanway 898256d416 obs-ffmpeg: Add a circlebuf to buffer output in ffmpeg-mux
This adds a circular buffer to ffmpeg-mux when writing to a file.
Output from ffmpeg is buffered so that slow disk I/O does not block
ffmpeg writes, as this causes the pipe to become full and OBS stops
sending frames with a misleading "Encoding overloaded!" warning. The
buffer may grow to 256 MB depending on the rate of data coming in and
out, if the buffer is full OBS will start waiting in ffmpeg writes.

A separate I/O thread is responsible for processing the contents of
the buffer and writing them to the output file. It tries to process 1 MB
at a time to minimize small I/O.

Complicating things considerably, some formats in ffmpeg require seeking
on the output, so we can't just treat everything as a stream of bytes.
To handle this, we record offsets of each write and try to buffer as
many contiguous writes as possible. This unfortunately makes the code
quite complicated, but hopefully well commented.
2022-05-30 10:06:09 -07:00
jpark37 f1e0844a58 obs-ffmpeg: Use period for localized sentences 2022-05-28 18:31:55 -04:00
jpark37 f21ea744f8 obs-ffmpeg: Localize NVENC error dialog messages
Localize messages for lack of 10-bit support, and exceeding the hardware
B-frame limit.
2022-05-28 08:36:18 -07:00
jpark37 699e89d859 obs-ffmpeg: Improve dialog text for NVENC errors
Add dialog messages for lack of 10-bit support, and exceeding the
hardware B-frame limit. Also move code around to test these just once.
2022-05-28 06:48:27 -07:00
gxalpha bfa7f1a88e obs-ffmpeg: Remove duplicate "FFmpeg Options" locale 2022-05-21 15:45:17 -07:00
Torge Matthies 5ac6c03a8a obs-ffmpeg: Initialize mapped_res field in nv_texture_init
Otherwise it might never be initialized and nv_texture_free might unmap
a non-existant resource.
2022-05-19 16:36:14 -07:00
Torge Matthies fe776a83eb obs-ffmpeg: Reserve jim-nvenc textures buffer space
Textures dynamic array buffer space was not reserved.
2022-05-19 16:36:14 -07:00
Matt Gajownik 73e6df5d09 obs-ffmpeg: Fix memory leak 2022-05-17 23:13:17 +10:00
jpark37 d70c6b9dfb obs-ffmpeg: Set 1000 nits for HLG metadata 2022-05-17 05:18:46 -07:00
pkv 12d1f1c335 obs-ffmpeg: Fix 4 channel layout in ffmpeg-mux
Previously SPEAKER_4POINT0 was assigned to AV_CH_LAYOUT_QUAD, but later
was changed to AV_CH_LAYOUT_4POINT0 [1]. The change was forgotten in
obs-ffmpeg-mux. This is remedied here.
[1] https://github.com/obsproject/obs-studio/commit/67e48ecc2ca033020210f3aae05617195d37e248

Signed-off-by: pkv <pkv@obsproject.com>
2022-05-16 16:17:32 -04:00
pkv 5b6cc73c24 obs-ffmpeg: Fix for channel layout API change
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 ffmpeg-mux,
obs-ffmpeg-output & to obs-ffmpeg-audio-encoders.

[1] Bump minor versions after the channel layout changes
https://github.com/FFmpeg/FFmpeg/commit/cdba98bb80e2ab73d34659c610771b020afc6a77
[2] lavc: switch to the new channel layout API
https://github.com/FFmpeg/FFmpeg/commit/548aeb93834b8425c86d1ce60fddc1d41805724d
[3] avutil/channel_layout: Add a new channel layout API
https://github.com/FFmpeg/FFmpeg/commit/086a8048061bf9fb4c63943f6962db48175f655c
[4] avframe: switch to the new channel layout API db6efa18
https://github.com/FFmpeg/FFmpeg/commit/db6efa1815e217ed76f39aee8b15ee5c64698537

Signed-off-by: pkv <pkv@obsproject.com>
2022-05-16 16:17:32 -04:00
stopforumspam 035ac5e3b7 obs-ffmpeg: Allow setting FFmpeg options for media sources 2022-05-16 15:17:13 -04:00
tytan652 0c33069772 obs-ffmpeg: Fix HEVC include in jim-nvenc 2022-05-07 16:13:21 -07:00
Richard Stanway 8bd4ef61a0 obs-ffmpeg: Change types to avoid unnecessary casts 2022-05-07 16:01:48 +02:00
jpark37 5ee5a8e1d4 obs-ffmpeg: Log/fail NVENC for B-frame maximum
Check NV_ENC_CAPS_NUM_MAX_BFRAMES to avoid exceeding the GPU limit.
2022-05-07 01:33:05 -07:00
jpark37 e74dc0dfe3 obs-ffmpeg: Default NVENC HEVC Max B-frames to 0
All NVENC cards support H.264 B-frames, but Turing is the first
generation to support HEVC B-frames.
2022-05-07 01:33:05 -07:00
jpark37 79059153e8 obs-ffmpeg: Fix old NVENC ignoring Max B-frames 2022-05-07 01:33:05 -07:00
jpark37 e513d1cb6b obs-ffmpeg: Fix NVENC HEVC fallback being H.264 2022-05-04 23:54:53 -07:00
Jim 952988d9ec Merge pull request #6231 from mvji/prores_pix_fmt
Add support for GPU conversion of YUV422P10LE, YUV444P12LE, YUVA444P12LE
2022-05-04 02:01:27 -07:00
tytan652 ce62240530 obs-ffmpeg: Fix compiler warnings
* obs-ffmpeg: Fix format-overflow warning

* obs-ffmpeg: Fix unused-parameter warnings
2022-05-04 01:37:10 -07:00
jpark37 80f6cff742 obs-ffmpeg: Add content light levels for HDR
YouTube wants it, and more metadata can only improve compatibility.
2022-04-30 16:05:01 -07:00
jpark37 9677ad1876 obs-ffmpeg: Add I010/P010 as formats for old NVENC
Avoids fallback to NV12, crushing 10-bit into 8-bit.
2022-04-29 12:34:56 -07:00
jpark37 01a806cb53 obs-ffmpeg: Add HEVC support to NVENC 2022-04-28 08:59:53 -07:00
Jim 3883c9e120 cmake: Add option to build hardware HEVC encoders
Allows the ability to enable HEVC encoders whenever we add them.
Disabled by default for now for obvious reasons.
2022-04-22 17:39:43 -07:00