0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 04:42:18 +02:00
Commit Graph

39 Commits

Author SHA1 Message Date
Exeldro
7a35d7c549 obs-ffmpeg: Add logging of audio track 2024-09-12 18:07:19 -04:00
derrod
baa1e1dc35 obs-ffmpeg: Remove compatibility with FFmpeg < 6.1 2024-08-23 13:44:04 -04:00
pkv
06e2b31001 obs-ffmpeg: Fix 7.1 ALAC encoding
Commit [1] added ALAC & PCM support.
But 7.1 ALAC encoding fails.
This fixes the issue by assigning the correct 7.1 layout supported by
FFmpeg ALAC encoder (7.1(wide)).

[1] 3ae98511d0

Signed-off-by: pkv <pkv@obsproject.com>
2024-05-09 10:27:20 -04:00
tt2468
8b6924b80f plugins: Set keyframe flag on encoded audio packets
Not strictly necessary, and does not fix any bug. This just corrects a
nitpick that technically audio encoder packets are start points, but
that they aren't being labeled accordingly as keyframes.
2024-04-13 17:04:48 -07:00
derrod
f083d14143 obs-ffmpeg: Replace circlebuf with deque 2024-01-16 16:45:10 +01:00
derrod
578dc46a79 obs-ffmpeg: Remove legacy FFmpeg compatibility 2023-07-12 15:57:43 -04:00
Lain
106c7aa61f Update copyrights/names 2023-05-20 01:31:18 -07:00
derrod
cf6adf84ab obs-ffmpeg: Fix iteration over sample formats 2023-04-05 21:53:23 +02:00
derrod
c2e66942d0 obs-ffmpeg: Allow specifying audio sample format 2023-04-03 23:37:22 +02:00
derrod
1a51aad582 obs-ffmpeg: Add unclamped 32-bit floating point PCM encoder 2023-03-25 10:38:18 +01:00
derrod
cf837fa38a obs-ffmpeg: Add FLAC encoder 2023-03-25 10:22:45 +01:00
derrod
3ae98511d0 obs-ffmpeg: Add PCM and ALAC encoders 2023-03-25 10:22:45 +01:00
tytan652
1514f1597a plugins: Fix codec name on AAC encoders 2023-03-19 17:27:42 +01:00
Norihiro Kamae
8938aeebfa obs-ffmpeg: Remove an empty clause
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.
2023-03-18 15:16:44 -07:00
Norihiro Kamae
baddacc111 Revert "obs-ffmpeg: Use FFmpeg's "fast" AAC encoder by default"
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.
2023-03-12 10:21:27 -07:00
pkv
ad3df88fe3 obs-ffmpeg: Fix encoding of 2.1 with FFmpeg aac encoder
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>
2023-02-11 15:06:47 -08:00
pkv
ce2d1ffab7 obs-ffmpeg: Fix deprecation of channels member of several structs
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>
2022-11-10 19:37:07 -05:00
tytan652
17ba8359e4 deps,libobs,plugins: Fix discarded-qualifiers warnings with FFmpeg 5 2022-07-22 08:50:36 -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
cdba98bb80
[2] lavc: switch to the new channel layout API
548aeb9383
[3] avutil/channel_layout: Add a new channel layout API
086a804806
[4] avframe: switch to the new channel layout API db6efa18
db6efa1815

Signed-off-by: pkv <pkv@obsproject.com>
2022-05-16 16:17:32 -04:00
wangshaohui
db8145e8a2 obs-ffmpeg, win-dshow, deps/media-playback: Use recommended API for AVCodecContext 2022-04-07 01:59:30 -07:00
Ryan Foster
abf1d609d2 obs-ffmpeg: Include channel_layout.h
avcodec.h stopped including channel_layout.h per FFmpeg commit
1be3d8a0cb77 [1]. avformat.h stopped including avcodec.h per FFmpeg
commit e67e02d15672 [2]. As a result, we need to explicitly include
avutil/channel_layout.h when needed. Fixes compilation error against
FFmpeg later than the two mentioned commits.

[1]: 1be3d8a0cb
[2]: e67e02d156
2021-11-21 11:30:02 -05:00
Richard Stanway
5e3e9c1f13 obs-ffmpeg: Use new encoder error handling functions 2020-04-12 17:05:19 +02:00
jp9000
68a5a40df9 libobs, obs-ffmpeg, win-dshow: Fix FFmpeg 4.0 deprecation
Fixes FFmpeg 4.0 deprecation warnings.
2019-07-29 20:34:13 -07:00
jp9000
f53df7da64 clang-format: Apply formatting
Code submissions have continually suffered from formatting
inconsistencies that constantly have to be addressed.  Using
clang-format simplifies this by making code formatting more consistent,
and allows automation of the code formatting so that maintainers can
focus more on the code itself instead of code formatting.
2019-06-23 23:49:10 -07:00
comex
c54cc0bf5b obs-ffmpeg: fill in more fields on audio frames
After you call av_frame_alloc(), ffmpeg expects you to fill in certain
fields on the frame, depending on whether it's an audio or video frame.
obs-ffmpeg did this in the two places where it allocates video frames,
but not where it allocates audio frames.  On my system, using trunk
ffmpeg and the Opus codec, this causes OBS to crash while calling
avcodec_send_frame, ultimately because av_frame_copy fails due to
'dst->format < 0' (as 'format' stays at the default of -1), causing a
null pointer to be added to a buffer queue, which later gets
dereferenced.

Oddly, the fields in question can just be copied directly from
corresponding fields in the AVCodecContext, but I don't see any ffmpeg
API to automatically copy all relevant fields, and all the examples I've
seen do it by hand.  So this patch does the same.
2018-04-18 13:13:48 -07:00
jp9000
aa58b9cf5f obs-ffmpeg: Use FFmpeg's "fast" AAC encoder by default
FFmpeg has recently made their "fast" AAC encoder the default, which
uses less CPU and sounds better at common bitrates.
2018-02-26 00:11:30 -08:00
jp9000
a89470d2ea obs-ffmpeg: Remove cutoff hack for AAC encoder
The cutoff hack was added many, many years ago as recommended by
Konverter.  Since then, there has been much work on the AAC encoder, so
this hack should no longer be necessary.
2018-02-25 23:50:09 -08:00
pkviet
645d6ae8dd libobs/media-io: Change speaker layout to match FFmpeg aac.
(This commit also modifies the obs-ffmpeg module)

The default channel layouts from aac spec are implemented in FFmpeg
native aac encoder as follows:

    AV_CH_LAYOUT_MONO,
    AV_CH_LAYOUT_STEREO,
    AV_CH_LAYOUT_SURROUND,
    AV_CH_LAYOUT_4POINT0,
    AV_CH_LAYOUT_5POINT0_BACK,
    AV_CH_LAYOUT_5POINT1_BACK,
    AV_CH_LAYOUT_7POINT1,

The correspondence of speaker layouts to AV_CH_LAYOUT from FFmpeg is
changed to reflect the previous table.

Although FFmpeg native aac encoder can now encode all the layouts listed
in avutil channel_layout.h (on master), there might be issues with older
FFmpeg binaries.

Note that 2.1 speaker layout will be encoded as AV_CH_LAYOUT_SURROUND
(FL FR FC) because it is not listed as the default layout for three
channels.

This just means some optimizations for LFE channel will not be used by
the encoder which will treat it as an SCE (single channel element).

Closes jp9000/obs-studio#1182
2018-02-06 06:14:24 -08:00
pkviet
67e48ecc2c libobs/media-io: Replace quad with 4.0
(also obs, deps/media-playback, libobs/audio-monitoring, decklink,
linux-alsa, linux-pulseaudio, mac-capture, obs-ffmpeg, win-dshow,
win-wasapi)

Default channel layout for 4 channels is 4.0 in FFmpeg.
Replacing quad with 4.0 will improve compatibility since FFmpeg has
better support of its default channel layouts.
2018-01-05 09:48:52 -08:00
pkviet
fb580535c9 libobs/media-io: Clean surround API
(also modifies obs-ffmpeg, audio-monitoring, win-wasapi, decklink,
obs-outputs)

Removes speaker layouts which are not exposed in UI.  The speaker
layouts selectable by users in the UI are the most common ones.  It is
not necessary to keep other layouts.  (This basically removes
5POINT1_SURROUND, 7POINT1_SURROUND, SURROUND =3.0).
2018-01-05 09:47:59 -08:00
jp9000
0497095f97 Fix a number of GCC warnings 2017-12-06 16:42:45 -08:00
jp9000
0d6204c8af Fix a number of MSVC warnings
Fixes a number of warnings with all modules
2017-12-05 13:53:44 -08:00
pkviet
bbac3280c1 libobs: Add surround sound audio support
(This commit also modifies the following modules: UI,
deps/media-playback, coreaudio-encoder, decklink, linux-alsa,
linux-pulseaudio, mac-capture, obs-ffmpeg, obs-filters, obs-libfdk,
obs-outputs, win-dshow, and win-wasapi)

Adds surround sound audio support to the core, core plugins, and user
interface.

Compatible streaming services: Twitch, FB 360 live
Compatible protocols: rtmp / mpeg-ts tcp udp
Compatible file formats: mkv mp4 ts  (others untested)
Compatible codecs: ffmpeg aac, fdk_aac, CoreAudio aac,
		   opus, vorbis, pcm (others untested).
Tested streaming servers: wowza, nginx
	 HLS, mpeg-dash : surround passthrough
Html5 players tested with live surround:
	 videojs, mediaelement, viblast (hls+dash), hls.js
Decklink: on win32, swap channels order for 5.1 7.1
         (due to different channel mapping on wav, mpeg, ffmpeg)
Audio filters: surround working.
Monitoring: surround working (win macOs linux (pulse-audio)).
VST:	 stereo plugins keep in general only the first two channels.
	 surround plugins should work (e.g. mcfx does).
OS: win, macOs, linux (alsa, pulse-audio).
Misc: larger audio bitrates unlocked to accommodate more channels
NB: mf-aac only supports mono and stereo + 5.1 on win 10
         (not implemented due to lack of usefulness)

Closes jp9000/obs-studio#968
2017-11-26 03:41:53 -08:00
pkviet
d670d7badb libobs: Fix FFmpeg constants
(This commit also modifies the deps/media-playback, obs-ffmpeg, and
win-dshow modules)

More fixes due to ffmpeg renaming some constants and deprecating
AVFMT_RAWPICTURE and AV_PIX_FMT_VDA_VLD.
Latter replaced by AV_PIX_FMT_VIDEOTOOLBOX per ffmpeg dev advice.

Closes jp9000/obs-studio#1061
2017-11-16 21:38:37 -08:00
Richard Stanway
95f20c84ba obs-ffmpeg: Use new ffmpeg constants 2017-10-26 19:17:53 +02:00
jp9000
fa611dcd76 obs-ffmpeg: Add Opus audio encoder 2017-08-01 02:14:58 -07:00
jp9000
d2ffd0fdd2 obs-ffmpeg: Ensure sample rate is supported in audio encoder
Ensures that the sample rate is supported in the audio encoders, and if
not, then make it automatically resample to the closest sample rate.
2017-07-31 14:51:21 -07:00
jp9000
0089d379b0 obs-ffmpeg: Make FFmpeg audio encoder abstractable
Abstracts the FFmpeg audio encoder to allow other codecs to use the same
code, and makes the AAC encoder derived from it.
2017-07-31 14:48:20 -07:00
jp9000
58c4f0ac91 obs-ffmpeg: Rename obs-ffmpeg-aac.c file
Renames obs-ffmpeg-aac.c to obs-ffmpeg-audio-encoders.c due to the fact
that it can be abstracted for multiple audio encoders.
2017-07-31 14:29:50 -07:00