VideoHelp Forum




+ Reply to Thread
Page 2 of 2
FirstFirst 1 2
Results 31 to 50 of 50
  1. Originally Posted by overlookmotel View Post
    Horace did you ever get to the bottom of this? I'm having exactly the same problem, with a 5.1 MOV file created in FFMPEG playing back in VLC with the centre channel coming through the left speaker only. (this is with VLC downmixing the 5.1 to stereo - I only have 2 speakers).
    In Horace's case the problem was re-mapping the channels when they didn't need remapping.

    Originally Posted by overlookmotel View Post
    I've tried setting FFMPEG's output layout to 5.1 and 5.1(side) and it makes no difference. In VLC it plays back with the centre channel being played through left only.
    Here's my FFMPEG command:
    ffmpeg -i input.mov -filter_complex "[0:1]pan=FL|c0=c0[ch0];[0:1]pan=FR|c0=c1[ch1];[0:2]pan=FC|c0=c0[ch2];[0:2]pan=LFE|c0=c1[ch3];[0:3]pan=SL|c0=c0[ch4];[0:3]pan=SR|c0=c1[ch5];[ch0][ch1][ch2][ch3][ch4][ch5]amerge=inputs=6[aout]" -c:v copy -c:a pcm_s16le -map 0:0 -map [aout] output.mov
    # NB stream 0 is video, streams 1-3 the 3 x stereo audio streams
    If this helps at all, as an experiment I created 3 wave files. The first Front left/right, the second Centre and LFE, and the third, Surround left/right. I muxed them as an MKA in that order and then used this command line to output an MKA containing a single 5.1ch PCM audio stream with the channels in the correct order.

    ffmpeg -i 3.mka -filter_complex amerge=inputs=3 -c:a pcm_s16le output.mka

    Click image for larger version

Name:	ffmpeg.gif
Views:	1213
Size:	18.8 KB
ID:	36970

    Originally Posted by overlookmotel View Post
    Cornucopia mentioned earlier in this thread that "MOV container (and by extension, MP4) has NAMED channels and so will tell you exactly how (in what order) those channels are listed, whether using industry convention order (SMPTE/AES/EBU) or not. Unless I'm mistaken, for those formats, the order does not matter, as they are retrieved by name, not number."
    I'll go on the record as still not agreeing with that one.

    For playback of multi-channel files, it might help to use a player that visually shows what's happening in each channel (given you're listening in stereo as I am). If you're using Windows, ffdshow displays the individual channel volumes in it's volume filter, or foobar2000's output meter adapts according to the number of channels being decoded and their layout. It can help to at least see where stuff is when it's not where it's supposed to be.

    Name:  foobar.gif
