Giter VIP home page Giter VIP logo

Comments (8)

slhck avatar slhck commented on July 17, 2024

I don't have a test file at hand, but you could try one of those options:

  • Explicitly setting -ac 6
  • Using -mapping_family 1
  • Using the audio filter channelmap=FL-FL|FR-FR|FC-FC|LFE-LFE|SL-BL|SR-BR:5.1

Per this thread.

Also note that your ffmpeg version is a bit outdated. Please follow the README instructions to get a static build: https://github.com/slhck/ffmpeg-normalize#ffmpeg

from ffmpeg-normalize.

joshinils avatar joshinils commented on July 17, 2024

I just downloaded the static ffmpeg build ffmpeg version 6.0-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2023 the FFmpeg developers
It's a problem with Ubuntu not having the latest versions in their repositories, the 22.04.1 LTS just has that 4.4.2 version, and its the latest LTS version.

I don't exactly know how to use what you mentioned.

  • It either runs without error, but the output is stereo.
    ['ffmpeg-normalize', '-pr', '-f', '-ar', '48000', '-c:a', 'opus', '-b:a', '448000', 'normalized_temp_single/test.mkv.audio-000.mkv', '-o', 'normalized_temp/test.mkv.audio-000.mkv.normalized.mkv', '-e', '-strict -2']
    ['ffmpeg-normalize', '-pr', '-f', '-ar', '48000', '-c:a', 'opus', '-b:a', '448000', 'normalized_temp_single/test.mkv.audio-000.mkv', '-o', 'normalized_temp/test.mkv.audio-000.mkv.normalized.mkv', '-e', '-strict -2 -mapping_family 1']
    ['ffmpeg-normalize', '--pre-filter', 'channelmap=channel_layout=7.1', '-pr', '-f', '-ar', '48000', '-c:a', 'opus', '-b:a', '448000', 'normalized_temp_single/test.mkv.audio-000.mkv', '-o', 'normalized_temp/test.mkv.audio-000.mkv.normalized.mkv', '-e', '-strict -2']
    ['ffmpeg-normalize', '--pre-filter', 'channelmap=channel_layout=7.1', '-pr', '-f', '-ar', '48000', '-c:a', 'opus', '-b:a', '448000', 'normalized_temp_single/test.mkv.audio-000.mkv', '-o', 'normalized_temp/test.mkv.audio-000.mkv.normalized.mkv', '-e', '-strict -2 -mapping_family 1']
  • Or I get an error, and I have no output, this happens for the variations where the f"-ac {num_channels}" is present
     ['ffmpeg-normalize', '--pre-filter', 'channelmap=channel_layout=7.1', '-pr', '-f', '-ar', '48000', '-c:a', 'opus', '-b:a', '448000', 'normalized_temp_single/test.mkv.audio-000.mkv', '-o', 'normalized_temp/test.mkv.audio-000.mkv.normalized.mkv', '-e', '-strict -2 -mapping_family 1 -ac 8']
    
    File:   0%|          | 0/1 [00:00<?, ?it/s]
    
    Stream 1/1:   0%|          | 0/100 [00:00<?, ?it/s]�[A
    
    Stream 1/1:   3%|▎         | 3.4166666666666665/100 [00:00<00:17,  5.63it/s]�[A
    
    Stream 1/1:  10%|█         | 10.0/100 [00:01<00:09,  9.64it/s]              �[A
    
    Stream 1/1:  15%|█▌        | 15.15/100 [00:01<00:08,  9.81it/s]�[A
    
    Stream 1/1:  22%|██▏       | 21.766666666666666/100 [00:02<00:07, 11.02it/s]�[A
    
    Stream 1/1:  28%|██▊       | 28.349999999999998/100 [00:02<00:06, 11.76it/s]�[A
    
    Stream 1/1:  33%|███▎      | 33.46666666666667/100 [00:03<00:05, 11.25it/s] �[A
    
    Stream 1/1:  40%|████      | 40.08333333333333/100 [00:03<00:05, 11.87it/s]�[A
    
    Stream 1/1:  47%|████▋     | 46.7/100 [00:04<00:04, 12.27it/s]             �[A
    
    Stream 1/1:  53%|█████▎    | 53.333333333333336/100 [00:04<00:03, 12.52it/s]�[A
    
    Stream 1/1:  58%|█████▊    | 58.43333333333334/100 [00:05<00:03, 11.77it/s] �[A
    
    Stream 1/1:  65%|██████▌   | 65.05/100 [00:05<00:02, 12.18it/s]            �[A
    
    Stream 1/1:  70%|███████   | 70.11666666666667/100 [00:06<00:02, 11.56it/s]�[A
    
    Stream 1/1:  77%|███████▋  | 76.71666666666667/100 [00:06<00:01, 12.04it/s]�[A
    
    Stream 1/1:  82%|████████▏ | 81.81666666666668/100 [00:07<00:01, 11.45it/s]�[A
    
    Stream 1/1:  88%|████████▊ | 88.4/100 [00:07<00:00, 11.94it/s]             �[A
    
    Stream 1/1:  95%|█████████▌| 95.01666666666667/100 [00:08<00:00, 11.37it/s]�[A
    Stream 1/1: 100%|██████████| 100.0/100 [00:08<00:00, 12.01it/s]            
    
    
    Second Pass:   0%|          | 0/100 [00:00<?, ?it/s]�[A
                                            
    
                                                        
    �[A�[33mWARNING: Input file had loudness range of 11.5. This is larger than the loudness range target (7.0). Normalization will revert to dynamic mode. Choose a higher target loudness range if you want linear normalization. Alternatively, use the --keep-loudness-range-target or --keep-lra-above-loudness-range-target option to keep the target loudness range from the input.�[0m
    
    File:   0%|          | 0/1 [00:08<?, ?it/s]
    
    Second Pass:   0%|          | 0/100 [00:00<?, ?it/s]�[A
    
    Second Pass:   0%|          | 0/100 [00:00<?, ?it/s]�[A
                                            
    
                                                        
    �[A�[31mERROR: Error while running command /usr/local/bin/ffmpeg -hide_banner -y -i normalized_temp_single/test.mkv.audio-000.mkv -filter_complex '[0:0]channelmap=channel_layout=7.1,loudnorm=i=-23.0:lra=7.0:tp=-2.0:offset=-1.62:measured_i=-18.74:measured_lra=11.5:measured_tp=-0.14:measured_thresh=-29.36:linear=true:print_format=json[norm0]' -map_metadata 0 -map_metadata:s:a:0 0:s:a:0 -map_chapters 0 -map '[norm0]' -c:a opus -b:a 448000 -ar 48000 -c:s copy -strict -2 -mapping_family 1 -ac 8 /tmp/tmphwg7fhvq/out.mkv! Error: Error running command ['/usr/local/bin/ffmpeg', '-hide_banner', '-y', '-i', 'normalized_temp_single/test.mkv.audio-000.mkv', '-filter_complex', '[0:0]channelmap=channel_layout=7.1,loudnorm=i=-23.0:lra=7.0:tp=-2.0:offset=-1.62:measured_i=-18.74:measured_lra=11.5:measured_tp=-0.14:measured_thresh=-29.36:linear=true:print_format=json[norm0]', '-map_metadata', '0', '-map_metadata:s:a:0', '0:s:a:0', '-map_chapters', '0', '-map', '[norm0]', '-c:a', 'opus', '-b:a', '448000', '-ar', '48000', '-c:s', 'copy', '-strict', '-2', '-mapping_family', '1', '-ac', '8', '/tmp/tmphwg7fhvq/out.mkv']: Input #0, matroska,webm, from 'normalized_temp_single/test.mkv.audio-000.mkv':
    Metadata:
    title           : James Bond 007 - Spectre
    SUMMARY         : James Bond 007 - Spectre
    DATE_RELEASED   : 2015
    ENCODER         : Lavf60.3.100
    Duration: 00:01:00.00, start: 0.000000, bitrate: 5319 kb/s
    Chapters:
    Chapter #0:0: start 0.000000, end 60.000000
    Metadata:
    title           : Chapter 1
    Stream #0:0(eng): Audio: dts (DTS-HD MA), 48000 Hz, 7.1, s32p (24 bit)
    Metadata:
    title           : Surround 7.1
    DURATION        : 00:00:59.999000000
    [out#0/matroska @ 0x5a8b480] Codec AVOption mapping_family (Channel Mapping Family) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
    Stream mapping:
    Stream #0:0 (dca) -> channelmap:default
    loudnorm:default -> Stream #0:0 (opus)
    Press [q] to stop, [?] for help
    [opus @ 0x5a8c580] Specified channel layout '7.1' is not supported
    [aost#0:0/opus @ 0x5a8c280] Error initializing output stream: Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
    [Parsed_loudnorm_1 @ 0x5ac7000]
    {
    "input_i" : "-inf",
    "input_tp" : "-inf",
    "input_lra" : "0.00",
    "input_thresh" : "-70.00",
    "output_i" : "-inf",
    "output_tp" : "-inf",
    "output_lra" : "0.00",
    "output_thresh" : "-70.00",
    "normalization_type" : "dynamic",
    "target_offset" : "inf"
    }
    Conversion failed!�[0m
    
    File:   0%|          | 0/1 [00:08<?, ?it/s]
    
    Second Pass:   0%|          | 0/100 [00:00<?, ?it/s]�[A
    Second Pass:   0%|          | 0/100 [00:00<?, ?it/s]
    
    File:   0%|          | 0/1 [00:08<?, ?it/s]
    Traceback (most recent call last):
    File "/home/niels/.local/bin/ffmpeg-normalize", line 8, in <module>
        sys.exit(main())
    File "/home/niels/.local/lib/python3.10/site-packages/ffmpeg_normalize/__main__.py", line 568, in main
        ffmpeg_normalize.run_normalization()
    File "/home/niels/.local/lib/python3.10/site-packages/ffmpeg_normalize/_ffmpeg_normalize.py", line 250, in run_normalization
        raise e
    File "/home/niels/.local/lib/python3.10/site-packages/ffmpeg_normalize/_ffmpeg_normalize.py", line 240, in run_normalization
        media_file.run_normalization()
    File "/home/niels/.local/lib/python3.10/site-packages/ffmpeg_normalize/_media_file.py", line 191, in run_normalization
        for progress in self._second_pass():
    File "/home/niels/.local/lib/python3.10/site-packages/ffmpeg_normalize/_media_file.py", line 406, in _second_pass
        raise e
    File "/home/niels/.local/lib/python3.10/site-packages/ffmpeg_normalize/_media_file.py", line 397, in _second_pass
        raise e
    File "/home/niels/.local/lib/python3.10/site-packages/ffmpeg_normalize/_media_file.py", line 393, in _second_pass
        yield from CommandRunner().run_ffmpeg_command(cmd)
    File "/home/niels/.local/lib/python3.10/site-packages/ffmpeg_normalize/_cmd_utils.py", line 80, in run_ffmpeg_command
        yield from ff.run_command_with_progress()
    File "/home/niels/.local/lib/python3.10/site-packages/ffmpeg_progress_yield/ffmpeg_progress_yield.py", line 191, in run_command_with_progress
        raise RuntimeError(f"Error running command {self.cmd}: {_pretty_stderr}")
    RuntimeError: Error running command ['/usr/local/bin/ffmpeg', '-hide_banner', '-y', '-i', 'normalized_temp_single/test.mkv.audio-000.mkv', '-filter_complex', '[0:0]channelmap=channel_layout=7.1,loudnorm=i=-23.0:lra=7.0:tp=-2.0:offset=-1.62:measured_i=-18.74:measured_lra=11.5:measured_tp=-0.14:measured_thresh=-29.36:linear=true:print_format=json[norm0]', '-map_metadata', '0', '-map_metadata:s:a:0', '0:s:a:0', '-map_chapters', '0', '-map', '[norm0]', '-c:a', 'opus', '-b:a', '448000', '-ar', '48000', '-c:s', 'copy', '-strict', '-2', '-mapping_family', '1', '-ac', '8', '/tmp/tmphwg7fhvq/out.mkv']: Input #0, matroska,webm, from 'normalized_temp_single/test.mkv.audio-000.mkv':
    Metadata:
    title           : James Bond 007 - Spectre
    SUMMARY         : James Bond 007 - Spectre
    DATE_RELEASED   : 2015
    ENCODER         : Lavf60.3.100
    Duration: 00:01:00.00, start: 0.000000, bitrate: 5319 kb/s
    Chapters:
    Chapter #0:0: start 0.000000, end 60.000000
    Metadata:
    title           : Chapter 1
    Stream #0:0(eng): Audio: dts (DTS-HD MA), 48000 Hz, 7.1, s32p (24 bit)
    Metadata:
    title           : Surround 7.1
    DURATION        : 00:00:59.999000000
    [out#0/matroska @ 0x5a8b480] Codec AVOption mapping_family (Channel Mapping Family) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
    Stream mapping:
    Stream #0:0 (dca) -> channelmap:default
    loudnorm:default -> Stream #0:0 (opus)
    Press [q] to stop, [?] for help
    [opus @ 0x5a8c580] Specified channel layout '7.1' is not supported
    [aost#0:0/opus @ 0x5a8c280] Error initializing output stream: Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
    [Parsed_loudnorm_1 @ 0x5ac7000]
    {
    "input_i" : "-inf",
    "input_tp" : "-inf",
    "input_lra" : "0.00",
    "input_thresh" : "-70.00",
    "output_i" : "-inf",
    "output_tp" : "-inf",
    "output_lra" : "0.00",
    "output_thresh" : "-70.00",
    "normalization_type" : "dynamic",
    "target_offset" : "inf"
    }
    Conversion failed!
    

from ffmpeg-normalize.

slhck avatar slhck commented on July 17, 2024

Let's focus on raw ffmpeg commands for now. I now see that you are using -c:a opus and not -c:a libopus; the former is the builtin ffmpeg encoder which may not have support for all these options.
So I wonder if you can get this simple command to work:

ffmpeg -i input.mkv -c:a libopus -vn output.mkv

Perhaps try -c:a libopus for ffmpeg-normalize, and maybe that does the job already.

from ffmpeg-normalize.

joshinils avatar joshinils commented on July 17, 2024

oh ffs.

ffmpeg -i test.mkv -c:a opus -vn -strict -2 opus.mkv 7.1 -> stereo
ffmpeg -i test.mkv -c:a libopus -vn libopus.mkv 7.1 -> 7.1

In retrospect, I should have looked into why the opus one needed the -strict -2 and the libopus does not.

Well, now I can re-do a bunch of media, guess I will develop my script to account for that.

from ffmpeg-normalize.

joshinils avatar joshinils commented on July 17, 2024

so yes, this is an upstream thing with ffmpeg, and the opus codec, do not use opus for surround sound!

from ffmpeg-normalize.

slhck avatar slhck commented on July 17, 2024

Good to know, thanks for reporting back!

from ffmpeg-normalize.

joshinils avatar joshinils commented on July 17, 2024

btw. my script does the whole thing with extracting the audio streams into separate files, so I can use multiprocessing and invoke ffmpeg-normalize in parallel, otherwise it only uses a single core to process the streams one by one.
I added more to make it do this with multiple files in parallel and only with a maximum number of jobs, which works great and of course is faster the more cores I give it, and my 3800xt has 8 cores, so 16 threads. I usually give it 11 so I can use it for other things simultaneously, that slows it down far enough, but still allows other things.

from ffmpeg-normalize.

joshinils avatar joshinils commented on July 17, 2024

Oh, and in case someone else has problems with surround sound variants "5.1(side)" or "7.1(side)" etc. those need the extra -e -ac {num_channels} argument, so -e "-ac 6" for 5.1(side). (the arguments to ffmpeg given via -e have to be combined somehow if they contain a space, which is why i added the double quotes around the -ac 6, otherwise it will only pass the -ac, not the 6 which makes no sense to ffmpeg.)
Otherwise, it error out with:

�[A�[31mERROR: Error while running command /usr/local/bin/ffmpeg -hide_banner -y -i normalized_temp_single/test.mkv.audio-000.mkv -filter_complex '[0:0]loudnorm=i=-23.0:lra=7.0:tp=-2.0:offset=-1.64:measured_i=-26.74:measured_lra=14.6:measured_tp=-4.78:measured_thresh=-37.73:linear=true:print_format=json[norm0]' -map_metadata 0 -map_metadata:s:a:0 0:s:a:0 -map_chapters 0 -map '[norm0]' -c:a libopus -b:a 320000 -ar 48000 -c:s copy /tmp/tmpja1bhttl/out.mkv! Error: Error running command ['/usr/local/bin/ffmpeg', '-hide_banner', '-y', '-i', 'normalized_temp_single/test.mkv.audio-000.mkv', '-filter_complex', '[0:0]loudnorm=i=-23.0:lra=7.0:tp=-2.0:offset=-1.64:measured_i=-26.74:measured_lra=14.6:measured_tp=-4.78:measured_thresh=-37.73:linear=true:print_format=json[norm0]', '-map_metadata', '0', '-map_metadata:s:a:0', '0:s:a:0', '-map_chapters', '0', '-map', '[norm0]', '-c:a', 'libopus', '-b:a', '320000', '-ar', '48000', '-c:s', 'copy', '/tmp/tmpja1bhttl/out.mkv']: Input #0, matroska,webm, from 'normalized_temp_single/test.mkv.audio-000.mkv':
Metadata:
title           : Blade
SUMMARY         : Blade
DATE_RELEASED   : 1998
ENCODER         : Lavf60.3.100
Duration: 00:01:00.00, start: 0.000000, bitrate: 641 kb/s
Chapters:
Chapter #0:0: start 0.000000, end 60.000000
Metadata:
title           : Chapter 15
Stream #0:0(ger): Audio: ac3, 48000 Hz, 5.1(side), fltp, 640 kb/s (default)
Metadata:
title           : Surround 5.1
DURATION        : 00:01:00.000000000
Stream mapping:
Stream #0:0 (ac3) -> loudnorm:default
loudnorm:default -> Stream #0:0 (libopus)
Press [q] to stop, [?] for help
[libopus @ 0x5d6b980] Invalid channel layout 5.1(side) for specified mapping family -1.
[aost#0:0/libopus @ 0x5d6b280] Error initializing output stream: Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

from ffmpeg-normalize.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.