Comments (14)
Maybe a --discrete
switch would make sense for this? Note that setting the channel mapping to 255 we prevent audio playback in most software; it's intended for use by DAW software which is used to handling unmixed audio.
I would expect a --no-coupling
option to still use stereo, but prevent any coupling between them, so normal playback would work. Looks like this could call opus_multistream_encoder_create()
instead of opus_multistream_surround_encoder_create()
for the necessary control.
from opus-tools.
Well, we can choose --discrete
flag, but imo --no-coupling
a bit more descriptive one.
Hmm, should I call opus_multistream_encoder_create
with channels=2,streams=1,coupled=0
?
This seems wrong as it will lead to validate_layout()
error.
Calling that with channels=2,streams=2,coupled=0
seems the same as calling opus_multistream_surround_encoder_create()
with header.channel_mapping=255
.
I also do not see any difference in mediainfo output or player (AIMP) behaviour.
Am I wrong?
Sorry, I am not familiar with Opus codebase, so maybe my questions are a bit stupid =)
from opus-tools.
You're right. I was thinking opus_multistream_surround_encoder_create()
would propagate the mapping_family
argument into the file header, but it only uses it to set up channel coupling and tweak some encoder parameters, then discards the value. It's opusenc.c that writes the actual value into the file header. So passing channels = 2
, streams = 2
, 'coupled = 0or creating a surround encoder with that and
channel_mapping = 255` should be the same.
What I was trying to get out is that there's a semantic difference between opusenc actually writing header.channel_mapping = 255
into the .opus file header (discrete channels) and writing header.channel_mapping = 2
(left/right stereo, which just happen to be uncoupled).
from opus-tools.
According to https://wiki.xiph.org/OggOpus, there is no reason to set header's channel mapping to 2, as
The remaining channel mapping families (2...254) are reserved. A decoder encountering a reserved mapping byte should act as though the mapping byte is 255.
Well, we can set it to 2, but who knows how it will be used in future.
from opus-tools.
Sorry, I meant header.channel_mapping = 1
, which is different from 255, unlike 2.
from opus-tools.
Sorry, I did not forgot about this, just didnt have enough time :(
from opus-tools.
Sorry to resurrect an old issue, but the proposed flag would be perfect for my use case of encoding multiple independent channels from a DAW for playback in a custom player. I exported the multichannel mix as WAV but opusenc offers no control over the channel mapping via command line switches. I see the codec is designed to handle my scenario but the tools are not.
I'm frankly getting tired of audio tools presuming surround configurations based solely on the channel counts. Just because I'm exporting an 8 channel WAV does not mean it's a 7.1 surround mix. Sure it can be default as that's low friction for most users but at least allow for customization and control.
I plan to make a PR of my own to address the issue but it will take some time.
from opus-tools.
Sorry for not doing this myself :(
Here is what I use; adapted just now to current HEAD, hope it still works;
Maybe, this will be useful for your PR.
From 9993b87e9c9635588796d3a2753c693c8d27e4f5 Mon Sep 17 00:00:00 2001
From: "World.exe" <>
Date: Wed, 1 Nov 2017 19:12:35 +0300
Subject: [PATCH] Adding force channel decoupling.
---
src/opusenc.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/opusenc.c b/src/opusenc.c
index 129dcdb..2901298 100644
--- a/src/opusenc.c
+++ b/src/opusenc.c
@@ -136,6 +136,7 @@ void usage(void)
printf(" --framesize n Set maximum frame size in milliseconds\n");
printf(" (2.5, 5, 10, 20, 40, 60, default: 20)\n");
printf(" --expect-loss Set expected packet loss in percent (default: 0)\n");
+ printf(" --no-coupling Force disable channel coupling\n");
printf(" --downmix-mono Downmix to mono\n");
printf(" --downmix-stereo Downmix to stereo (if >2 channels)\n");
printf(" --max-delay n Set maximum container delay in milliseconds\n");
@@ -345,6 +346,8 @@ int main(int argc, char **argv)
int comment_padding=512;
int serialno;
opus_int32 lookahead=0;
+ int no_coupling=0;
+
#ifdef WIN_UNICODE
int argc_utf8;
char **argv_utf8;
@@ -577,6 +580,8 @@ int main(int argc, char **argv)
inopt.copy_pictures=0;
} else if(strcmp(long_options[option_index].name,"discard-pictures")==0){
inopt.copy_pictures=0;
+ } else if(strcmp(long_options[option_index].name,"no-coupling")==0){
+ no_coupling=1;
}
/*Commands whose arguments would leak file paths or just end up as metadata
should have save_cmd=0; to prevent them from being saved in the
@@ -698,6 +703,10 @@ int main(int argc, char **argv)
/*Initialize Opus encoder*/
/*Frame sizes <10ms can only use the MDCT modes, so we switch on RESTRICTED_LOWDELAY
to save the extra 4ms of codec lookahead when we'll be using only small frames.*/
+ if(no_coupling){
+ header.channel_mapping=255;
+ }
+
st=opus_multistream_surround_encoder_create(coding_rate, chan, header.channel_mapping, &header.nb_streams, &header.nb_coupled,
header.stream_map, frame_size<480/(48000/coding_rate)?OPUS_APPLICATION_RESTRICTED_LOWDELAY:OPUS_APPLICATION_AUDIO, &ret);
if(ret!=OPUS_OK){
--
1.9.5.msysgit.1
from opus-tools.
@Worldexe I've just completed something similar albeit more flexible on my fork.
--no-surround Disable surround sound encoding
--coupled 1,4 Specify coupled input channels (e.g. 1/2, 4/5)
However, the encoder still remaps channels according to vorbis channel ordering which is not what I want. I want the input channels to be mapped 1:1 to the output channels.
I'm currently looking for a way to completely disable the vorbis channel remapping but I don't see any obvious avenue to do so in the code here. It'd be great if I could specify my own output channel mapping to vorbis so that the coupled channels found in the original input audio file are kept in their original places in the output file with the added benefit of being coupled together for stereo processing.
from opus-tools.
Nevermind what I wrote last. I'm using Reaper as my DAW and it is decoding as surround and remapping the channels on decode. opusenc
and opusdec
with my --no-surround
option correctly encode and decode the channels without reordering.
from opus-tools.
Got a working PR to resolve this: #19
Tested it out locally on my 8-channel non-surround mix and it works!
from opus-tools.
After 6 years.. sorry.
What is the right way to encode 2 channels uncoupled using opus_multistream_encoder_create?
Any changes in validate_layout?
from opus-tools.
This #80 should also fix this issue
from opus-tools.
@ePirat @mark4o Probably this issue can be closed now, for #80 was merged in master
from opus-tools.
Related Issues (20)
- generates wavs with a 46-byte I think Sox stat fails HOT 2
- Lyrics support
- How to modify metadata without re-encoding? HOT 5
- Enabling Ambisonic Encoding HOT 1
- `--hard-cbr` is not respected when frame size is set to 60 sometimes
- how to read the original data of opus file into python/numpy array? HOT 2
- [question] How does downsampling happen in decoding? HOT 1
- Opusenc from git fails to encode very short flac files on windows HOT 1
- opus_custom_decode() can't decode the custom stream while set sample rate less 24K HOT 3
- opusdec 0.2 is 6-7x slower than 0.1.10 HOT 2
- Force silence using built-in VAD during encoding HOT 2
- Add GitHub build workflow (`.github/workflows/build.yml`) for simpler user experimentation
- Parameter expect-loss is useless
- ` opusenc` extremely slow on `master+libopus1.4`. compared to `0.1.6+libopus1.0.2` HOT 2
- How to suppress `opusenc` progress bar, but still print the final stats?
- [bug] `opusenc` resampler is 3-4x slower in >= opus-tools-0.2 compared to opus-tools-0.1.10 (big degradation in encoding 8khz audio)
- Encoding multiple frames at once as oppose to per-frame encoding to save user<>kernel switches resulting from many `fread(...)` calls
- Option for opusenc to omit DTX/silence frames from output completely and provide options for controlling aggressivity of silence detection
- Produce RTP stream and dump it directly to a `.pcap` file
- new release?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opus-tools.