Views: 2357
Size:  5.7 KB
    Last edited by hello_hello; 10th May 2016 at 21:15.
    Quote Quote  
  2. Member
    Join Date
    Aug 2018
    Location
    Wrocław
    Search PM
    Originally Posted by hello_hello View Post
    ffmpeg decodes the following by mapping the surround channels to the back channels in wave file format. ie L, R, C, LFE, BL, BR
    AAC (M4A) - (FDKAAC, ffmpeg's AAC, NeroAAC, FhGAAC, QAAC)
    Apple Lossless (M4A)
    Opus
    Ogg
    WMA 9.2 (WMAEncode)
    WMA 10 (WMAEncode)
    ffmpeg decodes the following by mapping the surround channels to the side channels in wave file format ie L, R, C, LFE, SL, SR
    AC3
    DTS
    ffmpeg decodes the following by mapping the surround channels to the channels specified in the file (back or side)
    FLAC
    Wave
    Wavepack
    Helpful post.

    I have an MKV file with AC3-5.1 audio (layout: Channel layout: L R C LFE Ls Rs). When I run it through an AviSynth script, ffmpeg recognizes it as 5.1(side), but the layout in the outputted MP4 (encoder AAC) file is "Channel layout: L R C Cb Lb Rb".

    Is this 100% correct?
    I think if ffmpeg recognized the audio as 5.1(side), it should be "Ls Rs." The LFE channel is also labeled Cb, not LFE.
    Last edited by rgr; 2nd Sep 2025 at 03:43.
    Quote Quote  
  3. Member
    Join Date
    Aug 2018
    Location
    Wrocław
    Search PM
    I added the following to the ffmpeg command line:

    -channel_layout "5.1"

    but instead of the expected "L R C LFE Ls Rs" I now have "C L R Ls Rs LFE". So it's worse than before. Do you have any advice?
    Quote Quote  
  4. Different codecs use different channel orders for encoding, but they're decoded and remapped to the wave file channel order. MediaInfo displays the encoded channel order these days, rather than the decoded channel order.

    L R C LFE Ls Rs
    is the correct encoding order for 5.1ch AC3, where "s" is "surround".

    C L R Ls Rs LFE
    is the correct encoding order for 5.1ch AAC, where once again "s" is "surround" unless there's a PCE (program configuration element) specifying the channels. The AAC spec says encoding should start with the front centre channel, if it exists, encode the stereo channels in pairs from front to back and end with the back centre channel, if there is one. LFE is a "special" type of channel, encoded individually.

    For 5.1ch AAC, ffmpeg uses PCE's to encode it as 5.1ch (side) by default (according to the ffmpeg log file), but from what I've been able to tell it doesn't follow the AAC spec for the encoded channel order, and as a result MediaInfo seems to be interpreting it as L R C Cb Lb Rb. Despite that, foobar2000 decodes it correctly as FL FR, C, LFE, BL BR (in wave file channel order).
    When you add -channel_layout "5.1" to the command line, ffmpeg doesn't use PCE's to specify the channel layout, but it seems to be encoded in the correct order according to the AAC spec, so it's always decoded correctly.

    There's an old thread on the topic here.
    https://forum.videohelp.com/threads/401826-FFMPEG-changing-audio-channel-position#post2621729
    Or try a google search using "L R C Cb Lb Rb".

    Drilling down with MediaInfo's debug mode, this is what I'd expect to see (and do see when -channel_layout "5.1" is used).
    It's also what you'd see when encoding 5.1ch audio with QAAC.

    Code:
    000000B8   raw_data_block (923 bytes)
    000000B8    SCE - single_channel_element (93 bytes)
    000000B8     id_syn_ele:                         0 (0x0) - (3 bits) - SCE - single_channel_element
    000000B9    CPE - channel_pair_element (521 bytes)
    00000115     id_syn_ele:                         1 (0x1) - (3 bits) - CPE - channel_pair_element
    000000B8    CPE - channel_pair_element (918 bytes)
    000002C2     id_syn_ele:                         1 (0x1) - (3 bits) - CPE - channel_pair_element
    000000BE    LFE - lfe_channel_element (915 bytes)
    0000044E     id_syn_ele:                         3 (0x3) - (3 bits) - LFE - lfe_channel_element
    000000B9    END - End (921 bytes)
    00000451     id_syn_ele:                         7 (0x7) - (3 bits) - END - End
    00000452    byte_alignment:                      0 (0x0) - (6 bits)
    Without -channel_layout "5.1" in the command line:

    Code:
    000003CC   raw_data_block (834 bytes)
    000003CC    CPE - channel_pair_element (261 bytes)
    000003CC     id_syn_ele:                         1 (0x1) - (3 bits) - CPE - channel_pair_element
    000003CF    SCE - single_channel_element (556 bytes)
    000004D1     id_syn_ele:                         0 (0x0) - (3 bits) - SCE - single_channel_element
    000003CC    SCE - single_channel_element (562 bytes)
    000005FB     id_syn_ele:                         0 (0x0) - (3 bits) - SCE - single_channel_element
    000003CF    CPE - channel_pair_element (830 bytes)
    000005FE     id_syn_ele:                         1 (0x1) - (3 bits) - CPE - channel_pair_element
    000003CC    END - End (833 bytes)
    0000070D     id_syn_ele:                         7 (0x7) - (3 bits) - END - End
    0000070D    byte_alignment:                      0 (0x0) - (5 bits)
    I don't know why ffmpeg seems to change the encoded channel order for 5.1ch (side), or why MediaInfo interprets it as L R C Cb Lb Rb. As I said, foobar2000 (and therefore ffmpeg) decodes it correctly.
    Last edited by hello_hello; 2nd Sep 2025 at 11:36.
    Quote Quote  
  5. Member
    Join Date
    Aug 2018
    Location
    Wrocław
    Search PM
    Originally Posted by rgr View Post
    I added the following to the ffmpeg command line:

    -channel_layout "5.1"

    but instead of the expected "L R C LFE Ls Rs" I now have "C L R Ls Rs LFE". So it's worse than before. Do you have any advice?
    OK, after reading the manual, I see that the "C L R Ls Rs LFE" layout is correct for AAC5.1. However, in foobar I see that the channel order doesn't change -- LFE is still in 4th position instead of 6th. Doesn't ffmpeg do the channel swapping automatically? Do I have to change it manually?
    Quote Quote  
  6. foobar2000's output meter always displays the decoded audio in the wave file channel order, not necessarily the channel order the codec used to encode it.

    Image
    [Attachment 88512 - Click to enlarge]


    Try this (Surround = side. Rear surround = back).
    Image Attached Files
    Quote Quote  
  7. Member
    Join Date
    Aug 2018
    Location
    Wrocław
    Search PM
    Originally Posted by hello_hello View Post
    L R C LFE Ls Rs
    is the correct encoding order for 5.1ch AC3, where "s" is "surround".

    C L R Ls Rs LFE
    is the correct encoding order for 5.1ch AAC
    Yes, I figured it out. OK.

    For 5.1ch AAC, ffmpeg uses PCE's to encode it as 5.1ch (side) by default (according to the ffmpeg log file), but from what I've been able to tell it doesn't follow the AAC spec for the encoded channel order, and as a result MediaInfo seems to be interpreting it as L R C Cb Lb Rb. Despite that, foobar2000 decodes it correctly as FL FR, C, LFE, BL BR (in wave file channel order).
    So by default it should be encoded correctly and played correctly? Only internally the order will be inconsistent with the recommendations?

    When you add -channel_layout "5.1" to the command line, ffmpeg doesn't use PCE's to specify the channel layout, but it seems to be encoded in the correct order according to the AAC spec, so it's always decoded correctly.
    But in the foobar on the oscillator, I saw that the channel order hadn't changed. Center in 3rd position, LFE in 4th.
    Last edited by rgr; 3rd Sep 2025 at 04:46.
    Quote Quote  
  8. Member
    Join Date
    Aug 2018
    Location
    Wrocław
    Search PM
    Originally Posted by hello_hello View Post
    MediaInfo displays the encoded channel order these days, rather than the decoded channel order.
    a) encoded mp4 without -channel-layout
    MediaInfo: L R C Cb Lb Rb
    Foobar: FL FR FC LFE BL BR (matches what I see on the oscilloscope -- center 3rd from the top, LFE 4th from the top)

    b) encoded mp4 WITH -channel-layout "5.1"
    MediaInfo: C L R Ls Rs LFE (looks perfect for AAC 5.1)
    Foobar: still FL FR FC LFE BL BR (matches what I see on the oscilloscope)

    c) encoded mp4 WITH -channel-layout "5.1(side)"
    MediaInfo: L R C Cb Lb Rb
    Foobar: still FL FR FC LFE BL BR (matches what I see on the oscilloscope)


    So Foobar will always show the channel order on the oscillator according to WAV? So if I always have the same order, does this mean that regardless of whether I use -channel_layout "5.1" / "5.1(side)" or not, the encoding is correct?

    -channel_layout "5.1" seems to be the best option, as MediaInfo shows the correct order for AAC5.1. However, the source MKV is "5.1(side)".
    Quote Quote  
  9. Member
    Join Date
    Aug 2018
    Location
    Wrocław
    Search PM
    I've added a ticket to the ffmpeg bug tracker regarding this issue, It's here.
    https://trac.ffmpeg.org/ticket/7384#comment:14
    I see the ticket is still open. But the comments were helpful -- channel_layout "5.1" is recommended.
    Quote Quote  
  10. I'm only guessing about ffmpeg 5.1ch (side) not using the standard AAC channel order for encoding, based on what I see using MediaInfo in debug mode, but yes it does seem to change the encoding order. It uses PCEs to specify the channel layout though, so it should still be decoded correctly.

    Because there's no such thing as "surround" channels in the wave file channel layout, I think originally the back channels were used as surround when they're decoded, as "back" comes directly after LFE in the wave file channel order. That was before 7.1ch was a thing though. It added the extra surround channels to the rear, so for consistency it's becoming standard practice to decode the 5.1ch surround channels as "side". According to the "Use legacy 5.1ch layout" option in LAV filters, "back" as surround for 5.1ch is the legacy format.

    Having said that though, QAAC expects the input surround channels to be the back channels by default. https://github.com/nu774/qaac/wiki/Multichannel--handling

    Why, when 5.1ch AAC is encoded as "side" by ffmpeg, it's decoded as "back" by foobar2000, I do not know, but as foobar2000 uses ffmpeg to decode, it probably means ffmpeg decodes it that way. And I assume unless the 5.1ch AAC has a PCE to specify the side channels as surround, its up to the decoder to decide how those surround channels should be decoded, in respect to whether they're decoded as back or side channels.

    As a quick experiment I encoded a 5.1ch AC3 file, which fb2k decodes as side, as a wave file and the wave file used the side channels for surround. When I re-encoded the wave file as AAC with QAAC, the surround channels become "back". When I encoded it as flac with flac.exe it was encoded using the side channels, but when I encoded it as flac with ffmpeg (using fb2k) the flac file was decoded with the back channels as surround.

    I'm not sure why there's an inconsistency but I don't think it matters. Lossy encoders will accept either the side or back channels as surround when encoding 5.1ch, so it probably doesn't matter much which way those surround channels are decoded.
    Last edited by hello_hello; 3rd Sep 2025 at 13:13.
    Quote Quote  
  11. Originally Posted by hello_hello View Post
    foobar2000's output meter always displays the decoded audio in the wave file channel order, not necessarily the channel order the codec used to encode it.

    Image
    [Attachment 88512 - Click to enlarge]

    @ hello_hello
    I do not have foobar2000's output meter.
    At least I do not have anything like the picture you posted.
    My version is not too old but not the latest version.
    Quote Quote  
  12. The screenshot above is actually taken from the top of the Matrix Mixer DSP window, simply to show the wave file channel order.
    It's been abandoned by the author and it's not listed on the fb2k website for some reason, but for 32 bit fb2k it still works fine. It's handy if you want to downmix or remap channels or adjust channel volumes etc.
    https://www.softpedia.com/get/Multimedia/Audio/Audio-Plugins/foo-dsp-mm.shtml

    Image
    [Attachment 88545 - Click to enlarge]


    It was the Peak Meter UI element that I posted a screenshot of much earlier in this thread. You can add it as an element to the GUI in layout editing mode. I've added it twice. A small version under one tab, and a larger version under another for when I want to view the channel layout. Alternatively you can enable it separately via the "View/Visualisations/Peak Meter" menu. You can also right click on it somewhere to run it in full screen mode.

    Image
    [Attachment 88544 - Click to enlarge]
    Quote Quote  
  13. I just realised MediaInfo's debug mode displays both the encoded channel order, and the channels to which it thinks (I assume) the audio should be decoded.

    Code:
    Channel(s)                               : 6
    Channel(s)                               : 6 channels
    Channel positions                        : Front: L C R, Side: L R, LFE
    Channel positions                        : 3/2/0.1
    Channel layout                           : C L R Ls Rs LFE
    It still displays an odd layout for AAC 5.1ch (Side) encoded by ffmpeg though.

    Code:
    Channel(s)                               : 6
    Channel(s)                               : 6 channels
    Channel positions                        : Front: L C R, Side: C, Back: L R
    Channel positions                        : 3/1/2
    Channel layout                           : L R C Cb Lb Rb
    Quote Quote  
  14. @ hello_hello,
    Is there an easy way to enable Matrix Mixer in foobar2000 ?
    Like adding it to the View/DSP list.
    The only way I found was to go to File/Preferences/Playback/DSP Manager then double click on Matrix Mixer in the Active DSP's window.
    Quote Quote  
  15. cholla,
    There's no quicker way to open it that I'm aware of, but once it's added to the active DSPs list and opened you can leave it open while changing the MM configuration, then click Preview down the bottom. It might take a second or two, but your changes should be applied and the result will be reflected in a change to the Peak Meter display, assuming you've changed the number of channels, otherwise any volume change in the channels should be applied.

    You're probably aware you can create DSP presets. For instance I have a DSP preset for downmixing 5.1ch to stereo that simply looks like the screenshot below. Both the side and back channels are added for downmixing so it doesn't matter how the surround channels are decoded.
    When you check the "normalise" box the matrix mixer reduces the volume so the combined channels can't result in clipping. Its a "worst case scenario" reduction though, so the output audio can be quieter than it needs to be (the same presets can be applied when converting). Without the "Normalise" option checked, you can specify the volume reduction. A 6dB reduction is usually plenty, so for that you'd specify 0.5 as the multiplier value on the right, but it pays to scan the downmixed audio to check the peaks aren't clipped when "Normalise" is disabled.

    DSP presets can be added to the toolbar for playback. You can see the menu in the top left of my screenshot. I think adding DSPs to the View/DSP menu is done using a foobar2000 API and therefore DSPs have to be designed to use that menu, but I'm not really sure.

    Image
    [Attachment 88562 - Click to enlarge]


    Here's my preset for downmixing 7.1ch to stereo. I think it's similar to the way MeGUI uses Avisynth to do it.
    The first instance of MM combines the back and side channels into the side channels with a volume of 1, and without Normalising. The rest of the channels are passed through normally.
    The first instance of Amplify increases the volume by 1.5dB. The Advanced Limiter seems to need the peaks to be +1.5db in order to reduce them enough.
    The second instance of Amplify decreases the volume by 1.5dB, so hopefully any limited peaks in the side/surround channels will now be 0dB or less.
    The second instance of MM is configured to downmix 5.1ch to stereo, using the same sort of downmix as for 5.1ch, although it only needs to downmix the side channels as surround. "Normalise" is enabled for the second MM instance.

    Image
    [Attachment 88563 - Click to enlarge]


    By the way, fb2k comes with a DSP for automatic downmixing these days, but I don't know what sort of matrix is used or whether it normalises. I haven't played with it much.
    Last edited by hello_hello; 5th Sep 2025 at 03:51.
    Quote Quote  
  16. @ hello_hello,
    You are way beyond what I have done with foobar2000.
    I did update to the newest version & have the GUI set like the older version.
    The components added that I have from the older version.
    Keeping any that are newer.
    I do plan on doing some testing with what you posted & see what I get.
    Quote Quote  
  17. cholla,

    if you want to, try this:

    Install a second instance of fb2k as a portable version (it has to be 32 bit foobar2000) and while fb2k is closed, replace the profile folder with the one in the attached zip file. For the portable fb2k it's located in the same folder as foobar2000, so you should extract fb2k to somewhere it can write to it's own folder, or run it with administrator privileges. That way you can run the portable version with my configuration, without touching your current setup. The DSPs are 32 bit versions so you'll need to be using a 32 bit version of fb2k. You'll have to go into preferences and add your Media Library folder if you want fb2k to use it.

    My setup is configured to use two different fonts. One is Noto Sans and the other is Bitstream Vera Sans Mono. You should be able to download them from here. The text display area needs a mono space font to look nice, so if you install those fonts first it'll probably be easier than having to change them.
    https://www.1001fonts.com/noto-sans-font.html
    https://www.1001fonts.com/bitstream-vera-sans-font.html

    All the encoders I have presets for are saved in a "C:\Encoders" folder. The attached zip file also contains that folder. If you save it to the same location hopefully all of my conversion presets will work. The encoders folder contains 64 bit versions where applicable. FB2k uses a command line to run the encoders, so you can use them with 32 bit foobar2000, assuming you're running a 64 bit version of Windows. Oh... and the ffmpeg folder is empty so you'll have to put ffmpeg.exe and ffprobe.exe in there. I deleted them to keep the file size down as they're quite large.

    There may be a couple of other PC specific settings that need changing. I can't remember, but hopefully the above will be enough for everything to work.

    Edit: I said originally that ffmpeg and ffplay need to be added to the Encoders/ffmpeg folder, but it's actually ffmpeg.exe and ffprobe.exe that are needed, although it wont hurt to add all three.
    Image Attached Files
    Last edited by hello_hello; 6th Sep 2025 at 05:47.
    Quote Quote  
  18. @ hello_hello,
    My main computer is Windows 7 32-bit.
    My laptop is Windows 7 64-bit but I don't use it for conversions.
    I followed your instructions.
    I downloaded the two fonts but I'm not sure where I should put them.
    The font in your f2k portable looked OK & I could read them.
    I kept getting this error for any conversion I tried:
    Image
    [Attachment 88581 - Click to enlarge]


    Even though it said this"1 out of 1 files converted with major problems."
    No file was created.
    I believe the main problem is this: "Conversion failed: Could not start command line encoder: Machine type mismatch."
    Especially "Machine type mismatch".

    I was able to do some conversions. .mp3 , .wav , .some .ac3, some .aac but none of the apple related .aac.
    or qaac or Exhale .
    Also a small problem I fixed .The Encoder folder had a capital E in the .zip file.
    In the preferences the encoder folder had a small e. So fb2k could not find ffmpeg.
    Once changed it worked fine.

    Before I alter it any do you have any suggestions?
    Last edited by cholla; 6th Sep 2025 at 11:57.
    Quote Quote  
  19. Windows isn't case sensitive, so upper or lower case E for the folder name should be okay.

    If you're referring to Encoders in preferences somewhere like "Playback/Decoding/FFmpeg Decoder Wrapper", that's a decoding configuration and probably disabled for decoding anyway. The ffmpeg wrapper is mainly intended for decoding formats that fb2k doesn't natively support, and I discovered today (it was recently updated) that the way options for the codecs are specified has changed, so it won't work for many formats the way it is. It's easy to fix though, I'll explain it shortly.

    The conversion errors are no doubt due to many of the encoders being 64 bit while your OS is 32 bit. Ive attached another folder containing 32 bit versions. I've kept it updated along with the 64 bit versions but I haven't used any of them in quite a while. Hopefully they'll be fine.

    Once you've downloaded the fonts and unpacked them if need be, in Windows 11 you can open Settings, then go to Personalisation/Fonts. At the top of that page is a menu for installing fonts. Windows will copy them to it's fonts folder and probably add appropriate registry entries for them, so they'll be included in the list of available fonts for programs to use. The process is similar for Windows 7 but they're probably installed via the Control Panel. I can't remember. Try google if need be.

    The main difference you'll see is the text area. It probably looks something like this at the moment:

    Image
    [Attachment 88589 - Click to enlarge]


    But with the mono-space font it's configured to use:

    Image
    [Attachment 88590 - Click to enlarge]


    Back to the ffmpeg decoder wrapper....
    It should be near the top of the decoders list here and probably not checked.

    Image
    [Attachment 88583 - Click to enlarge]


    Double clicking on it's entry should take you here:

    Image
    [Attachment 88584 - Click to enlarge]


    The selected formats will be decoded by ffmpeg when the ffmpeg wrapper is enabled in the Decoders list instead of any native foobar2000 decoder.
    For AC3, EAC3, DTS, or a container that may contain a codec that uses dynamic range compression, you should double click on each entry to open the configuration and change it to look like this. For the AC3 entry it's:

    AC3
    *.AC3
    -drc_scale 0 -i %s

    For the moment, make sure only "show codec names from ffmpeg" is checked.

    Image
    [Attachment 88585 - Click to enlarge]


    For the remaining formats there should be nothing in the options section.

    Image
    [Attachment 88586 - Click to enlarge]


    None of that's important now as it's just extra decoding options, but I discovered there was a problem today so I thought I'd let you know how to fix it so there's no decoding errors when the ffmpeg decoder wrapper is enabled.

    The Command Line Decoder Wrapper can use any command line decoder. I've never had much need for it but I created a preset for decoding EAC3 with ffmpeg just to test it. The old command line doesn't work though, it needs to look like this.

    ffmpeg.exe -drc_scale 0 -i %s -c:a pcm_f32le -f W64 -

    or possibly this for 32 bit Windows:

    ffmpeg.exe -drc_scale 0 -i %s -c:a pcm_f32le -f wave -

    I hadn't intended to get side-tracked with all of that, but as I said, I only discovered there was a problem with the latest version of the ffmpeg decoder wrapper today. Below is a zip file with the 32 bit encoders, The ffmpeg folder is once again empty.
    Image Attached Files
    Last edited by hello_hello; 6th Sep 2025 at 14:32.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!