Android Custom Ringtone

Samsung/HTC/LG all have a configuration entry for setting a custom ringtone,
heck! you can even select a MP3 file out of your External-SDCard!

For ROMs such as AOSP or LineageOS, you will have to walk through some extra steps in-order to add some custom sounds.

  1. First step is acquiring an audio or a video file,
    you can download it from YouTube using savefrom.net or keepvid.com,
    or by using YouTube-DL.

    For example here is an “Old Nokia-Tune” video, I would like use.

    I’ve downloaded it as the highest quality mp4, and renamed it to video.mp4.

    In the next step we’ll encode it to OGG using ffmpeg, you can download any type of media-file you want (mp3, mp4, webm,…) – ffmpeg can handle it all!

  2. get ffmpeg from:
    ffmpeg-latest-win64-static.7z or ffmpeg-latest-win32-static.7z, you only need ffmpeg.exe from within the bin folder.
  3. Use the following command, to extract a fixed audio,
    from whatever input-media file you have (for example video.mp4).

    ffmpeg -i "video.mp4"   -y -hide_banner -loglevel "info" -stats -threads "16" -strict "experimental" -flags "+naq+low_delay+global_header-unaligned-ilme-cgop-loop-output_corrupt" -flags2 "+fast+ignorecrop+showall+export_mvs" -fflags "+ignidx+genpts+nofillin+discardcorrupt-fastseek" -movflags "+faststart+disable_chpl" -avoid_negative_ts "make_zero" -ss "00:00:00.001" -map_chapters "-1" -map_metadata "-1" -sn -vn -af "asetpts=PTS-STARTPTS,aresample=async=1:min_hard_comp=0.100000"   "old_nokia_tune.ogg"
    
  4. Rename your output file (for example old_nokia_tune.ogg),
    no whitespace characters and no dashes, you can use underscore.

    The filename does not matter.

  5. Next we need to edit the file’s Vorbis Comment,
    meta-data (similar to MP3’s IDv3…)
    using a program named mp3tag.

    Get it in here: mp3tag.de/en/download.html,
    install it on your PC and run it.

  6. Open your OGG file,
    right click the file an select “Extended Tags…”

    Add new tag:GENRE with the value Ringtone.
    Add new tag:ANDROID_LOOP with the value true.
    Add new tag:TITLE with the value Old Nokia Tune (for example).

    The TITLE tag can have any character you wish to use,
    for example Hebrew or Unicode characters, spaces and dashes,
    that content is the one that will be shown in Android’s ringtone selection menu (and not the filename!).

    Note that Samsung audio-files will also have:
    ALBUM with the value of Samsung,
    ARTIST with the value of Samsung and
    COMMENT with the value of Samsung
    but it is optional.



  7. Copy the audio file to your phone.

    first – try to place it in the phone’s storage or
    SDCard-storage under the /ringtones folder,
    reboot your device and check if you can select it from the
    ringtone-selection menu,

    If you do, you are done and it won’t require
    you to have root access.

    It does means though that the ringtone is stored
    under /data, and once You’ll be factory-resetting
    your device, you’ll loose the ringtone file.

    If the steps above didn’t worked for you,
    or you want to place the ringtone in your system,
    and not your data, so it will be kept safe even
    if you’ll factory-reset your device,
    keep through the next steps (root required!).

  8. For the next steps you will need to have a root access,
    the ability to mount /system,
    and some sort of a root-explorer.

    I like X-plore File Manager and I set it to start in “root + mount” mode automatically (see configuration menu).

  9. Use your root-explorer to navigate the folder-tree to /system/media/audio/ringtones and copy your old_nokia_tune.ogg directly under the ringtones folder.
  10. Set old_nokia_tune.ogg permissions to 0644,
    and its user to 0 (“root”) and group to 0 (“root”).
    If it goes back to being 1 or 2 it is fine.

    setting the permissions and ownership can be easily done
    using X-plore long-press the OGG file and
    selecting “permissions” from the pop-up menu.

  11. Reboot your phone,
    check the ringtone-selection menu,
    a new entry of Old Nokia-Tune should be there.

    In some cases You’ll have to reboot to your custom-recovery,
    and clear both Dalvik-cache and cache-partition,
    after you’ll boot up your device, give it a minute,
    and the new entry will be there!