BS1770GAIN

Copyright © 2014-2019 by Peter Belkner (http://home.snafu.de/pbelkner/)

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Last updated on 190710-1835.

BS1770GAIN is a loudness scanner compliant with ITU-R BS.1770 and its flavors EBU R128, ATSC A/85, and ReplayGain 2.0. It helps normalizing the loudness of audio and video files to the same level.

Nanos gigantum humeris insidentes: This project is dedicated to my European heritage. It is strictly to be understood as a statement against the saccarine "sweet" liberal lie of "multiculturalism" which is going to destroy Europe as we know it, in particular against the Merkel regime selling out Europe for nothing as we watch. #TeamWhite

Home:   http://bs1770gain.sourceforge.net/
Project:   http://sourceforge.net/projects/bs1770gain/
Download:   http://sourceforge.net/projects/bs1770gain/files/bs1770gain/

Content

  1. News
  2. Packaging Status
  3. Introduction
  4. Usage
  5. Command Line Syntax
  6. Test Cases

1. News

Date Release Notes
2019-07-07 0.6.0-β24 Purged off several (meanwhile) inactive code branches. Might be considered a release candidate.
2019-07-04 0.6.0-β23 Seeking (needed for implementing option -b/--begin) still wasn't in the shape it should be. We now follow the advice given here.
2019-06-29 0.6.0-β22 Improved seeking (update 2019-06-30: needed for implementing option -b/--begin.)
2019-06-28 0.6.0-β21
  • This β-release implements option --unit.
  • Without option --unit:
    root@root-pc MINGW32 ~/bs1770gain
    # bs1770gain ~/aerosmith/1973_make_it/01_make_it.flac -t
    analyzing ...
    [1/1] 01_make_it.flac
       integrated (momentary mean): -12.68 LUFS / -10.32 LU
      truepeak (relative/absolute): -0.39 TPFS / 0.956359
    [COLLECTION]
       integrated (momentary mean): -12.68 LUFS / -10.32 LU
      truepeak (relative/absolute): -0.39 TPFS / 0.956359
    done.
    
    root@root-pc MINGW32 ~/bs1770gain
    # bs1770gain ~/aerosmith/1973_make_it/01_make_it.flac -t --atsc
    analyzing ...
    [1/1] 01_make_it.flac
       integrated (momentary mean): -12.68 dBFS / -11.32 dB
      truepeak (relative/absolute): -0.39 dBFS / 0.956359
    [COLLECTION]
       integrated (momentary mean): -12.68 dBFS / -11.32 dB
      truepeak (relative/absolute): -0.39 dBFS / 0.956359
    done.
    
    root@root-pc MINGW32 ~/bs1770gain
    #
  • With option --unit:
    root@root-pc MINGW32 ~/bs1770gain
    # bs1770gain ~/aerosmith/1973_make_it/01_make_it.flac -t --unit=db
    analyzing ...
    [1/1] 01_make_it.flac
       integrated (momentary mean): -12.68 dBFS / -10.32 dB
      truepeak (relative/absolute): -0.39 dBFS / 0.956359
    [COLLECTION]
       integrated (momentary mean): -12.68 dBFS / -10.32 dB
      truepeak (relative/absolute): -0.39 dBFS / 0.956359
    done.
    
    root@root-pc MINGW32 ~/bs1770gain
    # bs1770gain ~/aerosmith/1973_make_it/01_make_it.flac -t --atsc --unit=ebu
    analyzing ...
    [1/1] 01_make_it.flac
       integrated (momentary mean): -12.68 LUFS / -11.32 LU
      truepeak (relative/absolute): -0.39 TPFS / 0.956359
    [COLLECTION]
       integrated (momentary mean): -12.68 LUFS / -11.32 LU
      truepeak (relative/absolute): -0.39 TPFS / 0.956359
    done.
    
    root@root-pc MINGW32 ~/bs1770gain
    #
2019-06-27  
2019-06-27 0.6.0-β20
  • This β-release marks a major update in functionality by introducing options --suffix=<suffix> and --codec=<codec>. Both options are useful in conjunction with the -a/--apply option only, i.e. just with transcoding and applying the gain obtained from the analysis. This might be useful for people producing (Youtube) videos as e.g. our "gatekeeper" to Debian, Petter Reinholdtsen: Measuring and adjusting the loudness of a TV channel using bs1770gain.
  • Without option --suffix=<suffix> the input is transcoded to FLAC and possibly wrapped into MKV or MKA, respectively (as usual):
    root@root-pc MINGW32 ~/bs1770gain
    # bs1770gain ~/peter_frampton/2000_live_in_detroit_dvd/02_lying.mkv -ao xx
    analyzing ...
    [1/1] 02_lying.mkv
      integrated (momentary mean): -24.38 LUFS / 1.38 LU
    [COLLECTION]
      integrated (momentary mean): -24.38 LUFS / 1.38 LU
    remuxing ...
    [1/1] 02_lying.mkv
    done.
    
    root@root-pc MINGW32 ~/bs1770gain
    # ffmpeg -i ./xx/02_lying.mkv
    ffmpeg version N-94125-gd33414d2ad Copyright (c) 2000-2019 the FFmpeg developers
      built with gcc 9.1.0 (Rev3, Built by MSYS2 project)
      configuration: --extra-ldflags='-static-libgcc -static-libstdc++ -static'
      libavutil      56. 29.100 / 56. 29.100
      libavcodec     58. 53.100 / 58. 53.100
      libavformat    58. 28.101 / 58. 28.101
      libavdevice    58.  7.100 / 58.  7.100
      libavfilter     7. 55.100 /  7. 55.100
      libswscale      5.  4.101 /  5.  4.101
      libswresample   3.  4.100 /  3.  4.100
      libpostproc    55.  4.100 / 55.  4.100
    [mpeg2video @ 01f49dc0] ignoring pic cod ext after 0
    Input #0, matroska,webm, from './xx/02_lying.mkv':
      Metadata:
        title           : Lying
        REPLAYGAIN_REFERENCE_LOUDNESS: -23.0 LUFS
        ARTIST          : Peter Frampton
        ALBUM           : Live In Detroit (DVD)
        YEAR            : 2000
        DISC            : 1/1
        track           : 2
        GENRE           : Rock
        VIDEO_CROP      : 698:572:8:2
        REPLAYGAIN_ALGORITHM: BS.1770
        ENCODER         : Lavf58.28.101
      Duration: 00:06:27.72, start: 0.000000, bitrate: 8100 kb/s
        Stream #0:0: Video: mpeg2video (Main), yuv420p(tv, top first)
        Metadata:
          DURATION        : 00:06:27.720000000
        Stream #0:1: Audio: flac, 48000 Hz, stereo, s32 (24 bit) (default)
        Metadata:
          DURATION        : 00:06:27.552000000
    At least one output file must be specified
    
    root@root-pc MINGW32 ~/bs1770gain
    #
  • By means of option --suffix=<suffix> the input is remuxed accordingly and the audio transcoded to a default codec obtained from libavformat.
    root@root-pc MINGW32 ~/bs1770gain
    # bs1770gain ~/peter_frampton/2000_live_in_detroit_dvd/02_lying.mkv -ao xx --suffix=mp4
    analyzing ...
    [1/1] 02_lying.mkv
      integrated (momentary mean): -24.38 LUFS / 1.38 LU
    [COLLECTION]
      integrated (momentary mean): -24.38 LUFS / 1.38 LU
    remuxing ...
    [1/1] 02_lying.mp4
    done.
    
    root@root-pc MINGW32 ~/bs1770gain
    # ffmpeg -i ./xx/02_lying.mp4
    ffmpeg version N-94125-gd33414d2ad Copyright (c) 2000-2019 the FFmpeg developers
      built with gcc 9.1.0 (Rev3, Built by MSYS2 project)
      configuration: --extra-ldflags='-static-libgcc -static-libstdc++ -static'
      libavutil      56. 29.100 / 56. 29.100
      libavcodec     58. 53.100 / 58. 53.100
      libavformat    58. 28.101 / 58. 28.101
      libavdevice    58.  7.100 / 58.  7.100
      libavfilter     7. 55.100 /  7. 55.100
      libswscale      5.  4.101 /  5.  4.101
      libswresample   3.  4.100 /  3.  4.100
      libpostproc    55.  4.100 / 55.  4.100
    [mpeg2video @ 0065a0c0] ignoring pic cod ext after 0
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './xx/02_lying.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2mp41
        title           : Lying
        artist          : Peter Frampton
        album           : Live In Detroit (DVD)
        encoder         : Lavf58.28.101
        genre           : Rock
        track           : 2
        disc            : 1/1
      Duration: 00:06:27.60, start: 0.000000, bitrate: 6648 kb/s
        Stream #0:0(und): Video: mpeg2video (Main) (mp4v / 0x7634706D), yuv420p(tv, top first)
        Metadata:
          handler_name    : VideoHandler
        Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
        Metadata:
          handler_name    : SoundHandler
    At least one output file must be specified
    
    root@root-pc MINGW32 ~/bs1770gain
    #
    root@root-pc MINGW32 ~/bs1770gain
    # bs1770gain ~/peter_frampton/2000_live_in_detroit_dvd/02_lying.mkv -ao xx --suffix=mkv
    analyzing ...
    [1/1] 02_lying.mkv
      integrated (momentary mean): -24.38 LUFS / 1.38 LU
    [COLLECTION]
      integrated (momentary mean): -24.38 LUFS / 1.38 LU
    remuxing ...
    [1/1] 02_lying.mkv
    done.
    
    root@root-pc MINGW32 ~/bs1770gain
    # ffmpeg -i ./xx/02_lying.mkv
    ffmpeg version N-94125-gd33414d2ad Copyright (c) 2000-2019 the FFmpeg developers
      built with gcc 9.1.0 (Rev3, Built by MSYS2 project)
      configuration: --extra-ldflags='-static-libgcc -static-libstdc++ -static'
      libavutil      56. 29.100 / 56. 29.100
      libavcodec     58. 53.100 / 58. 53.100
      libavformat    58. 28.101 / 58. 28.101
      libavdevice    58.  7.100 / 58.  7.100
      libavfilter     7. 55.100 /  7. 55.100
      libswscale      5.  4.101 /  5.  4.101
      libswresample   3.  4.100 /  3.  4.100
      libpostproc    55.  4.100 / 55.  4.100
    [mpeg2video @ 01d99d40] ignoring pic cod ext after 0
    Input #0, matroska,webm, from './xx/02_lying.mkv':
      Metadata:
        title           : Lying
        REPLAYGAIN_REFERENCE_LOUDNESS: -23.0 LUFS
        ARTIST          : Peter Frampton
        ALBUM           : Live In Detroit (DVD)
        YEAR            : 2000
        DISC            : 1/1
        track           : 2
        GENRE           : Rock
        VIDEO_CROP      : 698:572:8:2
        REPLAYGAIN_ALGORITHM: BS.1770
        ENCODER         : Lavf58.28.101
      Duration: 00:06:27.72, start: 0.000000, bitrate: 6707 kb/s
        Stream #0:0: Video: mpeg2video (Main), yuv420p(tv, top first)
        Metadata:
          DURATION        : 00:06:27.720000000
        Stream #0:1: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s (default)
        Metadata:
          DURATION        : 00:06:27.552000000
    At least one output file must be specified
    
    root@root-pc MINGW32 ~/bs1770gain
    #
  • By means of option --codec=<codec> the audio codec to which to transcode may be chosen:
    # bs1770gain ~/peter_frampton/2000_live_in_detroit_dvd/02_lying.mkv -ao xx --codec=wavpack
    analyzing ...
    [1/1] 02_lying.mkv
      integrated (momentary mean): -24.38 LUFS / 1.38 LU
    [COLLECTION]
      integrated (momentary mean): -24.38 LUFS / 1.38 LU
    remuxing ...
    [1/1] 02_lying.mkv
    done.
    
    root@root-pc MINGW32 ~/bs1770gain
    # ffmpeg -i ./xx/02_lying.mkv
    ffmpeg version N-94125-gd33414d2ad Copyright (c) 2000-2019 the FFmpeg developers
      built with gcc 9.1.0 (Rev3, Built by MSYS2 project)
      configuration: --extra-ldflags='-static-libgcc -static-libstdc++ -static'
      libavutil      56. 29.100 / 56. 29.100
      libavcodec     58. 53.100 / 58. 53.100
      libavformat    58. 28.101 / 58. 28.101
      libavdevice    58.  7.100 / 58.  7.100
      libavfilter     7. 55.100 /  7. 55.100
      libswscale      5.  4.101 /  5.  4.101
      libswresample   3.  4.100 /  3.  4.100
      libpostproc    55.  4.100 / 55.  4.100
    [mpeg2video @ 02019dc0] ignoring pic cod ext after 0
    Input #0, matroska,webm, from './xx/02_lying.mkv':
      Metadata:
        title           : Lying
        REPLAYGAIN_REFERENCE_LOUDNESS: -23.0 LUFS
        ARTIST          : Peter Frampton
        ALBUM           : Live In Detroit (DVD)
        YEAR            : 2000
        DISC            : 1/1
        track           : 2
        GENRE           : Rock
        VIDEO_CROP      : 698:572:8:2
        REPLAYGAIN_ALGORITHM: BS.1770
        ENCODER         : Lavf58.28.101
      Duration: 00:06:27.72, start: 0.000000, bitrate: 8143 kb/s
        Stream #0:0: Video: mpeg2video (Main), yuv420p(tv, top first)
        Metadata:
          DURATION        : 00:06:27.720000000
        Stream #0:1: Audio: wavpack, 48000 Hz, stereo, s32p (24 bit) (default)
        Metadata:
          DURATION        : 00:06:27.552000000
    At least one output file must be specified
    
    root@root-pc MINGW32 ~/bs1770gain
    #
  • It's up to the user supplying useful combinations of options --suffix=<suffix> and --codec=<codec>. Valid values can be obtained by means of options --help=suffix and --help=codec, respectively.
2019-06-26 0.6.0-β17
through
0.6.0-β19
  • Kyle pointed us to an issue with 8 channels. We've to emphasize we're convinced that no prior version was able to process 8 channels. (Anyway, we're not going to re-test versions already history.)
  • Adriano wants to use bs170gain in a filter chain. That's why there's a --suppress-progress option stripping any superflous information from the console output.
2019-06-24 0.6.0-β14
through
0.6.0-β16
  • Adriano pointed us to a sever bug when processing WAV files (cf. AVCodecContext::channel_layout 0 for WAV files.)
  • Adriano proposed that there shoud be a means for suppressing results up the hierarchy. That's why there's a --suppress-hierarchy option.
  • Kyle (from South Korea) pointed us to an issue with files where FFmpeg is unable to extract a duration.
    Note: In case of missing duration it is impossible to display the processing progress in percent. Instead it is given in (absolute) seconds.
  • Thanks a lot Adriano and Kyle!
2019-06-19   Hopefully the days of Merkel's tyranny are counted: Merkel shakes uncontrollably during military parade.
2019-06-14 0.6.0-β13 When transcoding/remuxing bs1770gain v0.6.0-β13 first creates a temporary file before finally moving it to its destination. By default, the temporary file's name is the target file's name prefixed with a dot ‘.’. When it happens that there is a file in the way with that particular name bs1770gain aborts. In order to make it possible to resolve this (we assume very rare) situation bs1770gain offers an option --temp-prefix=<prefix> making it possible to define a prefix different from the default.
2019-06-12 0.6.0-β11
through
0.6.0-β12
Dealing with option --overwrite still wasn't in the shape it should be.
2019-06-11 0.6.0-β10 Fixed crashing with option --overwrite.
2019-06-11 0.6.0-β9 Diimaan pointed us to a severe bug when re-muxing without transcoding, i.e. using option -o without option -a. Thanks a lot Diimaan!
2019-06-10 0.6.0-β4
through
0.6.0-β8
Jointly with Alexis made bs1770gain compilable on macOS (i.e. with gcc 10.0.1 whereas on our site just gcc 6.3.0 or gcc 9.1.0 is available.) Thanks a lot Alexis!
2019-06-10 0.6.0-β3 This β-release should fix the following:
  • Alexis reported that attempting to build on macOS aborts with a compilation error. Thanks a lot Alexis!
  • Diimaan reported an issue with loading the shared FFmpeg objects. Thanks a lot Diimaan!
    2019-06-06 0.6.0-β2 Fixes a bug with re-muxing to an unexpected target path when the source path contains one ore more additional dots ‘.’ except the separator for the file extension. Thanks a lot Hadrien for testing!
    2019-06-06 0.6.0-β1 This β-version is the first attempt letting see a renovated bs1770gain the light of the world:
    • SoX is history. Prior versions of bs1770gain relied on libsox for re-sampling. This version does re-sampling by means of ffmpeg's libswresample.
    • The renovation's major goal was getting rid of libsox. While at it we invented new data structures better fitting the problem domain. Finally we ended up replacing the libffsox and the bs1770gain layers by respective libff and libbg layers.
    • The responsibility of the libff layer is providing building blocks for accessing the ffmpeg libraries, i.e.
      • libavfilter (not needed by prior versions),
      • libpostproc (not needed by prior versions),
      • update 2019-06-11: libswscale (not needed by prior versions),
      • libavformat,
      • libavcodec,
      • libswresample (not needed by prior versions), and
      • libavutil.
    • For re-muxing in conjunction with transcoding the audio stream (by means of the -a/--apply option) bs1770gain now relies on libavfilter which in turn needs libpostproc update 2019-06-14: and libswscale.
    • The responsibility of the libbg layer is on one hand accessing the ffmpeg libraries (via the libff layer) and on the other hand accessing the lib1770 layer implementing the BS.1770 algorithm (which mainly has been untouched except fixing a minor bug preventing aggregation up the hierarchie.)
    • A great deal of time was spend improving NLS (especially for the Windows version. Please note that we've tried hard to find a solution for the cmd-box which is not UTF-8 aware wheras the MSYS2 shell indeed is - bs1770gain decides whether run from cmd-box or shell by examining the LANG environment variable and respectively relies on a 8 bit OEM or UTF-8 character representation when writing to cmd-box or shell. To make things worse a 16 bit wide character representaion is needed when writing to a file ... Note: We've tested with some cyrillic alphabet completely outside the lower half of the ASCII table - The best we could achieve with the cmd-box on our system is producing question marks - German OEM page is not able to display cyrillic letters - for you guys over there in Russia hopefully everything is fine except you have german umlauts in your file names ...)
    • The -b/--begin and -d/--duration options should work now as expected. (update 2019-06-16: In order to make this working we needed to implement a workaroud for dealing with issue 7864 or issue 4905, respectively.)
    2019-06-06  
    • Dr. Ludwig: This is Germany
    • Dr. Ludwig: German castles and palaces
    • update 2019-06-15: Ratatosk: German Doomer caught on camera (re-upload. The original video was deleted by Youtube just on 2019-06-06.) The re-upload featured the following comment by Black Forest (meanwhile completely overwritten): "This video is like a short movie. The pictures and the music tell us a story. My interpretation: There is a lonely man in a cold city. The city is cold to this man because there are mainly foreign shops and foreign fast food restaurants. And the gigantic supermarket is a symbol of capitalism. The shop center, too. The culture of the man was stolen from him. We see the stolen culture of this man in the last - dreamlike episode - of the video. The beautiful pictures of a lost country. Pictures of a blond beautiful culture that is lost. Hmmm. I really hope that you are OK, Mister Ratatoskr? Anyway: The Dessau event drags me down. But it makes no sense to discuss this here. There Is a Light That Never Goes Out - The Smiths". You might wonder what the flickering is when moving to the dreamlike episode and overshadowing most of it: it's the bombing of a German city viewed from the allied bombing fleet. You find information about what most likely is meant by Dessau event here (in German.)
    • update 2019-06-16: Dr. Ludwig: Wo stehen unsere letzten Burgen ✠ [German folk song][+ english translation]
    • update 2019-06-16: Dr. Ludwig: Palästinalied ✟ [German crusader song][+ english translation] (by Walther von der Vogelweide, c. 1170 – c. 1230, cf. also Wkipdia's entry regarding the Palästinalied.)
    2019-04-04
    • Just recently we discovered that this program leaks some memory in libavformat when run in apply mode and muxing into a matroska container:
      peter@debian-9:~/bs1770gain$ valgrind --leak-check=yes bs1770gain little_feat/1977_rockpalast/04_day_at_the_dog_races.mkv -ao xx
      ==2322== Memcheck, a memory error detector
      ==2322== Copyright (C) 2002-2015, and GNU GPL&d, by Julian Seward et al.
      ==2322== Using Valgrind-3.12.0.SVN and LibVEX; rerun with -h for copyright info
      ==2322== Command: bs1770gain little_feat/1977_rockpalast/04_day_at_the_dog_races.mkv -ao xx
      ==2322== 
      analyzing ...
        [1/1] "04_day_at_the_dog_races.mkv":         
            integrated:  -21.82 LUFS / -1.18 LU
      transcoding ...
        [1/1] "04_day_at_the_dog_races.mkv"     
      done.
      ==2322== 
      ==2322== HEAP SUMMARY:
      ==2322==     in use at exit: 3,445 bytes in 20 blocks
      ==2322==   total heap usage: 1,874,633 allocs, 1,874,613 frees, 3,062,595,861 bytes allocated
      ==2322== 
      ==2322== 100 (12 direct, 88 indirect) bytes in 1 blocks are definitely lost in loss record 11 of 17
      ==2322==    at 0x482F584: memalign (vg_replace_malloc.c:857)
      ==2322==    by 0x482F69B: posix_memalign (vg_replace_malloc.c:1020)
      ==2322==    by 0x4E91E67: av_malloc (in /home/peter/bs1770gain/autoconf/bin/bs1770gain-tools/libavutil.so.56)
      ==2322==    by 0x4E9214A: av_mallocz (in /home/peter/bs1770gain/autoconf/bin/bs1770gain-tools/libavutil.so.56)
      ==2322==    by 0x4E79BFA: av_buffer_ref (in /home/peter/bs1770gain/autoconf/bin/bs1770gain-tools/libavutil.so.56)
      ==2322==    by 0x5091F47: ???
      ==2322==    by 0x64CC712: ???
      ==2322==    by 0x6520DD5: ???
      ==2322==    by 0x110BA8: av_interleaved_write_frame (ffsox_dynload2.c:641)
      ==2322==    by 0x118015: ffsox_stream_interleaved_write (ffsox_stream.c:55)
      ==2322==    by 0x1173F4: frame_writer_encode (ffsox_frame_writer.c:163)
      ==2322==    by 0x1176F7: frame_writer_run (ffsox_frame_writer.c:242)
      ==2322== 
      ==2322== 110 (12 direct, 98 indirect) bytes in 1 blocks are definitely lost in loss record 12 of 17
      ==2322==    at 0x482D1BC: malloc (vg_replace_malloc.c:298)
      ==2322==    by 0x482F4E0: realloc (vg_replace_malloc.c:785)
      ==2322==    by 0x4E91ECB: av_realloc (in /home/peter/bs1770gain/autoconf/bin/bs1770gain-tools/libavutil.so.56)
      ==2322==    by 0x5090FEA: ???
      ==2322==    by 0x50910A1: ???
      ==2322==    by 0x509184D: ???
      ==2322==    by 0x5091F30: ???
      ==2322==    by 0x64CC712: ???
      ==2322==    by 0x6520DD5: ???
      ==2322==    by 0x110BA8: av_interleaved_write_frame (ffsox_dynload2.c:641)
      ==2322==    by 0x118015: ffsox_stream_interleaved_write (ffsox_stream.c:55)
      ==2322==    by 0x1173F4: frame_writer_encode (ffsox_frame_writer.c:163)
      ==2322== 
      ==2322== LEAK SUMMARY:
      ==2322==    definitely lost: 24 bytes in 2 blocks
      ==2322==    indirectly lost: 186 bytes in 3 blocks
      ==2322==      possibly lost: 0 bytes in 0 blocks
      ==2322==    still reachable: 3,235 bytes in 15 blocks
      ==2322==         suppressed: 0 bytes in 0 blocks
      ==2322== Reachable blocks (those to which a pointer was found) are not shown.
      ==2322== To see them, rerun with: --leak-check=full --show-leak-kinds=all
      ==2322== 
      ==2322== For counts of detected and suppressed errors, rerun with: -v
      ==2322== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
      peter@debian-9:~/bs1770gain$ 
    • The issue is already reported.
    • Update 2019-04-11: The issue is fixed (cf. ticket 7827) and the fix is available with the daily snapshot. (Cf. the following threads from FFmpeg-devel:
      2019-01-23 0.5.2 Released in order to make it into Debian 10 'buster'. Essentially the same as v0.5.2-β3.
      2019-01-23 0.5.2-β3 By the previous β-release we fixed a bug w.r.t. the MP3 codec we've already fixed by v0.5.0-β2 w.r.t. the OPUS codec. This β-release generalizes the approach.
      2019-01-23 0.5.2-β2 Aimed to fix bug #910451.
      2018-10-26 0.5.2-β1
      • User Hadrien wrote "I've found that bs1770gain wasn't liking '\'s in dirnames" and provided a patch this β-release incorporates.
      • Again modified slightly the build process.
      2018-10-19 0.5.1 Brought back to life building the project with autotools.
      2018-09-02 0.5.0
      • Essentialy the same as v0.5.0-β5.
      • BTW: We noticed that we've forgotten to upload v0.5.0-β4. Hence for completeness we uploaded it joint with v0.5.0.
      2018-09-01   We're aware that we're not the world's most gifted software developer. Anyway, we feel that we belong to #TeamWhite and hence added the respective hashtag to the above note.
      2018-08-11 0.5.0-β5
      • Remuxing files with more then one stream (i.e. video files) was broken. This β-release fixes the issue.
      2018-08-09 0.5.0-β4
      • With v0.5.0-β1 we introduced guarding bs1770gain against being run with incompatible FFmpeg and SoX libraries. At least this was the goal. In case of the FFmpeg libraries the test was done against the full version consiting of major, minor, and micro version numbers. This was by far to much. As far as we know just a bump of the major version number indicates some change in binary compatibility. This release relexas the test to FFmpeg major version number.
      • BTW:
        • Around the time v0.5.0-β1 was released we received the following mail from some Debian official:
          From: daniel <daniel@xxxxxxxx.xxx>
          Date: 29.07.2018 19:36
          To: Peter Belkner <pbelkner@snafu.de>
          Subject: Re: Bug#883198: Fixed

          Hi Peter,

          Thanks for the link. I was sorry to see the statement about European heritage on this page. I'm not sure how a Debian or Free Software user who isn't European is meant to react to that.

          Daniel

          -------- Original message --------
          From: Peter Belkner <pbelkner@snafu.de>
          Date: 29/07/2018 5:36 pm (GMT+00:00)
          To: 883198@bugs.debian.org
          Subject: Bug#883198: Fixed

          For details refer to http://bs1770gain.sourceforge.net/index.html#0.5.0-beta-1

          Peter
        • To be honest, dear Daniel: We're simply not interested in "how a Debian or Free Software user who isn't European is meant to react." We develop open source software and we're from Europe. We're interested in how we as native Europeans feel when overrun by the third world: To us the message of the above mail is nothing else then a typical instance of anti-white "racism" (by no means it is in accordance with the saccharine "sweet" words published by Debian.) To us the idea of developing open source software was always (and possibly will ever) be educational similar to academia and sience. Add the internet and you're in a position to bring it to the smallest village all over the world. In the ages of the internet there's really not the slidest reason for someone interested in open source software leaving his home somewhere in the world coming to Europe for some silly promise made by those (not by us of course, cf. below) obviously nobody ever can keep and that way destroying all the infrastucture we've created here in Europe in the course of thousands of years (just for a free lunch nobody is able to deliver to the whole world anyway.) Contrary to those (who are no native inhabitants of Europe, or to express it by a contemporary fake term they've invented for us goyim: they're refugees themselfs) we, the native inhabitants of Europe, clearly state: Make no mistake, stay at home and learn, learn, learn! Learn as much as you can!
        • We're convinced that the so called refugee crisis is an event staged by those (according to a well known politician a small, rootless, international clique) literally nobody is even allowed to call by their very name (at least here in Europe; cf. the fairytale Rumpelstiltskin: we have to break the spell and again have to learn to call the chosen people by their very name as it was usual for centuries and just nowadys is "prohibided" by some strange "laws" like §130 Volksverhetzung dictated by themselfs) in order to make their wet dream of a new world order become true (either in the clothes of nominal communism or in the clothes of crypto-communism aka liberalism - two sides of the very same coin anyway) and finally make those the masters of the world: liberté, égalité, fraternité for everyone except those who have chosen themselfs to be the masters (update 2019-01-11: cf. also here and here.)
      2018-08-05 0.5.0-β3
      • User Martin reported that the Windows build of prior versions is broken in that when called from a Windows cmd box rather than from MSYS2 it might come up with a message box like
      • Hence this release is of interest just for Windows users in that it fixes the issue.
      • Many thanks, Martin!
      2018-08-02 0.5.0-β2
      • User Michal reported that bs1770gain v0.5.0-β1 is crashing when run with Opus samples.
      • As root cause we could identify that (deprecated) avcodec_decode_audio4() crashes when flushed with AV_CODEC_ID_OPUS.
      • As a workaround flushing the decoder is avoided now for AV_CODEC_ID_OPUS.
      • There&s nothing preventing us from replacing deprectated API avcodec_decode_audio4() by the contemporary replacement API avcodec_send_packet()/avcodec_receive_frame (as already announced for several times. Of course, it&s easier said then done ...)
      • Thanks again Michal!
      2018-07-29 0.5.0-β1
      • Essentially this is a re-compilation against current FFmpeg. As it turned out bs100gain was showing unexpected behaviour when run with current (incompatible) FFmpeg libraries.
      • While at it we guarded bs1770gain against being run with incompatible FFmpeg and SoX libraries.
      • Fixed some bugs:
        • #881131: The bug was forced due to artifical test data faking zero channels:
          peter@debian-9-32:~/msys64/bs1770gain$ ~/bs1770gain/bin/bs1770gain ./bug-881131-channel-underflow/poc -o output
          analyzing ...
            [1/1] "poc": Error channel underflow (0 - should be 1 at min): ffsox_frame_reader_create() - "ffsox_frame_reader.c" (55).
          Error creating frame reader: ffsox_frame_reader_new() - "ffsox_frame_reader.c" (132).
          Error creating frame reader: ffsox_analyze() - "ffsox_analyze.c" (68).
          Error gathering track statistics - "bs1770gain_tree.c" (152).
          peter@debian-9-32:~/msys64/bs1770gain$ _
        • #881132: The bug was forced due to artifical test data faking a number of channels by far greater then the numer supported by FFmpeg:
          peter@debian-9-32:~/msys64/bs1770gain$ ~/bs1770gain/bin/bs1770gain ./bug-881132-channel-overflow/poc -o output
          analyzing ...
            [1/1] "poc": Error channel overflow (31 - should be 8 at max): ffsox_frame_reader_create() - "ffsox_frame_reader.c" (63).
          Error creating frame reader: ffsox_frame_reader_new() - "ffsox_frame_reader.c" (132).
          Error creating frame reader: ffsox_analyze() - "ffsox_analyze.c" (68).
          Error gathering track statistics - "bs1770gain_tree.c" (152).
          peter@debian-9-32:~/msys64/bs1770gain$ _
        • #883198: The bug was forced due to artifical test data fooling FFmpeg to come up with a zero codec id:
          peter@debian-9-32:~/msys64/bs1770gain$ ~/bs1770gain/bin/bs1770gain ./bug-883198-missing-codec-id/poc -o output
          analyzing ...
            [1/1] "poc": Error finding decoder: ffsox_frame_reader_create() - "ffsox_frame_reader.c" (48).
          Error creating frame reader: ffsox_frame_reader_new() - "ffsox_frame_reader.c" (132).
          Error creating frame reader: ffsox_analyze() - "ffsox_analyze.c" (68).
          Error gathering track statistics - "bs1770gain_tree.c" (152).
          peter@debian-9-32:~/msys64/bs1770gain$ _
      • Re-designed the dynamic loader module ("ffsox_dynload.c" vs. "ffsox_dynload2.c").
      2017-01-10   Added a political statement to the top of this page.
      2016-12-08 0.4.12 Added UTF-16 support to the Windows Console. Linux should not be affected and should have been worked all the time because being based on UTF-8. This development was triggered by Seongkyun (Andrei) Kim who is located in Korea and provided some testing.
      2016-12-06   Thanks to Seongkyun (Andrei) Kim there is an introduction to bs1770gain in Korean language available at http://blog.naver.com/eqmaker/220879120285 and a manual at http://www.eqmaker.kr/public/BS1770GAIN_Manual_KOR-20161206.pdf.
      2016-11-10   To all you great people out there in the US: Thank you for electing Donald Trump!
      2016-08-13 0.4.11 Just recently a very talented guy who calls himself kevinlekiller (https://github.com/kevinlekiller/) approached me with a bunch of bugs he obviously had learned the hard way by using the tool (i.e. by not artificially testing it). But not just that, he also proposed a solution for each of the bugs: https://gist.github.com/kevinlekiller/62730fa5ddcf791107a723b1f235773e. This release mainly consists of his contributions.
      • Fixed ignoring the --audio=<n> option.
      • Fixed crashing with files containing more than 5 audio streams.
      2016-07-18 0.4.10 Fixed writing xml escaped strings with the --xml option. Please note that bs1770gain is not officially supported on OSX even if it seems to build on OSX platforms and that it hence don&t take into account unicode mapping anomalies between OSX and Linux/Windows (NFD/NFC). It will always output the unicode dialect common on the platform and hence the generated XML is not portable between OSX and Linux/Windows.
      2016-03-16 0.4.9
      • In "ffsox_frame_convert.c", replaced constant ~0ll by ~0ull (sould fix #811955).
      • Replaced av_free_packet() by av_packet_unref() (should fix #810563).
      2015-12-19 0.4.8
      • There&s a new option --norm=<float> allowing to set the reference loudness to some value apart from -23.0 (EBU R128), -24.0 (ATSC A/85), or -18.0 (ReplayGain 2.0).
      • Loudness values are written to the output console with two places after the decimal point.
      • Regarding the Windows version, added some support for unicode paths (i.e. non-OEM).
      2015-09-15 0.4.7 Fixed a serious bug regarding the -r option.
      2015-09-12 0.4.6
      • There&s a new option --xml for producing XML-output.
      • There&s a new option --stereo. The effect is that down-mix to stereo only happens if requested. The old version always silently down-mixes to stereo which is fixed now.
      • FFmpeg has bumped their version numbers, i.e is not binary compatible to the old version. The new binary release now requires avutil-55, swresample-2, avcodec-57, and avformat-57.
      2015-06-25 0.4.5 Various fixes mainly to make BS1770GAIN compile on various architectures.
      2015-06-22 0.4.4
      • Fixed "stuttering" videos.
      • Thanks to Petter Reinholdtsen there is now an official BS1770GAIN package available on Debian. Read about Petter&s plans regarding BS1770GAIN.
      2015-06-15 0.4.3
      • Automake/Autoconf compatible source code distribution.
      • Several fixes.
      2015-06-08 0.4.2 Fixed memory leaks.
      2015-01-29 0.4.1 Several fixes.
      2015-01-14 0.4.0
      • Integrated BS.1770 analysis into the finite state machine.
      • Added automatic TRACK and DISC tags extension.
      • Added --extension <extension> option.
      • Several fixes.
      2015-01-08 0.3.2
      • Added another extension.
      • Several fixes.
      2014-12-30 0.3.1 Minor fixes.
      2014-12-23 0.3.0 Finite state machine for remuxing/transcoding.
      2014-12-11 0.2.1
      • Fixed a critical bug breaking the whole program (thanks to Michal Šmucr).
      • Improved diagnostic of erroneous command line.
      2014-12-07 0.2.0 Added experimental options.
      2014-12-04 0.1.1
      • Compiled with -O2.
      • Slightly different error handling with getopt_long().
      • Added the FFmpeg and SoX shared objects / dynamic link libraries to the release.
      2014-12-01 0.1.0 Initial release.

      2. Introduction

      Audio from different sources can be expected to be different loud and it would be nice to automatically adapt all these audio sources to the same loudness. Fortunately the ITU-R in their BS.1770 standard defines an algorithm which makes it possible to measure the loudness of a certain audio source. Based on the ITU-R BS.1770 measure several standards bodys defined what they think is the preferred loudness audio should normalize to, notably

      BS1770GAIN implements the ITU-R BS.1770 loudness measurement algorithm and makes it accessable to a user in several ways as known from the EBU R128 standard, i.e.

      The integrated loudness is the two phase gated measurement of the mean loudness as described by ITU-R BS.1770. All measures are described in detail by EBU R128.

      On top of that BS1770GAIN provides to additional measures not related to loudness:

      Besides measuring the loudness BS1770GAIN is also able to adapt it conformant with the above mentioned statndards. There are two ways to achieve this:

      Following we describe in more detail how BS1770GAIN has to be customized.

      3. Packaging Status

      The following shows versions and up to date status of this package in all known repositories.

      Packaging status

      4. Usage

      4.1. Loudness Measurement

      In the simplest case we want to analyze the (integrated) loudness of a track or, a bit more general, an album. Assuming the album is stored in some folder (in the following examples the folder is "~/2012_live_at_the_georgia_theatre") we may issue the following command:

      $ bs1770gain ~/2012_live_at_the_georgia_theatre
      /home/home/2012_live_at_the_georgia_theatre
      analyzing "2012_live_at_the_georgia_theatre" ...
        [1/3] "01_intro_like_i_am.mkv":
            integrated:  -16.2 LUFS / -6.8 LU
        [2/3] "02_good_one_coming_on.mkv":
            integrated:  -15.9 LUFS / -7.1 LU
        [3/3] "03_up_in_smoke.mkv":
            integrated:  -15.6 LUFS / -7.4 LU
        [ALBUM]:
            integrated:  -15.9 LUFS / -7.1 LU
      done.
      
      Immediatly BS1770GAIN gives us the (integrated) loudness of each track as well as of the whole album.

      The figure behind the slash is the gain one has to apply in order to achieve a certain loudness. Which loudness to choose depends on the users preferences and there are several standards to choose from, noatbly EBU R128, ATSC A/85, and ReplayGain 2.0 (cf. above). BS1770GAIN silently assumes EBU R128. If we want to alter this we have to utilize the --atsc or --replaygain options, respectively. For example, if we want to normalize to ATSC A/85 we have to issue the command

      $ bs1770gain ~/2012_live_at_the_georgia_theatre --atsc
      /home/home/2012_live_at_the_georgia_theatre
      analyzing "2012_live_at_the_georgia_theatre" ...
        [1/3] "01_intro_like_i_am.mkv":
            integrated:  -16.2 LUFS / -7.8 LU
        [2/3] "02_good_one_coming_on.mkv":
            integrated:  -15.9 LUFS / -8.1 LU
        [3/3] "03_up_in_smoke.mkv":
            integrated:  -15.6 LUFS / -8.4 LU
        [ALBUM]:
            integrated:  -15.9 LUFS / -8.1 LU
      done.
      

      You may request XML output by means of the --xml option:

      $ bs1770gain ~/2012_live_at_the_georgia_theatre --xml
      <bs1770gain>
        <album folder="2012_live_at_the_georgia_theatre">
          <track total="3" number="1" file="01_intro_like_i_am.mkv">
            <integrated lufs="-16.2" lu="-6.8" />
          </track>
          <track total="3" number="2" file="02_good_one_coming_on.mkv">
            <integrated lufs="-15.9" lu="-7.1" />
          </track>
          <track total="3" number="3" file="03_up_in_smoke.mkv">
            <integrated lufs="-15.6" lu="-7.4" />
          </track>
          <summary total="3">
            <integrated lufs="-15.9" lu="-7.1" />
          </summary>
        </album>
      </bs1770gain>
      

      In general, if we want to analyze properties out of intergrated loudness, maximum shortterm loudness, maximum momentary loudness, loudness range, maximum sample peak, or maximum true peak we have to choose the appropriate command line switches out of -i/--integrated, -s/--shortterm, -m/--momentary, -r/--range, -p/--samplepeak, and -t/--truepeak, respectivley. Assuming we&re interested in all of these properties at once we have to issue following command:

      $ bs1770gain ~/2012_live_at_the_georgia_theatre -ismrpt
      /home/home/2012_live_at_the_georgia_theatre
      analyzing "2012_live_at_the_georgia_theatre" ...
        [1/3] "01_intro_like_i_am.mkv":
             integrated:  -16.2 LUFS / -6.8 LU
              shortterm:  -12.3 LUFS / -10.7 LU
              momentary:  -12.3 LUFS / -10.7 LU
                  range:  4.9 LUFS
            sample peak:  -2.2 SPFS / 0.772912
              true peak:  -2.2 TPFS / 0.774780
        [2/3] "02_good_one_coming_on.mkv":
             integrated:  -15.9 LUFS / -7.1 LU
              shortterm:  -12.0 LUFS / -11.0 LU
              momentary:  -12.0 LUFS / -11.0 LU
                  range:  5.9 LUFS
            sample peak:  -2.9 SPFS / 0.714886
              true peak:  -2.9 TPFS / 0.714886
        [3/3] "03_up_in_smoke.mkv":
             integrated:  -15.6 LUFS / -7.4 LU
              shortterm:  -12.3 LUFS / -10.7 LU
              momentary:  -12.3 LUFS / -10.7 LU
                  range:  5.4 LUFS
            sample peak:  -2.8 SPFS / 0.726805
              true peak:  -2.8 TPFS / 0.726805
        [ALBUM]:
             integrated:  -15.9 LUFS / -7.1 LU
              shortterm:  -12.0 LUFS / -11.0 LU
              momentary:  -12.0 LUFS / -11.0 LU
                  range:  5.3 LUFS
            sample peak:  -2.2 SPFS / 0.772912
              true peak:  -2.2 TPFS / 0.774780
      done.
      

      If we want to analyze just a short part of the files (say starting at 1 minute and lasting 30 seconds) we may issue the following command utilizing the -b/--begin and -d/--duration options:

      $ bs1770gain ~/2012_live_at_the_georgia_theatre -b 1:00 -d 30
      /home/home/2012_live_at_the_georgia_theatre
      analyzing "2012_live_at_the_georgia_theatre" ...
        [1/3] "01_intro_like_i_am.mkv":
            integrated:  -17.0 LUFS / -6.0 LU
        [2/3] "02_good_one_coming_on.mkv":
            integrated:  -15.4 LUFS / -7.6 LU
        [3/3] "03_up_in_smoke.mkv":
            integrated:  -16.0 LUFS / -7.0 LU
        [ALBUM]:
            integrated:  -16.1 LUFS / -6.9 LU
      done.
      

      4.2. Applying the Gain

      With the help of BS1770GAIN we can adjust the loudness on the fly. There are two ways to achieve this:

      In each case we have to instruct BS1770GAIN where to write the output files by means of the -o/--output switch which has to point to the output folder. If we want BS1770GAIN to really apply the gain and not just to write tags to the files we also have to supply the -a/--apply switch. Two examples follow in order to illustrate this.

      The first example shows how to just write REPLAYGAIN tags to the output files. In this case we only have to supply the -o/--output switch:

      $ bs1770gain ~/2012_live_at_the_georgia_theatre -o ./test
      /home/home/number-3/2012_live_at_the_georgia_theatre
      analyzing "2012_live_at_the_georgia_theatre" ...
        [1/3] "01_intro_like_i_am.mkv":
            integrated:  -16.2 LUFS / -6.8 LU
        [2/3] "02_good_one_coming_on.mkv":
            integrated:  -15.9 LUFS / -7.1 LU
        [3/3] "03_up_in_smoke.mkv":
            integrated:  -15.6 LUFS / -7.4 LU
        [ALBUM]:
            integrated:  -15.9 LUFS / -7.1 LU
      remuxing "2012_live_at_the_georgia_theatre" ...
        [1/3] "01_intro_like_i_am.mkv" ... done.
        [2/3] "02_good_one_coming_on.mkv" ... done.
        [3/3] "03_up_in_smoke.mkv" ... done.
      done.
      

      We can convince ourselves that there are indeed REPLAYGAIN tags written to the files and that the video and the audio streams are not altered. To that means we make use of the -l/--list switch:

      $ bs1770gain ./test/2012_live_at_the_georgia_theatre -l
      ./test/2012_live_at_the_georgia_theatre
      Input #0, matroska,webm, from &./test/2012_live_at_the_georgia_theatre/01_intro_like_i_am.mkv&:
        Metadata:
          title           : Intro / Like I Am
          REPLAYGAIN_TRACK_GAIN: -6.81 LU
          CREATION_TIME   : 2013-02-09 13:41:04
          ARTIST          : Blackberry Smoke
          ALBUM           : Live At The Georgia Theatre
          YEAR            : 2012
          DISC            : 1/1
          track           : 1
          GENRE           : Rock
          REPLAYGAIN_ALBUM_GAIN: -7.05 LU
          REPLAYGAIN_ALGORITHM: ITU-R BS.1770
          REPLAYGAIN_REFERENCE_LOUDNESS: -23.00
          ENCODER         : Lavf56.15.101
        Duration: 00:05:15.36, start: 0.033000, bitrate: 7516 kb/s
          Stream #0:0: Video: mpeg2video (Main), yuv420p(tv, smpte170m), 720x480 [SAR 32:27 DAR 16:9], max. 8700 kb/s, SAR 186:157 DAR 279:157, 59.94 fps, 59.94 tbr, 1k tbn, 59.94 tbc (default)
          Stream #0:1: Audio: ac3, 48000 Hz, stereo, fltp, 448 kb/s (default)
      Input #0, matroska,webm, from &./test/2012_live_at_the_georgia_theatre/02_good_one_coming_on.mkv&:
        Metadata:
          title           : Good One Coming On
          REPLAYGAIN_TRACK_GAIN: -7.05 LU
          CREATION_TIME   : 2013-02-09 13:46:45
          ARTIST          : Blackberry Smoke
          ALBUM           : Live At The Georgia Theatre
          YEAR            : 2012
          DISC            : 1/1
          track           : 2
          GENRE           : Rock
          REPLAYGAIN_ALBUM_GAIN: -7.05 LU
          REPLAYGAIN_ALGORITHM: ITU-R BS.1770
          REPLAYGAIN_REFERENCE_LOUDNESS: -23.00
          ENCODER         : Lavf56.15.101
        Duration: 00:03:37.27, start: 0.033000, bitrate: 7741 kb/s
          Stream #0:0: Video: mpeg2video (Main), yuv420p(tv, smpte170m), 720x480 [SAR 32:27 DAR 16:9], max. 8700 kb/s, SAR 186:157 DAR 279:157, 59.94 fps, 59.94 tbr, 1k tbn, 59.94 tbc (default)
          Stream #0:1: Audio: ac3, 48000 Hz, stereo, fltp, 448 kb/s (default)
      Input #0, matroska,webm, from &./test/2012_live_at_the_georgia_theatre/03_up_in_smoke.mkv&:
        Metadata:
          title           : Up In Smoke
          REPLAYGAIN_TRACK_GAIN: -7.37 LU
          CREATION_TIME   : 2013-02-09 10:09:16
          ARTIST          : Blackberry Smoke
          ALBUM           : Live At The Georgia Theatre
          YEAR            : 2012
          DISC            : 1/1
          track           : 3
          GENRE           : Rock
          REPLAYGAIN_ALBUM_GAIN: -7.05 LU
          REPLAYGAIN_ALGORITHM: ITU-R BS.1770
          REPLAYGAIN_REFERENCE_LOUDNESS: -23.00
          ENCODER         : Lavf56.15.101
        Duration: 00:03:33.77, start: 0.033000, bitrate: 8151 kb/s
          Stream #0:0: Video: mpeg2video (Main), yuv420p(tv, smpte170m), 720x480 [SAR 32:27 DAR 16:9], max. 8700 kb/s, SAR 186:157 DAR 279:157, 59.94 fps, 59.94 tbr, 1k tbn, 59.94 tbc (default)
          Stream #0:1: Audio: ac3, 48000 Hz, stereo, fltp, 448 kb/s (default)
      
      The second example deals with really applying the gain. For that order we not only have to supply the -o/--output switch but also the -a/--apply switch:
      $ bs1770gain ~/2012_live_at_the_georgia_theatre -ao ./test
      /home/home/number-3/2012_live_at_the_georgia_theatre
      analyzing "2012_live_at_the_georgia_theatre" ...
        [1/3] "01_intro_like_i_am.mkv":
            integrated:  -16.2 LUFS / -6.8 LU
        [2/3] "02_good_one_coming_on.mkv":
            integrated:  -15.9 LUFS / -7.1 LU
        [3/3] "03_up_in_smoke.mkv":
            integrated:  -15.6 LUFS / -7.4 LU
        [ALBUM]:
            integrated:  -15.9 LUFS / -7.1 LU
      transcoding "2012_live_at_the_georgia_theatre" ...
        [1/3] "01_intro_like_i_am.mkv" ... done.
        [2/3] "02_good_one_coming_on.mkv" ... done.
        [3/3] "03_up_in_smoke.mkv" ... done.
      done.
      

      An obvious difference to the previous example is that BS1770GAIN now uses the term transcoding instead of remuxing. The reason for that is that the streams are now altered and no REPLAYGAIN-tags appear if we make the contents of the transcoded files visible by means of the -l/--list switch:

      $ bs1770gain ./test/2012_live_at_the_georgia_theatre -l
      ./test/2012_live_at_the_georgia_theatre
      Input #0, matroska,webm, from &./test/2012_live_at_the_georgia_theatre/01_intro_like_i_am.mkv&:
        Metadata:
          title           : Intro / Like I Am
          GENRE           : Rock
          CREATION_TIME   : 2013-02-09 13:41:04
          ARTIST          : Blackberry Smoke
          ALBUM           : Live At The Georgia Theatre
          YEAR            : 2012
          DISC            : 1/1
          track           : 1
          ENCODER         : Lavf56.15.101
        Duration: 00:05:16.87, start: 0.033000, bitrate: 8626 kb/s
          Stream #0:0: Video: mpeg2video (Main), yuv420p(tv, smpte170m), 720x480 [SAR 32:27 DAR 16:9], max. 8700 kb/s, SAR 186:157 DAR 279:157, 59.94 fps, 59.94 tbr, 1k tbn, 59.94 tbc (default)
          Stream #0:1: Audio: flac, 48000 Hz, stereo, s32 (24 bit) (default)
      Input #0, matroska,webm, from &./test/2012_live_at_the_georgia_theatre/02_good_one_coming_on.mkv&:
        Metadata:
          title           : Good One Coming On
          GENRE           : Rock
          CREATION_TIME   : 2013-02-09 13:46:45
          ARTIST          : Blackberry Smoke
          ALBUM           : Live At The Georgia Theatre
          YEAR            : 2012
          DISC            : 1/1
          track           : 2
          ENCODER         : Lavf56.15.101
        Duration: 00:03:38.77, start: 0.033000, bitrate: 8827 kb/s
          Stream #0:0: Video: mpeg2video (Main), yuv420p(tv, smpte170m), 720x480 [SAR 32:27 DAR 16:9], max. 8700 kb/s, SAR 186:157 DAR 279:157, 59.94 fps, 59.94 tbr, 1k tbn, 59.94 tbc (default)
          Stream #0:1: Audio: flac, 48000 Hz, stereo, s32 (24 bit) (default)
      Input #0, matroska,webm, from &./test/2012_live_at_the_georgia_theatre/03_up_in_smoke.mkv&:
        Metadata:
          title           : Up In Smoke
          GENRE           : Rock
          CREATION_TIME   : 2013-02-09 10:09:16
          ARTIST          : Blackberry Smoke
          ALBUM           : Live At The Georgia Theatre
          YEAR            : 2012
          DISC            : 1/1
          track           : 3
          ENCODER         : Lavf56.15.101
        Duration: 00:03:35.27, start: 0.033000, bitrate: 9266 kb/s
          Stream #0:0: Video: mpeg2video (Main), yuv420p(tv, smpte170m), 720x480 [SAR 32:27 DAR 16:9], max. 8700 kb/s, SAR 186:157 DAR 279:157, 59.94 fps, 59.94 tbr, 1k tbn, 59.94 tbc (default)
          Stream #0:1: Audio: flac, 48000 Hz, stereo, s32 (24 bit) (default)
      

      The most important observation is that the audio stream now is a 24 bit FLAC and no longer an AC3.

      It may happen that it is not appropriate to base the gain on the measurement of the integrated loudness but insteed on the maximum shorterm loudness or on the maximum momentary loudness. For that means there is the -u/--use switch which has to be supplied with the method to use, i.e. integrated, shorterm, or momentary. The following illustrates this:

      $ bs1770gain ~/2012_live_at_the_georgia_theatre -o ./test -u shortterm
      /home/home/number-3/2012_live_at_the_georgia_theatre
      analyzing "2012_live_at_the_georgia_theatre" ...
        [1/3] "01_intro_like_i_am.mkv":
            shortterm:  -12.3 LUFS / -10.7 LU
        [2/3] "02_good_one_coming_on.mkv":
            shortterm:  -12.0 LUFS / -11.0 LU
        [3/3] "03_up_in_smoke.mkv":
            shortterm:  -12.3 LUFS / -10.7 LU
        [ALBUM]:
            shortterm:  -12.0 LUFS / -11.0 LU
      remuxing "2012_live_at_the_georgia_theatre" ...
        [1/3] "01_intro_like_i_am.mkv" ... done.
        [2/3] "02_good_one_coming_on.mkv" ... done.
        [3/3] "03_up_in_smoke.mkv" ... done.
      done.
      

      4.3. Experimental Options

      We can imagine the ITU-R BS.1770 measurement device as a blackbox where time after time portions of the audio with the same length

      Such portions of audio are called a block. We assume that at a given time at least one audio block is inside the measurement device, but in general there are more than one are there.

      The measurement device does some sophisticated calculation on the audio blocks currently inside with the loudness as the result. We don&t want to go into all the details here but it should be clear that the result depends at least on the following:

      EBU R128 defines two such measurement devices,

      The momentary device has the following properties:

      wheras the shorttime device has the following: After all we can calculate 6 measures from the two blocks, two of them are non-standard:

      This gives rise to a variety of possible parameters if one takes into account that it is possible to customize measurement devices themselfs (cf. "experimental options" under "command line syntax" below).

      Finally we give an example on how to RG tag with the non-standard measure shortterm mean loudness:

      $ ./bs1770gain ~/2012_live_at_the_georgia_theatre -o ./test -u shortterm-mean
      /home/home/2012_live_at_the_georgia_theatre
      analyzing "2012_live_at_the_georgia_theatre" ...
        [1/3] "01_intro_like_i_am.mkv":         
            shortterm mean:  -16.2 LUFS / -6.8 LU
        [2/3] "02_good_one_coming_on.mkv":         
            shortterm mean:  -16.0 LUFS / -7.0 LU
        [3/3] "03_up_in_smoke.mkv":         
            shortterm mean:  -15.6 LUFS / -7.4 LU
        [ALBUM]:
            shortterm mean:  -16.0 LUFS / -7.0 LU
      remuxing "2012_live_at_the_georgia_theatre" ...
        [1/3] "01_intro_like_i_am.mkv" ... done.
        [2/3] "02_good_one_coming_on.mkv" ... done.
        [3/3] "03_up_in_smoke.mkv" ... done.
      done.
      

      5. Command Line Syntax

      $ bs1770gain -h
      BS1770GAIN 0.4.8, Copyright (C) Peter Belkner 2014-2015.
      http://bs1770gain.sourceforge.net/
      
      Usage:  bs1770gain [options] <file/dir> [<file/dir> ...]
      
      Options:
       -h,--help:  print this message and exit
       -i,--integrated:  calculate integrated loudness
       -s,--shorterm:  calculate maximum shortterm loudness
       -m,--momentary:  claculate maximum momentary loudness
       -r,--range:  calculate loudness range
       -p,--samplepeak:  calculate maximum sample peak
       -t,--truepeak:  calculate maximum true peak
       -b <timestamp>,--begin <timestamp>:  begin decoding at
         timestamp (in microseconds, format: hh:mm:ss.mus)
       -d <duration>,--duration <duration>:  let decoding
         last duration (in microseconds, format: hh:mm:ss.mus)
       -u <method>,--use <method>:  base replay gain calculation
         on method (with respect to the -a/--apply and -o/--output
         options),
         methods:  "integrated" (default), "shortterm", or
         "momentary"
         experimental methods:  "momentary-mean" (same as
         "integrated"), "momentary-maximum" (same as "momentary"),
         "shortterm-mean", or "shortterm-maximum" (same as
         "shortterm")
       -a:  apply the EBU/ATSC/RG album gain to the output
         (in conjunction with the -o/--output option)
       -o <folder>,--output <folder>:  write RG tags
         or apply the EBU/ATSC/RG gain, respectively,
         and output to folder
       -f <file>,--file <file>:  write analysis to file
       -x,--extensions:  enable following extensions/defaults:
         1) rename files according to TITLE tag
         2) read metadata from per-folder CSV file "folder.csv"
         3) copy file "folder.jpg" from source to destination
            folder
         4) automatically add the TRACK and DISC tags
         5) calculate maximum true peak
         6) convert to stereo
       -l,--list:  print FFmpeg format/stream information
       --ebu:  calculate replay gain according to EBU R128
         (-23.0 LUFS, default)
       --atsc:  calculate replay gain according to ATSC A/85
         (-24.0 LUFS)
       --replaygain:  calculate replay gain according to
         ReplayGain 2.0 (-18.0 LUFS)
       --track-tags:  write track tags
       --album-tags:  write album tags
       --unit <unit>:  write tags with <unit>
       --apply <q>:  apply the EBU/ATSC/RG gain to the output
         (in conjunction with the -o/--output option),
         q=0.0 (album gain) ... 1.0 (track gain),
         default:  0.0 (album gain)
       --audio <index>:  select audio index (corresponds to
         [0:<index>] in FFmpeg listing, cf. -l/--list option)
       --video <index>:  select video index (corresponds to
         [0:<index>] in FFmpeg listing, cf. -l/--list option)
       --stereo:  convert to stereo
       --drc <float>:  set AC3 dynamic range compression (DRC)
       --extension <extension>:  enable extension out of
         "rename":  rename files according to TITLE tag
         "csv":  read metadata from per-folder CSV file "folder.csv"
         "jpg":  copy file "folder.jpg" from source to destination
            folder
         "tags":  automatically add the TRACK and DISC tags
       --format <format>:  convert to format
       --loglevel <level>:  set loglevel,
         level:  "quiet", "panic", "fatal", "error", "warning",
         "info", "verbose", "debug"
       --xml:  print results in xml format
       --time:  print out duration of program invocation
       --norm <float>:  norm loudness to float.
      
      Experimental options:
      1) momentary block
       --momentary-mean:  calculate mean loudness based on
         momentary block (same as --integrated)
       --momentary-maximum:  calculate maximum loudness based
         on momentary block (same as --momentary)
       --momentary-range:  calculate loudness range based on
         momentary block
       --momentary-length <ms>:  length of momentary block
         in milliseconds (default: 400)
       --momentary-overlap <percent>:  overlap of momentary
         block in percent (default: 75)
       --momentary-mean-gate <gate>:  silence gate for mean
         measurement of momentary block (default: -10.0)
       --momentary-range-gate <gate>:  silence gate for range
         measurement of momentary block (default: -20.0)
       --momentary-range-lower-bound <float>:  lower bound for
         range measurement of momentary block (default: 0.1)
       --momentary-range-upper-bound <float>:  upper bound for
         range measurement of momentary block (default: 0.95)
      2) shortterm block
       --shortterm-mean:  calculate mean loudness based on
         shortterm block
       --shortterm-maximum:  calculate maximum loudness based
         on shortterm block (same as --shortterm)
       --shortterm-range:  calculate loudness range based on
         shortterm block (same as --range)
       --shortterm-length <ms>:  length of shortterm block
         in milliseconds (default: 3000)
       --shortterm-overlap <percent>:  overlap of shortterm
         block in percent (default: 67)
       --shortterm-mean-gate <gate>:  silence gate for mean
         measurement of shortterm block (default: -10.0)
       --shortterm-range-gate <gate>:  silence gate for range
         measurement of shortterm block (default: -20.0)
       --shortterm-range-lower-bound <float>:  lower bound for
         range measurement of shortterm block (default: 0.1)
       --shortterm-range-upper-bound <float>:  upper bound for
         range measurement of shortterm block (default: 0.95)
      
      Command line arguments may appear in any order.
      

      6. Test Cases

      Results for the EBU R128 test vector: