slhck / ffmpeg-normalize

Audio Normalization for Python/ffmpeg
MIT License
1.28k stars 118 forks source link

"Could not create Header" error appears when normalizing ".m4a" input specifying ".wav" output #174

Closed loshlee closed 2 years ago

loshlee commented 2 years ago

:warning: Please read this carefully! If you do not fill out this information, your bug report may be closed.

Expected behavior A clear and concise description of what you expected to happen. Execution of "ffmpeg-normalize" so that the default method is used to normalize an ".m4a" audio file and output to a ".wav" file in the default (but specified) "normalized" director. There appears to be no logistical issue with the command because a conversion using the following ffmpeg command executes successfully: ffmpeg -i ~/Desktop/caboodle/input\ files/MyTitle.m4a ~/Desktop/caboodle/input\ files/normalized/MyTitle.wav

Actual behavior What happened? Error for .wav file creation appeared in Terminal output: "Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument"

Command The exact command you were trying to run: ffmpeg-normalize ~/Desktop/caboodle/input\ files/MyTitle.m4a -o ~/Desktop/caboodle/input\ files/MyTitle.wav

<enter command here>

Any output you get when running the command with the --debug flag:

<add output here>
WARNING: The sample rate will automatically be set to 192 kHz by the loudnorm filter. Specify -ar/--sample-rate to override it.
ERROR: Error while running command /opt/homebrew/bin/ffmpeg -y -nostdin -i '/Users/me/Desktop/caboodle/input files/MyTitle.m4a' -filter_complex '[0:0]loudnorm=i=-23.0:lra=7.0:tp=-2.0:offset=-0.42:measured_i=-19.56:measured_lra=11.2:measured_tp=-2.37:measured_thresh=-29.93:linear=true:print_format=json[norm0]' -map_metadata 0 -map_metadata:s:a:0 0:s:a:0 -map_metadata:s:v:0 0:s:v:0 -map_chapters 0 -map 0:1 -c:v copy -map '[norm0]' -c:a:0 pcm_s16le -c:s copy /var/folders/2f/9ff5q0dx38v2j7crnr887ypw0000gr/T/hd7a6tj8.wav! Error: Error running command ['/opt/homebrew/bin/ffmpeg', '-y', '-nostdin', '-i', '/Users/me/Desktop/caboodle/input files/MyTitle.m4a', '-filter_complex', '[0:0]loudnorm=i=-23.0:lra=7.0:tp=-2.0:offset=-0.42:measured_i=-19.56:measured_lra=11.2:measured_tp=-2.37:measured_thresh=-29.93:linear=true:print_format=json[norm0]', '-map_metadata', '0', '-map_metadata:s:a:0', '0:s:a:0', '-map_metadata:s:v:0', '0:s:v:0', '-map_chapters', '0', '-map', '0:1', '-c:v', 'copy', '-map', '[norm0]', '-c:a:0', 'pcm_s16le', '-c:s', 'copy', '/var/folders/2f/9ff5q0dx38v2j7crnr887ypw0000gr/T/hd7a6tj8.wav']: ffmpeg version N-106624-g391ce570c8 Copyright (c) 2000-2022 the FFmpeg developers
built with Apple clang version 13.1.6 (clang-1316.0.21.2.3)
configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/HEAD-391ce57_1 --enable-shared --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libaom --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-demuxer=dash --enable-opencl --enable-audiotoolbox --enable-videotoolbox --enable-neon --disable-htmlpages --enable-libfdk-aac --enable-libtwolame --enable-nonfree
libavutil      57. 24.101 / 57. 24.101
libavcodec     59. 26.100 / 59. 26.100
libavformat    59. 22.100 / 59. 22.100
libavdevice    59.  6.100 / 59.  6.100
libavfilter     8. 33.100 /  8. 33.100
libswscale      6.  6.100 /  6.  6.100
libswresample   4.  6.100 /  4.  6.100
libpostproc    56.  5.100 / 56.  5.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x136704300] stream 0, timescale not set
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/me/Desktop/caboodle/input files/MyTitle.m4a':
Metadata:
major_brand     : M4A
minor_version   : 0
compatible_brands: M4A mp42isom
creation_time   : 2013-09-10T02:49:00.000000Z
:
Duration: 00:08:59.21, start: 0.000000, bitrate: 656 kb/s
Stream #0:0[0x1](eng): Audio: alac (alac / 0x63616C61), 48000 Hz, stereo, s16p, 646 kb/s (default)
Metadata:
creation_time   : 2013-09-10T02:49:00.000000Z
handler_name    : ?Apple Sound Media Handler
vendor_id       : [0][0][0][0]
Stream #0:1[0x0]: Video: png, rgb24(pc), 200x200, 90k tbr, 90k tbn (attached pic)
Stream mapping:
Stream #0:0 (alac) -> loudnorm:default
Stream #0:1 -> #0:0 (copy)
loudnorm:default -> Stream #0:1 (pcm_s16le)
[wav @ 0x136707ea0] WAVE files have exactly one stream
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:1 --
[Parsed_loudnorm_0 @ 0x137c044b0]
{
"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!
Traceback (most recent call last):
  File "/opt/homebrew/bin/ffmpeg-normalize", line 8, in <module>
    sys.exit(main())
  File "/opt/homebrew/lib/python3.9/site-packages/ffmpeg_normalize/__main__.py", line 544, in main
    ffmpeg_normalize.run_normalization()
  File "/opt/homebrew/lib/python3.9/site-packages/ffmpeg_normalize/_ffmpeg_normalize.py", line 195, in run_normalization
    raise e
  File "/opt/homebrew/lib/python3.9/site-packages/ffmpeg_normalize/_ffmpeg_normalize.py", line 184, in run_normalization
    media_file.run_normalization()
  File "/opt/homebrew/lib/python3.9/site-packages/ffmpeg_normalize/_media_file.py", line 162, in run_normalization
    for _ in self._second_pass():
  File "/opt/homebrew/lib/python3.9/site-packages/ffmpeg_normalize/_media_file.py", line 369, in _second_pass
    raise e
  File "/opt/homebrew/lib/python3.9/site-packages/ffmpeg_normalize/_media_file.py", line 358, in _second_pass
    raise e
  File "/opt/homebrew/lib/python3.9/site-packages/ffmpeg_normalize/_media_file.py", line 350, in _second_pass
    for progress in cmd_runner.run_ffmpeg_command():
  File "/opt/homebrew/lib/python3.9/site-packages/ffmpeg_normalize/_cmd_utils.py", line 55, in run_ffmpeg_command
    for progress in ff.run_command_with_progress():
  File "/opt/homebrew/lib/python3.9/site-packages/ffmpeg_progress_yield/ffmpeg_progress_yield.py", line 107, in run_command_with_progress
    raise RuntimeError(
RuntimeError: Error running command ['/opt/homebrew/bin/ffmpeg', '-y', '-nostdin', '-i', '/Users/me/Desktop/caboodle/input files/MyTitle.m4a', '-filter_complex', '[0:0]loudnorm=i=-23.0:lra=7.0:tp=-2.0:offset=-0.42:measured_i=-19.56:measured_lra=11.2:measured_tp=-2.37:measured_thresh=-29.93:linear=true:print_format=json[norm0]', '-map_metadata', '0', '-map_metadata:s:a:0', '0:s:a:0', '-map_metadata:s:v:0', '0:s:v:0', '-map_chapters', '0', '-map', '0:1', '-c:v', 'copy', '-map', '[norm0]', '-c:a:0', 'pcm_s16le', '-c:s', 'copy', '/var/folders/2f/9ff5q0dx38v2j7crnr887ypw0000gr/T/hd7a6tj8.wav']: ffmpeg version N-106624-g391ce570c8 Copyright (c) 2000-2022 the FFmpeg developers
built with Apple clang version 13.1.6 (clang-1316.0.21.2.3)
configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/HEAD-391ce57_1 --enable-shared --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libaom --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-demuxer=dash --enable-opencl --enable-audiotoolbox --enable-videotoolbox --enable-neon --disable-htmlpages --enable-libfdk-aac --enable-libtwolame --enable-nonfree
libavutil      57. 24.101 / 57. 24.101
libavcodec     59. 26.100 / 59. 26.100
libavformat    59. 22.100 / 59. 22.100
libavdevice    59.  6.100 / 59.  6.100
libavfilter     8. 33.100 /  8. 33.100
libswscale      6.  6.100 /  6.  6.100
libswresample   4.  6.100 /  4.  6.100
libpostproc    56.  5.100 / 56.  5.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x136704300] stream 0, timescale not set
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/me/Desktop/caboodle/input files/MyTitle.m4a':
Metadata:
major_brand     : M4A
minor_version   : 0
compatible_brands: M4A mp42isom
creation_time   : 2013-09-10T02:49:00.000000Z
:
Duration: 00:08:59.21, start: 0.000000, bitrate: 656 kb/s
Stream #0:0[0x1](eng): Audio: alac (alac / 0x63616C61), 48000 Hz, stereo, s16p, 646 kb/s (default)
Metadata:
creation_time   : 2013-09-10T02:49:00.000000Z
handler_name    : ?Apple Sound Media Handler
vendor_id       : [0][0][0][0]
Stream #0:1[0x0]: Video: png, rgb24(pc), 200x200, 90k tbr, 90k tbn (attached pic)
Stream mapping:
Stream #0:0 (alac) -> loudnorm:default
Stream #0:1 -> #0:0 (copy)
loudnorm:default -> Stream #0:1 (pcm_s16le)
[wav @ 0x136707ea0] WAVE files have exactly one stream
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:1 --
[Parsed_loudnorm_0 @ 0x137c044b0]
{
"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!
┌─(~)──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────(llee@Treble:s000)─┐
└─(13:31:20)──> ffmpeg-normalize -debug  ~/Desktop/caboodle/input\ files/MyTitle.m4a -o ~/Desktop/caboodle/input\ files/MyTitle.wav         1 ↵ ──(Fri,Apr15)─┘
DEBUG: found executable in path: /opt/homebrew/bin/ffmpeg
DEBUG: found executable in path: /opt/homebrew/bin/ffmpeg
DEBUG: Running command: ['/opt/homebrew/bin/ffmpeg', '-filters']
DEBUG: Parsing streams of /Users/llee/Desktop/caboodle/input files/MyTitle.m4a
DEBUG: Running command: ['/opt/homebrew/bin/ffmpeg', '-i', '/Users/me/Desktop/caboodle/input files/MyTitle.m4a', '-c', 'copy', '-t', '0', '-map', '0', '-f', 'null', '/dev/null']
DEBUG: Stream parsing command output:
DEBUG: ffmpeg version N-106624-g391ce570c8 Copyright (c) 2000-2022 the FFmpeg developers
  built with Apple clang version 13.1.6 (clang-1316.0.21.2.3)
  configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/HEAD-391ce57_1 --enable-shared --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libaom --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-demuxer=dash --enable-opencl --enable-audiotoolbox --enable-videotoolbox --enable-neon --disable-htmlpages --enable-libfdk-aac --enable-libtwolame --enable-nonfree
  libavutil      57. 24.101 / 57. 24.101
  libavcodec     59. 26.100 / 59. 26.100
  libavformat    59. 22.100 / 59. 22.100
  libavdevice    59.  6.100 / 59.  6.100
  libavfilter     8. 33.100 /  8. 33.100
  libswscale      6.  6.100 /  6.  6.100
  libswresample   4.  6.100 /  4.  6.100
  libpostproc    56.  5.100 / 56.  5.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1466057b0] stream 0, timescale not set
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/me/Desktop/caboodle/input files/MyTitle.m4a':
  Metadata:
    major_brand     : M4A 
    minor_version   : 0
    compatible_brands: M4A mp42isom
    creation_time   : 2013-09-10T02:49:00.000000Z
                    : 
  Duration: 00:08:59.21, start: 0.000000, bitrate: 656 kb/s
  Stream #0:0[0x1](eng): Audio: alac (alac / 0x63616C61), 48000 Hz, stereo, s16p, 646 kb/s (default)
    Metadata:
      creation_time   : 2013-09-10T02:49:00.000000Z
      handler_name    : ?Apple Sound Media Handler
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x0]: Video: png, rgb24(pc), 200x200, 90k tbr, 90k tbn (attached pic)
Output #0, null, to '/dev/null':
  Metadata:
    major_brand     : M4A 
    minor_version   : 0
    compatible_brands: M4A mp42isom
                        : 
    encoder         : Lavf59.22.100
  Stream #0:0(eng): Audio: alac (alac / 0x63616C61), 48000 Hz, stereo, s16p, 646 kb/s (default)
    Metadata:
      creation_time   : 2013-09-10T02:49:00.000000Z
      handler_name    : ?Apple Sound Media Handler
      vendor_id       : [0][0][0][0]
  Stream #0:1: Video: png, rgb24(pc), 200x200, q=2-31, 90k tbr, 90k tbn (attached pic)
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=    0 fps=0.0 q=-1.0 Lsize=N/A time=00:00:00.00 bitrate=N/A speed=   0x    
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

