Open JazzMusicFan opened 3 years ago
Currently SSR only supports stereo. Supporting surround sound is more complicated than it sounds because there are many different channel layouts, and support varies between formats. I might implement it at some point, but it's not really a high priority for me because so few people have audio sources with more than 2 channels.
Thank you - I certainly understand many SSR use cases wouldn't need >2 channels, although it is a priority for my case. Does your reply mean a single 5.1 layout would be hard for someone (such as myself) to change in the source code, or do you expect it is fundamentally complex even for a single case?
There are two things FFmpeg needs to know: the number of channels and the channel layout (because there are multiple ways to arrange 6 channels). The difficult part for SSR is figuring out what channel layout the source is using, and doing the necessary conversions to map this onto the channel layout used by the audio codec.
If you only want to specifically support 5.1, then you can add this by assuming that all 6-channel sources are 5.1, and making the necessary changes to the source (ALSAInput
, PulseAudioInput
or JACKInput
). You may also have to make some changes to Synchronizer
and AudioEncoder
, but they should be minor. E.g. in AudioEncoder
you probably have to set a channel layout in addition to the channel number in AVCodecContext
to let FFmpeg know what layout you want. Normally the channel layout conversion is handled in Synchronizer
by calling SampleChannelRemap
, a function which is implemented in SampleCast.h
. This currently doesn't actually implement any conversions except mono->stereo and stereo->mono, in other cases it just adds zeros or drops redundant channels. But if you only need a one-to-one mapping (i.e. no downmixing from 5.1 to stereo etc) then it may be good enough.
You should probably also add a GUI option to PageInput to select the preferred channel layout. Currently the preferred layout is hardcoded to stereo in PageRecord (line 566) but this is easy to change.
For a more complete solution, the code would have to be changed to deal not only with the number of channels but also with the chosen channel layout (e.g. to distinguish between 5.1 and 6.0).
Many thanks, Maarten, for providing me this insight into the code for possible enhancements. I am very appreciative of SSR and your time volunteered to help the OSS community use it. I don't expect you to invest time coding changes that aren't seen as a priority for the SSR user base at large, but I'm grateful for help so that I might enable surround output in our specific application (details of which I'd be willing to share with you offline). I will leave this ticket open for now so that I can report progress on the enhancement.
Using a Pulseaudio 5.1 channel source audio stream (confirmed using pavucontrol), SSR always down-mixes the audio to 2-channel stereo, regardless of whether I use vorbis or aac audio encoding. I have attempted to add "Custom options", but any expected command line options for these encoders are "not recognized" by SSR. How can SSR be configured to preserve 5.1 / 6 channel audio in the output file? Thanks in advance for your help.