Batch tools for 4.0-4.1-5-0>5.1 adding silent channel(s)

QuadraphonicQuad

Help Support QuadraphonicQuad:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

winopener

2K Club - QQ Super Nova
Since 2002/2003
Joined
Mar 2, 2002
Messages
4,208
We have seen several times that some format doesn't behave correctly with some hardware or software players; given that the basic factor is that a 5.1 file does always works with digital players, there is somewhere a program that can
1) scan a mch flac files library
2) analyze what kind of channel map the files does have (4.0, 4.1, 5.0, 5.1)
3) run a remix of the file adding the correct channel(s) in order to have the correctly-handled 5.1 files with the one or two silent channels added
4) save a log of what has been changed and what not

Possibily with a cue-sheet input and output, as many does use.

Think MMH is close to this task but not complete for it. Probably Sox can do that but i can't figure it out how to pass the arguments about the original channels situation - says if files = 4.0 goto here, files = 4.1 goto there and so on.
 
Some media players and AVRs that I’ve seen actually ignore the channel layout and base the channel input/output solely on the number of channels. There’s a standard (somewhere) that is that does not include 4.1. 5 channels is mapped to 5.0. If you have 4.1 you’ll need to add a silent centre for it to play correctly in Kodi as it uses that standard.

For example of channel mapping being ignored is changing the channel mapping of a quad from FL, FR, SL, SR to FL, FR, BL, BR (front and rears in a 7.1 system) has no effect on playback channels, it remains front and sides. Same with mapping a 5ch file to 4.1, 5ch is always played as 5.0.

Up until very recently Kodi couldn’t play pure quad files. Only yesterday I found my system with a Denon AVR now does play 4.0 correctly. Now I’m not sure what changed (and when) since the last time I tried Kodi has had multiple updates and my Denon had a firmware update. Previously I played with this was probably 12 months ago.

Due to the above I don’t think remixing channels can be achieved automatically, it will take a human to work out what the current mapping is, especially when the files have already been altered by adding silent channels. Example, quad SACDs can be 5 ch with a silent centre on some releases, some SACDs are 5ch with an active centre, some quad SACDs are 6ch with silent centre and LFE.

I think the fastest way will be to move your albums into temporary root folders based on channel count and actual used channels then run MMH to the root folder to find all files recursively matching a channel count and convert to whatever you’re trying to do.

Have a play and see what you come up with based on your system - player(s) and AVR(s). If you find something that works or you’d like me to help with a change/new feature in MMH let me know and I’ll look at what’s involved.
 
Some media players and AVRs that I’ve seen actually ignore the channel layout and base the channel input/output solely on the number of channels.

Correction: The sentence above should have this added at the end:

and the order of the channels in the file.
 
You can do it with ffmpeg: ffmpeg -i input.flac -ac 5 output.flac

I’ve tested it with 4.0 files and it output 5.1 files with silent center and subwoofer channels, in the correct order.
 
The "sox" command line tool works well. Here is my "4 to 6 channels script"...

Code:
#!/bin/sh
for filename in *.flac
do
    sox "$filename" "$filename.flac" remix 1 2 0 0 3 4; rm "$filename" &
 
Think MMH is close to this task but not complete for it. Probably Sox can do that but i can't figure it out how to pass the arguments about the original channels situation - says if files = 4.0 goto here, files = 4.1 goto there and so on.

You may want to start with soxi, which is included with SoX, at least on Linux:
Code:
soxi 'America 2013 Five Point One.flac'

will give you:

Code:
Input File     : 'America 2013 Five Point One.flac'
Channels       : 6
Sample Rate    : 96000
Precision      : 24-bit
Duration       : 00:10:37.00 = 61152480 samples ~ 47775.4 CDDA sectors
File Size      : 541M
Bit Rate       : 6.79M
Sample Encoding: 24-bit FLAC
Comments       : 
ALBUM=America [2013 5.1 remix 24/96]
ARTIST=Yes
DATE=1972
DISCNUMBER=1
GENRE=Rock
GENRE=DVD-A
TITLE=America
DISCTOTAL=1
TRACKTOTAL=1
TRACKNUMBER=1
replaygain_album_gain=-5.51 dB
replaygain_album_peak=0.955241
replaygain_track_gain=-5.51 dB
replaygain_track_peak=0.955241
WAVEFORMATEXTENSIBLE_CHANNEL_MASK=0x60F
 
There’s a standard (somewhere) that is that does not include 4.1. 5 channels is mapped to 5.0. If you have 4.1 you’ll need to add a silent centre for it to play correctly in Kodi as it uses that standard.

Yeah, I ran into that years ago. It's possible to compute a WAVEFORMATEXTENSIBLE_CHANNEL_MASK value for a 4.1 file (it's simply a matter of doing some hex math), but FLAC will refuse to encode such a file.

