Commit Graph

624 Commits

Author SHA1 Message Date
jp9000
a1235f498e Revert "obs-ffmpeg: Check nvenc max bframe count"
This reverts commit a793748743.

Not necessary, there's a better fix with 77fbfbe5c6.
2022-11-01 15:30:35 -07:00
Ryan Foster
f405647419 obs-ffmpeg: Cap NVENC Max B-frames according to GPU caps
Erroring out of NVENC init early if the Max B-frames setting was higher
than the encoder's capability causes an encoder failure on NVIDIA Pascal
(10-series) and earlier GPUs due to an unfortunate interaction between
Simple Output Mode, HEVC, and our default B-frames setting of 2. Since
we already check the Max B-frames capability of the encoder, cap at that
value instead of erroring out.

Fixes #7698.
2022-11-01 15:30:35 -07:00
jp9000
4a938c10c4 obs-ffmpeg: Check nvenc max bframe count
Checks to make sure that the bframe count is equal to or below the
maximum number of bframes that the encoder for the codec supports.

Fixes a bug where setting bframes higher than what the encoder supports
would cause the encoder to not start up properly.
2022-11-01 00:52:06 -07:00
Ryan Foster
c57da834e9 obs-ffmpeg: Split NVENC preset migrations by codec
This commit also modifies UI.
2022-10-31 14:20:21 -07:00
Ryan Foster
eaf0eb95c5 obs-ffmpeg: Align NVENC preset migrations to NVIDIA guidelines
Bring our NVENC preset migrations closer in line with NVIDIA guidelines.

https://docs.nvidia.com/video-technologies/video-codec-sdk/nvenc-preset-migration-guide/

This commit also modifies UI.
2022-10-31 14:20:21 -07:00
Ryan Foster
fd73860167 obs-ffmpeg: Add NVENC preset mapping for old Default preset
The old NVENC preset "Default", labeled in OBS as "Performance", maps to
the new P3 preset when not using multipass. Since we previously only
enabled multipass/two-pass on "Max Quality", we can map this to P3 in
all cases.

This commit also modifies UI.
2022-10-31 14:20:21 -07:00
Ryan Foster
c1178f638b obs-ffmpeg: Swap hq and mq preset order
This is for consistency with b2ff22a587.
Max Quality (mq) is "higher" than Quality (hq), and it's helpful for the
code order to reflect that.
2022-10-31 14:20:21 -07:00
derrod
ebe3311384 obs-ffmpeg: Fix Ubuntu 20.04 detection 2022-10-28 21:36:52 -07:00
Jim
e43fb25051 obs-ffmpeg: Fix FFmpeg NVENC presets on Ubuntu 20.04
Ubuntu 20.04 and 22.04 both have the same FFmpeg versions, but FFmpeg on
20.04 was built with version 9 of NVENC headers, whereas 22.04 was built
with 11.

Unfortunately, that means we have to revert back to the old presets when
Ubuntu 20.04 is detected. The way this detection is done is a bit hacky,
but it's the only way to preserve startup performance. Otherwise we'd
have to write yet another startup subprocess test program to detect
whether the FFmpeg being used was built with older or newer NVENC, which
is both slow to start up and annoying to write. So instead, just get the
distro name/version strings and detect Ubuntu 20.04 that way.
2022-10-28 21:36:52 -07:00
Translation Updater
3b0033a26b Update translations from Crowdin 2022-10-27 14:36:16 -07:00
jp9000
f8299e3739 obs-ffmpeg: Fix NVENC "mq" to use P6 rather than P4 2022-10-19 17:53:25 -07:00
jp9000
e18acb57af obs-ffmpeg: Clarify name of NVENC preset 2022-10-14 16:25:22 -07:00
jp9000
53f4627b0c obs-ffmpeg: Add NVENC AV1 support 2022-10-07 14:34:39 -07:00
jp9000
843fec57be obs-ffmpeg: Fix unpause causing certain encoders to fail
Due to the timeout detection, we need to factor in the current pause
offset to prevent pause from affecting the timeout.

