mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-09-21 12:49:40 +08:00
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
This commit is contained in:
@@ -94,6 +94,21 @@ static inline enum audio_format convert_sample_format(int f)
|
||||
return AUDIO_FORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
static inline enum speaker_layout convert_speaker_layout(uint8_t channels)
|
||||
{
|
||||
switch (channels) {
|
||||
case 0: return SPEAKERS_UNKNOWN;
|
||||
case 1: return SPEAKERS_MONO;
|
||||
case 2: return SPEAKERS_STEREO;
|
||||
case 3: return SPEAKERS_2POINT1;
|
||||
case 4: return SPEAKERS_QUAD;
|
||||
case 5: return SPEAKERS_4POINT1;
|
||||
case 6: return SPEAKERS_5POINT1;
|
||||
case 8: return SPEAKERS_7POINT1;
|
||||
default: return SPEAKERS_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void copy_data(struct ffmpeg_decode *decode, uint8_t *data,
|
||||
size_t size)
|
||||
{
|
||||
@@ -142,7 +157,7 @@ int ffmpeg_decode_audio(struct ffmpeg_decode *decode,
|
||||
audio->data[i] = decode->frame->data[i];
|
||||
|
||||
audio->samples_per_sec = decode->frame->sample_rate;
|
||||
audio->speakers = (enum speaker_layout)decode->decoder->channels;
|
||||
audio->speakers = convert_speaker_layout(decode->decoder->channels);
|
||||
audio->format = convert_sample_format(decode->frame->format);
|
||||
|
||||
audio->frames = decode->frame->nb_samples;
|
||||
|
||||
@@ -403,6 +403,21 @@ static inline audio_format ConvertAudioFormat(AudioFormat format)
|
||||
}
|
||||
}
|
||||
|
||||
static inline enum speaker_layout convert_speaker_layout(uint8_t channels)
|
||||
{
|
||||
switch (channels) {
|
||||
case 0: return SPEAKERS_UNKNOWN;
|
||||
case 1: return SPEAKERS_MONO;
|
||||
case 2: return SPEAKERS_STEREO;
|
||||
case 3: return SPEAKERS_2POINT1;
|
||||
case 4: return SPEAKERS_QUAD;
|
||||
case 5: return SPEAKERS_4POINT1;
|
||||
case 6: return SPEAKERS_5POINT1;
|
||||
case 8: return SPEAKERS_7POINT1;
|
||||
default: return SPEAKERS_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
//#define LOG_ENCODED_VIDEO_TS 1
|
||||
//#define LOG_ENCODED_AUDIO_TS 1
|
||||
|
||||
@@ -559,7 +574,7 @@ void DShowInput::OnAudioData(const AudioConfig &config,
|
||||
return;
|
||||
}
|
||||
|
||||
audio.speakers = (enum speaker_layout)config.channels;
|
||||
audio.speakers = convert_speaker_layout(config.channels);
|
||||
audio.format = ConvertAudioFormat(config.format);
|
||||
audio.samples_per_sec = (uint32_t)config.sampleRate;
|
||||
audio.data[0] = data;
|
||||
|
||||
Reference in New Issue
Block a user