Up until very recently Kodi couldn’t play pure quad files. Only yesterday I found my system with a Denon AVR now does play 4.0 correctly.

It may be platform-dependent. A while back I updated to what was then (and might still be) the most current version of LibreELEC for the Odroid C2 and found that 4.0 files still played at half speed. I gave up and padded everything to 5.1.
 
the most current version of LibreELEC for the Odroid C2 and found that 4.0 files still played at half speed.

Winopener found same issue with CoreElec on the new Odroid N2 so sounds like an Odroid kernel issue. LibreElec on on two Intel NUCs has no speed issue with 4.0.

You should log the problem to get it resolved

EDIT: winopen’s speed issue was only when he sets Kod’s output channels to 4.0. Odroid N2 plays quad ok if there’s silent channels added and out I’d set to 5.1 or 7.1
 
Last edited:
@atrocity I just noticed you use the Genre (multi-value) property to store your original disc type as well as traditional music style values. That’s a nice idea as many players can filter on genre (incl Kodi). I’m going to look closer at that. Thanks.
 
I’ve just about finished an MMH update the adds existing ‘Channel Layout‘ to the Remix tool dried so you’ll be able to filter remixes based on a grid filter including Layout (or any other grid filter), hence only only remix all visible tracks (tracks not filtered out).

I’m just looking at adding an ‘expert’ mode so the grid will recursively add every track under a selected root folder, users can then apply filters to do only a selected remix on those visible non filtered files. I should be able to still enforce sanity checks to stop ‘bad’ remixes, for example, you can’t remix to add an silent LFE to an existing 5.1 file (with LFE) etc.

When finished I’ll post the update on the MMH thread here.
 
Winopener found same issue with CoreElec on the new Odroid N2 so sounds like an Odroid kernel issue. LibreElec on on two Intel NUCs has no speed issue with 4.0.

You should log the problem to get it resolved

EDIT: winopen’s speed issue was only when he sets Kod’s output channels to 4.0. Odroid N2 plays quad ok if there’s silent channels added and out I’d set to 5.1 or 7.1

Not exactly, and that's the nastyness of this bug; that's the sequence i did.

1) set hdmi mch out to 4.0, playback at halfspeed of any mch file (tested 4.0 and 5.1)
2) set hdmi mch out to 5.1, playback of 5.1 file speed OK
3) back to set hdmi mch out to 4.0, playback of both 5.1 and 4.0 files speed OK.

Problem is, and that's where the nastyness lies, that since 3) everything plays ok: i haven't been able to reproduce the bug. It is somewhere, but very deep.
 
You should log the problem to get it resolved

I posted to the forum a year or more back but never got an acknowledgment. I guess that's better than when I complained about DSD trouble and just got a snippy "suggestion" that I convert everything to PCM.

EDIT: winopen’s speed issue was only when he sets Kod’s output channels to 4.0. Odroid N2 plays quad ok if there’s silent channels added and out I’d set to 5.1 or 7.1

I had/have the problem with the C2 even when the channels are set to 5.1 (bedroom) or 7.1 (living room). I just padded everything, which also has the benefit of making the files easier to share with others.
 
@atrocity I just noticed you use the Genre (multi-value) property to store your original disc type as well as traditional music style values. That’s a nice idea as many players can filter on genre (incl Kodi). I’m going to look closer at that. Thanks.

You're welcome...I'm afraid I haven't been very consistent about it, though. At one time I over-optimistically thought that I'd have an all-in-one system that would work for both stereo and multichannel, but it never happened. Specifically pointing out DVD-A seemed like a good idea at the time for reasons I no longer fully remember, but I never actually used that information for anything.

And yes, I know that I could technically use Kodi for both stereo and multichannel, but I greatly prefer using Logitech Media Server for 2.0/DTS/AC-3. There are a lot of reasons, but arguably the most important one is multi-room sync.
 
Specifically pointing out DVD-A seemed like a good idea at the time for reasons I no longer fully remember

For me, using Kodi, I could filter on Genre to view my Albums by Source Type (e.g Show me albums that are 'DVD-A" or 'Q8' etc). I guess it would be nice but a bit of work to re-tag, although I could write some code to automate most of it since I already have most my album folder names with that info... Example: 'Dark Side of the Moon (BDA)'.

It would also be handy to add the channel layout name as a 'genre' as again I can filter my albums by 'Quad' '5.1', '7.1', 'Atmos' etc.

The thing about Genre is its a supported filter in my iPad Remote app, so I can do these filters from the app which would be nice. Also Genre, has practically unlimited number of entries per song so I could add both source type and channel layout and still keep the current genres.

Something for me to think about....
 
Back
Top