Extracting Apple’s iOS audio sounds

AppleAudioVideoFFMPEG
23 Aug 2021

I wanted to use some of Apple’s iconic audio sounds in a project, here’s how I did it.

Extracting the audio files

The first thing was to extract the raw audio files from iOS.

On a mac this process was pretty simple.

This resulted in around 300 individual audio files.

Using these files

Worth noting is that Apple use their own proprietory Core Audio Format .caf file format which can be played using VLC.

My aim was to have an easy way of listening through them to identifying the ones I needed.

This turned out to be a four step process

  1. convert the audio format
  2. generate videos showing filenames
  3. compile an index of these videos
  4. concatenate them together

1. Convert the audio format

I used FFMPEG for this

#!/bin/bash

mkdir ./mp3/

for path in ./caf/*.caf; do
  file=${path##*/}
  ffmpeg -i "$path" -c:a mp3 -strict -2 "./mp3/${file%.*}.mp3"
done
#!/bin/bash

mkdir ./mp3/

for path in ./caf/*.caf; do
  file=${path##*/}
  ffmpeg -i "$path" -c:a mp3 -strict -2 "./mp3/${file%.*}.mp3"
done

Turns out this was necessary because of the .caf format1 and audio sync issues.

… time is measured depending on the bitrate when importing aac files:

Estimating duration from bitrate, this may be inaccurate

2. Generate videos showing filenames

Again, using FFMPEG. The video includes a histogram of the audio and the filename.

#!/bin/bash

mkdir ./mp4/

for path in ./mp3/*.mp3; do
  file=${path##*/}
  ffmpeg -i "$path" -s hd1080 -filter_complex "[0:a]ahistogram,format=yuv420p,drawtext=text='${file}':x=(w-text_w)/2:y=(h-text_h)/2:fontfile=./font.otf:fontsize=36:fontcolor=white" -c:v libx264 "./mp4/${file%.*}.mp4"
done
#!/bin/bash

mkdir ./mp4/

for path in ./mp3/*.mp3; do
  file=${path##*/}
  ffmpeg -i "$path" -s hd1080 -filter_complex "[0:a]ahistogram,format=yuv420p,drawtext=text='${file}':x=(w-text_w)/2:y=(h-text_h)/2:fontfile=./font.otf:fontsize=36:fontcolor=white" -c:v libx264 "./mp4/${file%.*}.mp4"
done

Here is an example video generated.

Resources

FFMPEG

Command line scripting

Audio sync issues

Footnotes

  1. From Superuser post Duration parameter being ignored