Closes obsproject/obs-studio#7313
2022-09-30 13:09:29 -07:00
shinji3
9d7a6e7e8c obs-ffmpeg: Fix m3u8 recording in AMF 2022-09-29 15:47:26 -07:00
Ryan Foster
c5f1446ab3 obs-ffmpeg: Cap AMF encoder at 100 Mbps
The AMF docs specify that the maximum value for TARGET_BITRATE and
PEAK_BITRATE is 100,000,000 bit/s. Trying to set values above this
maximum value results in AMF choosing from its defaults instead of
capping at the maximum value. Let's cap at 100,000 Kbps in the UI to
prevent users from running in to this.

Fixes GitHub Issue obsproject/obs-studio#7423.
2022-09-24 16:38:17 -07:00
jp9000
3df0c61c8c obs-ffmpeg: Fix when NVENC retries without psycho aq
In obsproject/obs-studio#6963, a crash was fixed when retrying NVENC
without psycho aq. Unfortunately, the code forgot to reinitialize the
session, and thus the retry always failed. This reinitializes the
session as it was likely meant to.
2022-09-22 02:42:32 -07:00
jp9000
3b7f15a046 obs-ffmpeg: Show detailed NVENC error messages 2022-09-22 02:42:32 -07:00
jp9000
6c474fecab obs-ffmpeg: use NvEncGetSequenceParams for NVENC header
The NvEncGetSequenceParams is the function used for extracting the
header, so let's use that rather than manually splitting the packet.
2022-09-22 02:42:32 -07:00
jp9000
b9f562729a obs-ffmpeg: Refactor NVENC defaults/properties
Removes unnecessarily duplicated code
2022-09-22 02:42:32 -07:00
jp9000
d7c7180a8c obs-ffmpeg: Update NVENC to new presets
(This commit also modifies the UI)
2022-09-22 02:42:32 -07:00
jp9000
5c9e620315 obs-ffmpeg: Refactor NVENC
There's a lot of duplicated code, so refactor it
2022-09-22 02:42:32 -07:00
pkv
d0366671e4 obs-ffmpeg: Fix memory leak with mpegts
Fixes #7305.
Some copied data was not freed and also not all paths freed AVPackets.

Signed-off-by: pkv <pkv@obsproject.com>
2022-09-10 15:31:07 -07:00
Richard Stanway
3332beece5 obs-ffmpeg: Fix seek offset being calculated incorrectly
If FFmpeg wrote data and then seeked back to immediately overwrite it,
the second seek would be skipped as our virtual offset was incorrectly
thinking it hadn't changed. This caused MP4 corruption when seeking
back in the file to write the moov atom.

Fixes https://github.com/obsproject/obs-studio/issues/7269
Fixes https://github.com/obsproject/obs-studio/issues/7144
2022-09-03 01:34:14 +02:00
gxalpha
bbd1e8b485 obs-ffmpeg: Always reset timestamp 2022-08-30 22:41:29 -04:00
jp9000
21da0b0462 obs-ffmpeg: NVENC "(new)" begone
It's about time to get rid of this being labeled as "(new)".

Also rename the FFmpeg variant. And make it more explicit when the
FFmpeg encoder is being used in the log file.
2022-08-30 17:05:36 -07:00
Translation Updater
cc2d0791ca Update translations from Crowdin 2022-08-30 09:00:44 +00:00
Richard Stanway
894bc4078b obs-ffmpeg: Log codec when creating NVENC encoders
With HEVC and H264 settings being near-identical, it was impossible to
figure out which codec was being used by context alone. This applies to
both ffmpeg output and jim-nvenc.

Fixes #6976.
2022-08-29 21:43:04 -07:00
jpark37
8f6f761631 obs-ffmpeg: Rename NVENC type for clarity 2022-08-29 20:41:42 -07:00
jpark37
26fce825a7 obs-ffmpeg: Fix NVENC HEVC regression
Forgot to switch enableEncodeAsync to 0.
2022-08-29 20:41:42 -07:00
Norihiro Kamae
f393adb7e6 plugins: Rename Partial to Limited in localization files
The commit 9409ce1ea7 rephrased Limited instead of Partial. Other
plugins should follow the updated phrase.
2022-08-29 10:03:12 -07:00
jpark37
5c85f8ae17 obs-ffmpeg: Add AVContentLightMetadata to MPEG-TS 2022-08-29 10:02:49 -07:00
jpark37
29be9bff7a obs-ffmpeg: Don't use NVENC async mode
Fixes hang on stop presumably because header read failed from being too
early?

Our buffering scheme makes async mode moot anyway.
2022-08-29 10:01:57 -07:00
jpark37
614119db21 obs-ffmpeg: Fix NVENC async usage pattern
Fix async API usage problems reported by NVIDIA.
2022-08-28 17:50:48 -07:00
Jim
2e5f900fe6 obs-ffmpeg: In AMF, use bframe count + 1 as DTS offset
Recommended by Mikhail. Seems to work fine. Should also fix the DTS
regression.
2022-08-27 09:39:46 -07:00
Jim
4c3e671819 obs-ffmpeg: Set max AMF consecutive bframes to 3 by default
The AMF documentation states that this value is recommended to be 3 if
the bframe picture pattern property is a non-zero value.
2022-08-27 09:32:38 -07:00
Chris
7c36cba065 obs-ffmpeg: Change AMF bitrate to kbps
Move multiplication to when its passed to the encoder, so that bitrate
is kept in kbps. Changed for both for H264 and HEVC. Other encoders
(x264 and NVENC) already display bitrate in kbps in the log,
so it makes sense to mimic this with AMF. It's difficult to tell the
exact bitrate with bps.
2022-08-24 05:34:21 -07:00
jp9000
6dc8897e79 obs-ffmpeg: Fix AMF encoder lockup with older AMD cards
This goes back to a slightly older variant of the
SubmitInput/QueryOutput handling that doesn't use AMF's timeout
property. Older devices do not like it when you change the query timeout
on the fly and will lock up. So instead, wait one millisecond when the
AMF input is full, which appears to fix the issue according to testers.

Also adds a loop timeout in case it goes in an infinite loop (which it
shouldn't anymore, but still)

Big thanks to Flaeri for testing the old code, and Yukari for patiently
testing a whole bunch of builds.
2022-08-22 11:20:51 -07:00
Jim
a6c2bb1294 obs-ffmpeg: Use AMD example PTS/DTS offset
All this does is it uses the same exact code AMD uses with their own
example FFmpeg muxer code. Although instead of adding to the PTS, it
subtracts from the DTS.
2022-08-22 11:15:23 -07:00
Jim
9b087d15fc ffmpeg-mux: Do not output error if non-fatal error
Fixes a case where stderr can fill up and cause a freeze on Windows
2022-08-22 03:30:10 -07:00
Jim
d95ebc6294 Revert "ffmpeg-mux: Disable stdout/stderr on Windows"
This reverts commit 332dd00089.
2022-08-22 03:28:38 -07:00
Jim
332dd00089 ffmpeg-mux: Disable stdout/stderr on Windows
These server no purpose unless the ENABLE_FFMPEG_MUX_DEBUG flag is
enabled, and will ultimately just cause problems.
2022-08-22 02:50:17 -07:00
fuyingqi
f5be6f5fdd obs-ffmpeg: Fix ffmpeg_output memory leak
The memory leak was introduced by a commit ba68eda59 to use
av_packet_alloc because av_init_packet got deprecated.

Also removes a boolean flag `new_packet` and use the pointer `packet`,
which is introduced by ba68eda59, to indicate there is a new packet.

Co-authored-by: Norihiro Kamae <norihiro@nagater.net>
2022-08-18 11:07:17 -07:00
Chris
0cc7ed4382 obs-ffmpeg: Add b-frame logging for AMD encoder
Add b-frame value to log for the AMD ENcoder When checking for b-frame
support, also set bf=0 so the log will reflect reality.
2022-08-17 05:38:54 -07:00
Translation Updater
4aaa07f93d Update translations from Crowdin 2022-08-17 04:22:50 +00:00
jpark37
7e6a2ccdec obs-ffmpeg: Prevent invalid NVENC combinations
Don't want to silently generate lossy video.
2022-08-16 21:14:36 -07:00
jpark37
4ffedf877a obs-ffmpeg: Block 8-bit HDR for AV1 encoders
Don't want to silently generate lossy video.
2022-08-16 07:39:52 -07:00
jpark37
eec66e10e3 obs-ffmpeg: Prevent invalid AMF combinations
Don't want to silently generate lossy video.
2022-08-16 07:37:36 -07:00
jpark37
690ba952de obs-ffmpeg: Fix leaks in AMF with unique_ptr 2022-08-16 07:37:36 -07:00
Richard Stanway
dcc79c374d obs-ffmpeg: Fix format specifier in obs-amf-test 2022-08-12 23:05:58 +02:00