DEBUG: Found duration: 539.021 s
DEBUG: Found audio stream at index 0
DEBUG: Found video stream at index 1
INFO: Normalizing file MyTitle.m4a (1 of 1)
DEBUG: Running normalization for /Users/llee/Desktop/caboodle/input files/MyTitle.m4a
DEBUG: Parsing normalization info for /Users/llee/Desktop/caboodle/input files/MyTitle.m4a
INFO: Running first pass loudnorm filter for stream 0
DEBUG: Running command: ['/opt/homebrew/bin/ffmpeg', '-nostdin', '-y', '-i', '/Users/me/Desktop/caboodle/input files/MyTitle.m4a', '-filter_complex', '[0:0]loudnorm=i=-23.0:lra=7.0:tp=-2.0:offset=0.0:print_format=json', '-vn', '-sn', '-f', 'null', '/dev/null']
DEBUG: ffmpeg output: ffmpeg version N-106624-g391ce570c8 Copyright (c) 2000-2022 the FFmpeg developers
built with Apple clang version 13.1.6 (clang-1316.0.21.2.3)
configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/HEAD-391ce57_1 --enable-shared --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libaom --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-demuxer=dash --enable-opencl --enable-audiotoolbox --enable-videotoolbox --enable-neon --disable-htmlpages --enable-libfdk-aac --enable-libtwolame --enable-nonfree
libavutil      57. 24.101 / 57. 24.101
libavcodec     59. 26.100 / 59. 26.100
libavformat    59. 22.100 / 59. 22.100
libavdevice    59.  6.100 / 59.  6.100
libavfilter     8. 33.100 /  8. 33.100
libswscale      6.  6.100 /  6.  6.100
libswresample   4.  6.100 /  4.  6.100
libpostproc    56.  5.100 / 56.  5.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x13ef04300] stream 0, timescale not set
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/me/Desktop/caboodle/input files/MyTitle.m4a':
Metadata:
major_brand     : M4A
minor_version   : 0
compatible_brands: M4A mp42isom
creation_time   : 2013-09-10T02:49:00.000000Z
:
Duration: 00:08:59.21, start: 0.000000, bitrate: 656 kb/s
Stream #0:0[0x1](eng): Audio: alac (alac / 0x63616C61), 48000 Hz, stereo, s16p, 646 kb/s (default)
Metadata:
creation_time   : 2013-09-10T02:49:00.000000Z
handler_name    : ?Apple Sound Media Handler
vendor_id       : [0][0][0][0]
Stream #0:1[0x0]: Video: png, rgb24(pc), 200x200, 90k tbr, 90k tbn (attached pic)
Stream mapping:
Stream #0:0 (alac) -> loudnorm:default
loudnorm:default -> Stream #0:0 (pcm_s16le)
Output #0, null, to '/dev/null':
Metadata:
major_brand     : M4A
minor_version   : 0
compatible_brands: M4A mp42isom
:
encoder         : Lavf59.22.100
Stream #0:0: Audio: pcm_s16le, 192000 Hz, stereo, s16, 6144 kb/s
Metadata:
encoder         : Lavc59.26.100 pcm_s16le
bitrate=N/A
total_size=N/A
out_time_us=0
out_time_ms=0
out_time=00:00:00.000000
dup_frames=0
drop_frames=0
speed=   0x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=18500000
out_time_ms=18500000
out_time=00:00:18.500000
dup_frames=0
drop_frames=0
speed=36.8x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=37800000
out_time_ms=37800000
out_time=00:00:37.800000
dup_frames=0
drop_frames=0
speed=37.6x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=57000000
out_time_ms=57000000
out_time=00:00:57.000000
dup_frames=0
drop_frames=0
speed=37.9x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=76100000
out_time_ms=76100000
out_time=00:01:16.100000
dup_frames=0
drop_frames=0
speed=37.9x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=95200000
out_time_ms=95200000
out_time=00:01:35.200000
dup_frames=0
drop_frames=0
speed=37.9x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=114400000
out_time_ms=114400000
out_time=00:01:54.400000
dup_frames=0
drop_frames=0
speed=  38x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=133400000
out_time_ms=133400000
out_time=00:02:13.400000
dup_frames=0
drop_frames=0
speed=  38x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=152600000
out_time_ms=152600000
out_time=00:02:32.600000
dup_frames=0
drop_frames=0
speed=  38x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=171800000
out_time_ms=171800000
out_time=00:02:51.800000
dup_frames=0
drop_frames=0
speed=  38x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=190800000
out_time_ms=190800000
out_time=00:03:10.800000
dup_frames=0
drop_frames=0
speed=  38x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=210000000
out_time_ms=210000000
out_time=00:03:30.000000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=229100000
out_time_ms=229100000
out_time=00:03:49.100000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=248200000
out_time_ms=248200000
out_time=00:04:08.200000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=267300000
out_time_ms=267300000
out_time=00:04:27.300000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=286400000
out_time_ms=286400000
out_time=00:04:46.400000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=305400000
out_time_ms=305400000
out_time=00:05:05.400000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=324600000
out_time_ms=324600000
out_time=00:05:24.600000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=343800000
out_time_ms=343800000
out_time=00:05:43.800000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=363000000
out_time_ms=363000000
out_time=00:06:03.000000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=382200000
out_time_ms=382200000
out_time=00:06:22.200000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=401200000
out_time_ms=401200000
out_time=00:06:41.200000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=420400000
out_time_ms=420400000
out_time=00:07:00.400000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=439500000
out_time_ms=439500000
out_time=00:07:19.500000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=458600000
out_time_ms=458600000
out_time=00:07:38.600000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=477600000
out_time_ms=477600000
out_time=00:07:57.600000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=497000000
out_time_ms=497000000
out_time=00:08:17.000000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=516000000
out_time_ms=516000000
out_time=00:08:36.000000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=535000000
out_time_ms=535000000
out_time=00:08:55.000000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
size=N/A time=00:08:59.22 bitrate=N/A speed=38.2x
bitrate=N/A
total_size=N/A
out_time_us=539221333
out_time_ms=539221333
out_time=00:08:59.221333
dup_frames=0
drop_frames=0
speed=38.2x
progress=end
video:0kB audio:404416kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[Parsed_loudnorm_0 @ 0x13ef0e8f0]
{
"input_i" : "-19.56",
"input_tp" : "-2.37",
"input_lra" : "11.20",
"input_thresh" : "-29.93",
"output_i" : "-22.58",
"output_tp" : "-5.82",
"output_lra" : "7.30",
"output_thresh" : "-32.82",
"normalization_type" : "dynamic",
"target_offset" : "-0.42"
}
DEBUG: Loudnorm first pass command output:
DEBUG: ffmpeg version N-106624-g391ce570c8 Copyright (c) 2000-2022 the FFmpeg developers
built with Apple clang version 13.1.6 (clang-1316.0.21.2.3)
configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/HEAD-391ce57_1 --enable-shared --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libaom --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-demuxer=dash --enable-opencl --enable-audiotoolbox --enable-videotoolbox --enable-neon --disable-htmlpages --enable-libfdk-aac --enable-libtwolame --enable-nonfree
libavutil      57. 24.101 / 57. 24.101
libavcodec     59. 26.100 / 59. 26.100
libavformat    59. 22.100 / 59. 22.100
libavdevice    59.  6.100 / 59.  6.100
libavfilter     8. 33.100 /  8. 33.100
libswscale      6.  6.100 /  6.  6.100
libswresample   4.  6.100 /  4.  6.100
libpostproc    56.  5.100 / 56.  5.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x13ef04300] stream 0, timescale not set
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/me/Desktop/caboodle/input files/MyTitle.m4a':
Metadata:
major_brand     : M4A
minor_version   : 0
compatible_brands: M4A mp42isom
creation_time   : 2013-09-10T02:49:00.000000Z
:
Duration: 00:08:59.21, start: 0.000000, bitrate: 656 kb/s
Stream #0:0[0x1](eng): Audio: alac (alac / 0x63616C61), 48000 Hz, stereo, s16p, 646 kb/s (default)
Metadata:
creation_time   : 2013-09-10T02:49:00.000000Z
handler_name    : ?Apple Sound Media Handler
vendor_id       : [0][0][0][0]
Stream #0:1[0x0]: Video: png, rgb24(pc), 200x200, 90k tbr, 90k tbn (attached pic)
Stream mapping:
Stream #0:0 (alac) -> loudnorm:default
loudnorm:default -> Stream #0:0 (pcm_s16le)
Output #0, null, to '/dev/null':
Metadata:
major_brand     : M4A
minor_version   : 0
compatible_brands: M4A mp42isom
:
encoder         : Lavf59.22.100
Stream #0:0: Audio: pcm_s16le, 192000 Hz, stereo, s16, 6144 kb/s
Metadata:
encoder         : Lavc59.26.100 pcm_s16le
bitrate=N/A
total_size=N/A
out_time_us=0
out_time_ms=0
out_time=00:00:00.000000
dup_frames=0
drop_frames=0
speed=   0x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=18500000
out_time_ms=18500000
out_time=00:00:18.500000
dup_frames=0
drop_frames=0
speed=36.8x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=37800000
out_time_ms=37800000
out_time=00:00:37.800000
dup_frames=0
drop_frames=0
speed=37.6x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=57000000
out_time_ms=57000000
out_time=00:00:57.000000
dup_frames=0
drop_frames=0
speed=37.9x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=76100000
out_time_ms=76100000
out_time=00:01:16.100000
dup_frames=0
drop_frames=0
speed=37.9x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=95200000
out_time_ms=95200000
out_time=00:01:35.200000
dup_frames=0
drop_frames=0
speed=37.9x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=114400000
out_time_ms=114400000
out_time=00:01:54.400000
dup_frames=0
drop_frames=0
speed=  38x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=133400000
out_time_ms=133400000
out_time=00:02:13.400000
dup_frames=0
drop_frames=0
speed=  38x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=152600000
out_time_ms=152600000
out_time=00:02:32.600000
dup_frames=0
drop_frames=0
speed=  38x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=171800000
out_time_ms=171800000
out_time=00:02:51.800000
dup_frames=0
drop_frames=0
speed=  38x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=190800000
out_time_ms=190800000
out_time=00:03:10.800000
dup_frames=0
drop_frames=0
speed=  38x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=210000000
out_time_ms=210000000
out_time=00:03:30.000000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=229100000
out_time_ms=229100000
out_time=00:03:49.100000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=248200000
out_time_ms=248200000
out_time=00:04:08.200000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=267300000
out_time_ms=267300000
out_time=00:04:27.300000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=286400000
out_time_ms=286400000
out_time=00:04:46.400000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=305400000
out_time_ms=305400000
out_time=00:05:05.400000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=324600000
out_time_ms=324600000
out_time=00:05:24.600000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=343800000
out_time_ms=343800000
out_time=00:05:43.800000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=363000000
out_time_ms=363000000
out_time=00:06:03.000000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=382200000
out_time_ms=382200000
out_time=00:06:22.200000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=401200000
out_time_ms=401200000
out_time=00:06:41.200000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=420400000
out_time_ms=420400000
out_time=00:07:00.400000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=439500000
out_time_ms=439500000
out_time=00:07:19.500000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=458600000
out_time_ms=458600000
out_time=00:07:38.600000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=477600000
out_time_ms=477600000
out_time=00:07:57.600000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=497000000
out_time_ms=497000000
out_time=00:08:17.000000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=516000000
out_time_ms=516000000
out_time=00:08:36.000000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
bitrate=N/A
total_size=N/A
out_time_us=535000000
out_time_ms=535000000
out_time=00:08:55.000000
dup_frames=0
drop_frames=0
speed=38.1x
progress=continue
size=N/A time=00:08:59.22 bitrate=N/A speed=38.2x
bitrate=N/A
total_size=N/A
out_time_us=539221333
out_time_ms=539221333
out_time=00:08:59.221333
dup_frames=0
drop_frames=0
speed=38.2x
progress=end
video:0kB audio:404416kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[Parsed_loudnorm_0 @ 0x13ef0e8f0]
{
"input_i" : "-19.56",
"input_tp" : "-2.37",
"input_lra" : "11.20",
"input_thresh" : "-29.93",
"output_i" : "-22.58",
"output_tp" : "-5.82",
"output_lra" : "7.30",
"output_thresh" : "-32.82",
"normalization_type" : "dynamic",
"target_offset" : "-0.42"
}
DEBUG: Loudnorm stats parsed: {"input_i": "-19.56", "input_tp": "-2.37", "input_lra": "11.20", "input_thresh": "-29.93", "output_i": "-22.58", "output_tp": "-5.82", "output_lra": "7.30", "output_thresh": "-32.82", "normalization_type": "dynamic", "target_offset": "-0.42"}
INFO: Running second pass for /Users/llee/Desktop/caboodle/input files/MyTitle.m4a
WARNING: The sample rate will automatically be set to 192 kHz by the loudnorm filter. Specify -ar/--sample-rate to override it.
DEBUG: Running command: ['/opt/homebrew/bin/ffmpeg', '-y', '-nostdin', '-i', '/Users/me/Desktop/caboodle/input files/MyTitle.m4a', '-filter_complex', '[0:0]loudnorm=i=-23.0:lra=7.0:tp=-2.0:offset=-0.42:measured_i=-19.56:measured_lra=11.2:measured_tp=-2.37:measured_thresh=-29.93:linear=true:print_format=json[norm0]', '-map_metadata', '0', '-map_metadata:s:a:0', '0:s:a:0', '-map_metadata:s:v:0', '0:s:v:0', '-map_chapters', '0', '-map', '0:1', '-c:v', 'copy', '-map', '[norm0]', '-c:a:0', 'pcm_s16le', '-c:s', 'copy', 'bug', '/var/folders/2f/9ff5q0dx38v2j7crnr887ypw0000gr/T/0hteehc0.wav']
ERROR: Error while running command /opt/homebrew/bin/ffmpeg -y -nostdin -i '/Users/me/Desktop/caboodle/input files/MyTitle.m4a' -filter_complex '[0:0]loudnorm=i=-23.0:lra=7.0:tp=-2.0:offset=-0.42:measured_i=-19.56:measured_lra=11.2:measured_tp=-2.37:measured_thresh=-29.93:linear=true:print_format=json[norm0]' -map_metadata 0 -map_metadata:s:a:0 0:s:a:0 -map_metadata:s:v:0 0:s:v:0 -map_chapters 0 -map 0:1 -c:v copy -map '[norm0]' -c:a:0 pcm_s16le -c:s copy bug /var/folders/2f/9ff5q0dx38v2j7crnr887ypw0000gr/T/0hteehc0.wav! Error: Error running command ['/opt/homebrew/bin/ffmpeg', '-y', '-nostdin', '-i', '/Users/me/Desktop/caboodle/input files/MyTitle.m4a', '-filter_complex', '[0:0]loudnorm=i=-23.0:lra=7.0:tp=-2.0:offset=-0.42:measured_i=-19.56:measured_lra=11.2:measured_tp=-2.37:measured_thresh=-29.93:linear=true:print_format=json[norm0]', '-map_metadata', '0', '-map_metadata:s:a:0', '0:s:a:0', '-map_metadata:s:v:0', '0:s:v:0', '-map_chapters', '0', '-map', '0:1', '-c:v', 'copy', '-map', '[norm0]', '-c:a:0', 'pcm_s16le', '-c:s', 'copy', 'bug', '/var/folders/2f/9ff5q0dx38v2j7crnr887ypw0000gr/T/0hteehc0.wav']: ffmpeg version N-106624-g391ce570c8 Copyright (c) 2000-2022 the FFmpeg developers
built with Apple clang version 13.1.6 (clang-1316.0.21.2.3)
configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/HEAD-391ce57_1 --enable-shared --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libaom --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-demuxer=dash --enable-opencl --enable-audiotoolbox --enable-videotoolbox --enable-neon --disable-htmlpages --enable-libfdk-aac --enable-libtwolame --enable-nonfree
libavutil      57. 24.101 / 57. 24.101
libavcodec     59. 26.100 / 59. 26.100
libavformat    59. 22.100 / 59. 22.100
libavdevice    59.  6.100 / 59.  6.100
libavfilter     8. 33.100 /  8. 33.100
libswscale      6.  6.100 /  6.  6.100
libswresample   4.  6.100 /  4.  6.100
libpostproc    56.  5.100 / 56.  5.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x141704300] stream 0, timescale not set
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/me/Desktop/caboodle/input files/MyTitle.m4a':
Metadata:
major_brand     : M4A
minor_version   : 0
compatible_brands: M4A mp42isom
creation_time   : 2013-09-10T02:49:00.000000Z
:
Duration: 00:08:59.21, start: 0.000000, bitrate: 656 kb/s
Stream #0:0[0x1](eng): Audio: alac (alac / 0x63616C61), 48000 Hz, stereo, s16p, 646 kb/s (default)
Metadata:
creation_time   : 2013-09-10T02:49:00.000000Z
handler_name    : ?Apple Sound Media Handler
vendor_id       : [0][0][0][0]
Stream #0:1[0x0]: Video: png, rgb24(pc), 200x200, 90k tbr, 90k tbn (attached pic)
[NULL @ 0x141707ea0] Unable to find a suitable output format for 'bug'
bug: Invalid argument
Traceback (most recent call last):
  File "/opt/homebrew/bin/ffmpeg-normalize", line 8, in <module>
    sys.exit(main())
  File "/opt/homebrew/lib/python3.9/site-packages/ffmpeg_normalize/__main__.py", line 544, in main
    ffmpeg_normalize.run_normalization()
  File "/opt/homebrew/lib/python3.9/site-packages/ffmpeg_normalize/_ffmpeg_normalize.py", line 195, in run_normalization
    raise e
  File "/opt/homebrew/lib/python3.9/site-packages/ffmpeg_normalize/_ffmpeg_normalize.py", line 184, in run_normalization
    media_file.run_normalization()
  File "/opt/homebrew/lib/python3.9/site-packages/ffmpeg_normalize/_media_file.py", line 162, in run_normalization
    for _ in self._second_pass():
  File "/opt/homebrew/lib/python3.9/site-packages/ffmpeg_normalize/_media_file.py", line 369, in _second_pass
    raise e
  File "/opt/homebrew/lib/python3.9/site-packages/ffmpeg_normalize/_media_file.py", line 358, in _second_pass
    raise e
  File "/opt/homebrew/lib/python3.9/site-packages/ffmpeg_normalize/_media_file.py", line 350, in _second_pass
    for progress in cmd_runner.run_ffmpeg_command():
  File "/opt/homebrew/lib/python3.9/site-packages/ffmpeg_normalize/_cmd_utils.py", line 55, in run_ffmpeg_command
    for progress in ff.run_command_with_progress():
  File "/opt/homebrew/lib/python3.9/site-packages/ffmpeg_progress_yield/ffmpeg_progress_yield.py", line 107, in run_command_with_progress
    raise RuntimeError(
RuntimeError: Error running command ['/opt/homebrew/bin/ffmpeg', '-y', '-nostdin', '-i', '/Users/me/Desktop/caboodle/input files/MyTitle.m4a', '-filter_complex', '[0:0]loudnorm=i=-23.0:lra=7.0:tp=-2.0:offset=-0.42:measured_i=-19.56:measured_lra=11.2:measured_tp=-2.37:measured_thresh=-29.93:linear=true:print_format=json[norm0]', '-map_metadata', '0', '-map_metadata:s:a:0', '0:s:a:0', '-map_metadata:s:v:0', '0:s:v:0', '-map_chapters', '0', '-map', '0:1', '-c:v', 'copy', '-map', '[norm0]', '-c:a:0', 'pcm_s16le', '-c:s', 'copy', 'bug', '/var/folders/2f/9ff5q0dx38v2j7crnr887ypw0000gr/T/0hteehc0.wav']: ffmpeg version N-106624-g391ce570c8 Copyright (c) 2000-2022 the FFmpeg developers
built with Apple clang version 13.1.6 (clang-1316.0.21.2.3)
configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/HEAD-391ce57_1 --enable-shared --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libaom --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-demuxer=dash --enable-opencl --enable-audiotoolbox --enable-videotoolbox --enable-neon --disable-htmlpages --enable-libfdk-aac --enable-libtwolame --enable-nonfree
libavutil      57. 24.101 / 57. 24.101
libavcodec     59. 26.100 / 59. 26.100
libavformat    59. 22.100 / 59. 22.100
libavdevice    59.  6.100 / 59.  6.100
libavfilter     8. 33.100 /  8. 33.100
libswscale      6.  6.100 /  6.  6.100
libswresample   4.  6.100 /  4.  6.100
libpostproc    56.  5.100 / 56.  5.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x141704300] stream 0, timescale not set
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/me/Desktop/caboodle/input files/MyTitle.m4a':
Metadata:
major_brand     : M4A
minor_version   : 0
compatible_brands: M4A mp42isom
creation_time   : 2013-09-10T02:49:00.000000Z
:
Duration: 00:08:59.21, start: 0.000000, bitrate: 656 kb/s
Stream #0:0[0x1](eng): Audio: alac (alac / 0x63616C61), 48000 Hz, stereo, s16p, 646 kb/s (default)
Metadata:
creation_time   : 2013-09-10T02:49:00.000000Z
handler_name    : ?Apple Sound Media Handler
vendor_id       : [0][0][0][0]
Stream #0:1[0x0]: Video: png, rgb24(pc), 200x200, 90k tbr, 90k tbn (attached pic)
[NULL @ 0x141707ea0] Unable to find a suitable output format for 'bug'
bug: Invalid argument

Environment (please complete the following information):

slhck commented 2 years ago

Thanks, I see now what the problem is.

Your input has cover art, which is interpreted by ffmpeg as a video stream. By default, ffmpeg-normalize will copy over these input streams. If your output is a WAV file though, it can only contain exactly one audio stream, no cover art/video. This is what is causing the error.

Solution: Add the -vn option to disable the video part.

An alternative could be to choose a different audio codec and output extension/container, like M4A.

loshlee commented 2 years ago

OK, thanks. That one got by me. I wasn't having trouble with .mp3, .aac, or anything else, just .wav. I wrote an AppleScript app that makes it simple to run ffmpeg-normalize on a folder full of source files, either by choice or drop. I'm going to publish on my blog, and I'll probably make a fork and add it there, too. You're welcome to merge it if you think it could do your Mac users any good. Thanks again.

slhck commented 2 years ago

Happy to add a link to your tool! Feel free to send some info once you publish it.

loshlee commented 2 years ago

Thanks. BTW, the easiest workaround I've found, I think, is simply to output to .aif, then to .wav.

loshlee commented 2 years ago

Happy to add a link to your tool! Feel free to send some info once you publish it.

https://prehensileblog.wordpress.com/2022/04/15/create-an-applescript-application-to-drop-or-open-a-folder-of-files-in-ffmpeg-normalize/

slhck commented 2 years ago

I added the article to the README.

loshlee commented 2 years ago

Great! Thanks!