Last Updated: September 27, 2021
·
8.359K
· erebusbat

Create iPhone Ringtones with FFMPEG

FFMPEG can write almost any format and can read many more. That makes it an ideal tool to use to convert/transcode file formats from one to another. FFMpeg has so much power though that reading the docs can make you go cross eyed.

These are my field notes on some FFMpeg commands that I use for this and should be a good starting place. Any audio format that FFMpeg can read can be substituted in these commands. Likewise with the video, although the streams may not match.

If you get complaints about libfdk_aac not being available then replace it with libfaac, or recompile your ffmepg to have the better AAC encoder (although for ringtones it is probably a moot point).

# Downsample input to 96k
$ ffmpeg -i Input.mp3 -c:a libfdk_aac -f ipod -b:a 96k output.m4r

# Convert all FLAC files in the current directory (ZSH specifics)
for f in *.flac; do 
    ffmpeg -i $f -acodec libfdk_aac -f ipod ${f:r}.m4r; 
done

# Get stream info
ffmpeg -i movie.m4v

# Extract a portion of audio from movie file (0 is first input, 
#   stream 1 is the audio) assumes the audio is already in AAC, 
#   if not replace 'copy' with the aac encoder
#   Skip to 1500 seconds, copy 300 seconds of audio  (to grab a 
#   general chunk, then can edit in audacity)
ffmpeg -i movie.m4v -map 0:1 -acodec copy -f ipod -ss 1500 -t 300 ringtone.m4r

This should be enough to get you started. Ubuntu has very clean manpages for ffmpeg: