Commit Graph

601 Commits (master)

Author SHA1 Message Date
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
jp9000 2c43ca1dc6 obs-ffmpeg: Add b-frame option to AMF encoder 2022-08-10 02:20:11 -07:00
derrod 9c20ad9046 obs-ffmpeg: Set NVENC CQP maximum to 51
51 is the actual maximum and especially with HEVC values higher than 30
are actually pretty usable.
2022-08-08 09:24:08 +02:00
Chris f5fe4d0acf obs-ffmpeg: Fix USAGE typo
Replace TRANSCONDING with TRANSCODING, because it is likely that the
typo compatibility will be removed in a future AMF header update. This
should also minimize confusion and improve search.
2022-08-06 20:02:48 -04:00
tududweb 9780d2f596 obs-ffmpeg: Remove unused variables for NVENC 2022-08-06 16:45:31 -07:00
tududweb e16f336882 obs-ffmpeg: Reinit before retrying init for NVENC 2022-08-06 16:45:31 -07:00
tududweb 6c364f78cf obs-ffmpeg: Correctly assign argument for NVENC
When retrying again without Psycho Visual Tuning,
the argument psycho_aq should be false.
2022-08-06 16:45:31 -07:00
tytan652 d71878cd35 obs-ffmpeg: Add better error if SRT or RIST libraries are not found 2022-08-06 16:18:55 -07:00
Vainock e6a03be487 obs-ffmpeg, obs-transitions: Use property suffixes 2022-08-06 10:23:26 +10:00
Richard Stanway 8ab6fffec4 obs-amf-test: Add 2.5 second timeout for AMF test process
If the test process freezes for whatever reason, OBS would block
indefinitely on reading the pipe. This commit adds a 2.5 second timeout
on the AMF test process after which it will self-terminate.
2022-08-01 13:34:27 -07:00
Richard Stanway 68415fa08f obs-ffmpeg: Throw on invalid amf_format 2022-08-01 13:34:27 -07:00
Richard Stanway ac025b51ac obs-ffmpeg: Use get_buf function to ensure buffers_mutex is locked 2022-08-01 13:34:27 -07:00
Richard Stanway 2e8b8c5ae1 obs-ffmpeg: Fix typo in min_qp_p / max_qp_p options
Detected by PVS Studio.
2022-08-01 13:34:27 -07:00
Richard Stanway 00408b6b3b obs-ffmpeg: Don't load AMF DLL before amf-test
In the event that simply loading the AMF DLL causes initialization code
to run that might crash, don't load the DLL before the AMF test process
has succeeded. Instead, we load the DLL as data to see if it exists,
then run the AMF test, then load the DLL for real.
2022-08-01 13:34:27 -07:00
jpark37 3d18643088 obs-ffmpeg: Use new priority parsing for HLS
Parsing priority while serializing/discarding packet data is too gross.
2022-08-01 08:15:39 -07:00
tytan652 9d0c48af33 obs-ffmpeg: Fix incompatible-pointer-types warning 2022-07-31 21:48:13 -07:00
tytan652 4303e31268 obs-ffmpeg: Replace ftime on *nix platforms
ftime is deprecated on newer version of glibc.
2022-07-31 21:48:13 -07:00
jpark37 a34439aecc obs-ffmpeg: Make muxers respect ENABLE_HEVC
The encoded_video_codecs field doesn't seem to be used though.

Also update HDR luminance to match pattern.
2022-07-31 21:46:17 -07:00
jpark37 2a1b047d33 obs-ffmpeg: Implement priority for HEVC over HLS 2022-07-31 17:42:53 -07:00
Translation Updater 81734be37c Update translations from Crowdin 2022-07-31 23:40:53 +00:00
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