1

Apologies if this is off topic here.

I have dozens of small audio files recorded using iOS VoiceMemo. These files fail to load properly in a web-based experiment that I am trying to run.

When I open the file in Audacity and then export it as .m4a the file then loads.

When I use ffmpeg -i file.m4a -ss 0.0 -copy newfile.m4a the file still doesn't load.

I'd really like to be able to fix all the files using ffmpeg rather than opening each one at a time in Audacity. From what I understand, Audacity is using ffmpeg to do the export.

How can I get ffmpeg to create a file in the same way that the Audacity export is?

The files can be found here:

File 100.m4a fails to load. File aud100m4a exported via Audacity loads. File ff100.m4a copied using ffmpeg fails to load.

https://github.com/amunn/junk

A link to the test HTML code is here:

https://amunn.github.io/junk/

1 Answer 1

2

The original memo file is encoded as alac :

$ mediainfo 100.m4a 
General
Complete name                            : Téléchargements/100.m4a
Format                                   : MPEG-4
Format profile                           : Apple audio with iTunes info
Codec ID                                 : M4A  (M4A /isom/mp42)
File size                                : 164 KiB
Duration                                 : 3 s 900 ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 344 kb/s
Track name                               : 100
Encoded date                             : UTC 2022-06-10 00:59:40
Tagged date                              : UTC 2022-06-10 00:59:48
Writing application                      : com.apple.VoiceMemos (Jingying's iPhone (null))
voice-memo-uuid                          : 3137F094-78C9-4024-926D-F173E4B35A35

Audio
ID                                       : 1
Format                                   : ALAC
Codec ID                                 : alac
Codec ID/Info                            : Apple Lossless Audio Codec
Duration                                 : 3 s 900 ms
Source duration                          : 3 s 925 ms
Bit rate mode                            : Variable
Bit rate                                 : 339 kb/s
Channel(s)                               : 1 channel
Sampling rate                            : 48.0 kHz
Bit depth                                : 16 bits
Stream size                              : 161 KiB (99%)
Source stream size                       : 161 KiB (99%)
Title                                    : Core Media Audio
Encoded date                             : UTC 2022-06-10 00:59:40
Tagged date                              : UTC 2022-06-10 00:59:48

The audacity export has been transcoded to aac-lc

$ mediainfo Téléchargements/aud100.m4a 
General
Complete name                            : Téléchargements/aud100.m4a
Format                                   : MPEG-4
Format profile                           : Apple audio with iTunes info
Codec ID                                 : M4A  (isom/iso2)
File size                                : 94.4 KiB
Duration                                 : 3 s 370 ms
Overall bit rate mode                    : Constant
Overall bit rate                         : 230 kb/s
Track name                               : 100
Writing application                      : Lavf55.33.100

Audio
ID                                       : 1
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 3 s 370 ms
Duration_LastFrame                       : -1 ms
Bit rate mode                            : Constant
Bit rate                                 : 226 kb/s
Channel(s)                               : 1 channel
Channel layout                           : C
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 93.1 KiB (99%)
Default                                  : Yes
Alternate group                          : 1

and the ffmpeg output has the same codec than the original file :

$ mediainfo Téléchargements/ff100.m4a 
General
Complete name                            : Téléchargements/ff100.m4a
Format                                   : MPEG-4
Format profile                           : Apple audio with iTunes info
Codec ID                                 : M4A  (M4A /isom/iso2)
File size                                : 162 KiB
Duration                                 : 3 s 926 ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 339 kb/s
Track name                               : 100
Writing application                      : Lavf59.16.100

Audio
ID                                       : 1
Format                                   : ALAC
Codec ID                                 : alac
Codec ID/Info                            : Apple Lossless Audio Codec
Duration                                 : 3 s 926 ms
Bit rate mode                            : Variable
Bit rate                                 : 337 kb/s
Channel(s)                               : 1 channel
Sampling rate                            : 48.0 kHz
Bit depth                                : 16 bits
Stream size                              : 161 KiB (99%)
Title                                    : Core Media Audio
Default                                  : Yes
Alternate group                          : 1

I would think that the alac codec is not readable by your web browser and if you want to use ffmpeg you must explicitly ask for a transcoding, as an example :

$ ffmpeg -i 100.m4a -c:a aac anotherff100.m4a
ffmpeg version 4.2.7-0ubuntu0.1 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1)
  configuration: --prefix=/usr --extra-version=0ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '100.m4a':
  Metadata:
    major_brand     : M4A 
    minor_version   : 0
    compatible_brands: M4A isommp42
    creation_time   : 2022-06-10T00:59:40.000000Z
    title           : 100
    voice-memo-uuid : 3137F094-78C9-4024-926D-F173E4B35A35
    encoder         : com.apple.VoiceMemos (Jingying's iPhone (null))
  Duration: 00:00:03.90, start: 0.000000, bitrate: 343 kb/s
    Stream #0:0(und): Audio: alac (alac / 0x63616C61), 48000 Hz, mono, s16p, 336 kb/s (default)
    Metadata:
      creation_time   : 2022-06-10T00:59:40.000000Z
      handler_name    : Core Media Audio
Stream mapping:
  Stream #0:0 -> #0:0 (alac (native) -> aac (native))
Press [q] to stop, [?] for help
Output #0, ipod, to 'anotherff100.m4a':
  Metadata:
    major_brand     : M4A 
    minor_version   : 0
    compatible_brands: M4A isommp42
    voice-memo-uuid : 3137F094-78C9-4024-926D-F173E4B35A35
    title           : 100
    encoder         : Lavf58.29.100
    Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp (16 bit), 69 kb/s (default)
    Metadata:
      creation_time   : 2022-06-10T00:59:40.000000Z
      handler_name    : Core Media Audio
      encoder         : Lavc58.54.100 aac
size=      35kB time=00:00:03.90 bitrate=  73.1kbits/s speed= 123x    
video:0kB audio:33kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 4.601811%
[aac @ 0x56201bd0d580] Qavg: 120.461
$ mediainfo anotherff100.m4a 
General
Complete name                            : anotherff100.m4a
Format                                   : MPEG-4
Format profile                           : Apple audio with iTunes info
Codec ID                                 : M4A  (isom/iso2)
File size                                : 34.9 KiB
Duration                                 : 3 s 922 ms
Overall bit rate mode                    : Constant
Overall bit rate                         : 72.8 kb/s
Track name                               : 100
Writing application                      : Lavf58.29.100

Audio
ID                                       : 1
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 3 s 922 ms
Duration_LastFrame                       : -4 ms
Bit rate mode                            : Constant
Bit rate                                 : 69.6 kb/s
Channel(s)                               : 1 channel
Channel layout                           : C
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 33.3 KiB (96%)
Title                                    : Core Media Audio
Default                                  : Yes
Alternate group                          : 1

That might require some tuning to achieve the desired quality output.

1
  • 1
    Thank you so much! Audio files are simply a means to an end for me, and I know almost nothing about the huge variety of encodings out there. And the ffmpeg documentation is not too easy to digest. Thanks also for showing the mediainfo tool. Very useful!
    – Alan Munn
    Jul 18, 2022 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.