I’ve recently crossed into the dark side and gotten my first iPhone. I wanted to set up ringtones for my contacts but discovered that Apple is pretty picky about ringtone file format. After some searching I found the ffmpeg command to run to get the ringtones into a file iPhones are happy with.
The criteria are:
- aac codec
- m4r filename
- 30 seconds or less in duration
I ran into a snag with various things I was trying to convert apparently having more than one stream. I would get the error message
Could not find tag for codec h264 in stream #0, codec not currently supported in container
I had to use the map command to specify exactly which stream I wanted (just the audio one.) I discovered which stream I wanted by running the
ffmpeg -i command on the file to see its available streams. I also discovered that some songs reported incorrect duration. This was fixed with the
-write_xing 0 option. Thanks to this gist for the inspiration.
Here is the full command to turn music into an Apple-compatible ringtone. Modify -ss and -to to suit your needs (starting time, to ending time)
ffmpeg -i <input file> -codec:a aac -ss 00:00:59.5 -to 00:01:21.5 -f ipod -map 0:0 -write_xing 0 ringtone.m4r If taking a ringtone from a video file, I had to specify I wanted stream 1 instead of stream 0:
ffmpeg -i Batman-\ The\ Animated\ Series\ -\ S02E01\ -\ Shadow\ of\ the\ Bat\ \(1\)\ SDTV.avi -codec:a aac -ss 00:00:20.5 -to 00:00:43.5 -f ipod -write_xing 0 -map 0:1 batman_ringtone.m4r Once you have the right m4r file, you simply need to plug your iPhone into your computer and fire up iTunes. You can then drag the file into the "Tones" section on the left under "Devices".