Saturday, May 27, 2023

How to convert call recordings to Cube ACR format

INTRODUCTION

android-call-recorder is version 1.8.4
Cube ACR is version 2.4.239

The call recording app android-call-recorder, saves call recording in several audio formats, for example OGG. Such files are one per call, and go by default into this directory:
/storage/emulated/0/Android/data/com.github.axet.callrecorder/files
And there are two subdirectories, "raw" and "recordings". The "recordings" one is where the ogg files go.


The other recording app, Cube ACR, stores recording by default into this directory
/external/Documents/CubeCallRecorder
so recordings really end up here (even if the directories are the same, when you reinstall the app, recording won't show up, yo have to go to Settings > Backup & storage settings > MIGRATE YOUR RECORDINGS > choose this directory:
/storage/emulated/0/Documents/CubeCallRecorder
and inside that directory there's the "All" subdirectory, where everything goes.

Now, Cube ACR stores 2 files for each recording:
  1. The audio itself, which is saved to "All" subdirectory.
  2. The json file for that audio, which is saved to "All/.props" subdirectory. This is a text file containing metadata for the audio call.
The audio itself can be configured in 4 different formats, in Settings > Recording > Output file format:
  • AMR (.amr, small size, normal quality)
  • MPEG-4 LO (.m4a, small size, normal quality)
  • MPEG-4 (.m4a, medium size, better quality)
  • MPEG-4 HQ (.m4a, large size, best quality)
1) The audio filename (without the extension) has this format: phone_yyyymmdd-hhmmss_NUMBER. Phone is for phone calls, if you record Meet or WhatsApp, it will be a different string. If the number has a plus sign "+" it will be replaced in the filename by underscore "_".
2) The json filename has the same format but with .json extension instead of .amr or .m4a. If some weird configurations are present, there can be 2 json files instead of one for each recording. The second json will have the same filename as the second but adding a space and a number starting by one: " (1)", so for example the files for a recording could be:
/external/Documents/CubeCallRecorder/All/phone_20230527-173933_555123456.amr
/external/Documents/CubeCallRecorder/All/.props/phone_20230527-173933_555123456.json
/external/Documents/CubeCallRecorder/All/.props/phone_20230527-173933_555123456 (1).json
When this happens, usually both json files are exactly the same, but describe slightly different call durations. The json with the "(1)" has the right duration, while the one without it has a few hundred milliseconds more of declared duration. Also, in the phone's filesystem, the json with the "(1)" was modified and accessed about 300 milliseconds later that the json without, so it means that was written later due to some correction. This is probably a bug.

Note that although Cube ACR can only record in AMR or M4A, you can put there other audio formats, like OGG, and they will be accepted and displayed properly within the recording app, provided that the audio is supported by the phone and the corresponding JSON is in place and containing the proper metadata. If you don't have the .json file because you copied the .ogg recording from android-call-recording, you just make a new one (copy one existing and modify it). In the beginning, I was about to convert all previous ogg recordings to Cube's format, but made a try just copying them and they were accepted without any hassle. So it's great that works like that. In any case, later I'll try converting some files to Cube's MPEG-4 format with ffmpeg for the sake of it.

AUDIO FORMATS

Cube ACR can record audio in 4 formats, so I've recorded a call of about 30 seconds with each setting, to see what are the specifications:

1.1) AMR
  • File size: 51718 bytes
  • (MediaInfo) Format: AMR
  • (MediaInfo) Duration: 32 s 320 ms
  • (MediaInfo) Overall bit rate mode: Constant
  • (MediaInfo) Overall bit rate: 12.8 kb/s
  • (MediaInfo) Streams: Audio: 12.8 kb/s, 8000 Hz, 1 channel, ARM (Narrow Band)
  • (VLC) Type: Audio
  • (VLC) Duration: 00:32
  • (VLC) Codec: AMR narrow band (samr)
  • (VLC) Channels: mono
  • (VLC) Sample rate: 8000 Hz
  • (VLC) Bits per sample: 12
1.2) MPEG-4 LO
  • File size: 67143 bytes
  • (MediaInfo) Format: MPEG-4 (Base Media / Version 2)
  • (MediaInfo) Duration: 32 s 640 ms
  • (MediaInfo) Overall bit rate mode: Constant
  • (MediaInfo) Overall bit rate: 16.5 kb/s
  • (MediaInfo) Streams: Audio: English, 16.0 kb/s, 8000 Hz, 1 channel, AAC LC, SoundHandle
  • (VLC) Type: Audio
  • (VLC) Duration: 00:32
  • (VLC) Codec: MPEG AAC Audio (mp4a)
  • (VLC) Channels: Stereo
  • (VLC) Sample rate: 16000 Hz
  • (VLC) Bits per sample: 32
  • (ExifTool) ExifTool Version Number: 12.60
  • (ExifTool) Major Brand: MP4 v2 [ISO 14496-14]
  • (ExifTool) Duration: 0:00:33
  • (ExifTool) Audio Format: mp4a
  • (ExifTool) Audio Channels: 1
  • (ExifTool) Audio Bits Per Sample: 16
  • (ExifTool) Audio Sample Rate: 8000
  • (ExifTool) Avg Bitrate: 16 kbps
1.3) MPEG-4
  • File size: 101072 bytes
  • (MediaInfo) Format: MPEG-4 (Base Media / Version 2)
  • (MediaInfo) Duration: 32 s 700 ms
  • (MediaInfo) Overall bit rate mode: Constant
  • (MediaInfo) Overall bit rate: 24.7 kb/s
  • (MediaInfo) Streams: Audio: English, 24.0 kb/s, 16 kHz, 1 channel, AAC LC, SoundHandle
  • (VLC) Type: Audio
  • (VLC) Duration: 00:32
  • (VLC) Codec: MPEG AAC Audio (mp4a)
  • (VLC) Channels: Stereo
  • (VLC) Sample rate: 32000 Hz
  • (VLC) Bits per sample: 32
  • (ExifTool) ExifTool Version Number: 12.60
  • (ExifTool) Major Brand: MP4 v2 [ISO 14496-14]
  • (ExifTool) Duration: 0:00:33
  • (ExifTool) Audio Format: mp4a
  • (ExifTool) Audio Channels: 1
  • (ExifTool) Audio Bits Per Sample: 16
  • (ExifTool) Audio Sample Rate: 16000
  • (ExifTool) Avg Bitrate: 24 kbps
1.4) MPEG-4 HQ
  • File size: 135238 bytes
  • (MediaInfo) Format: MPEG-4 (Base Media / Version 2)
  • (MediaInfo) Duration: 32 s 500 ms
  • (MediaInfo) Overall bit rate mode: Constant
  • (MediaInfo) Overall bit rate: 33.3 kb/s
  • (MediaInfo) Streams: Audio: English, 32.0 kb/s, 32 kHz, 1 channel, AAC LC, SoundHandle
  • (VLC) Type: Audio
  • (VLC) Duration: 00:32
  • (VLC) Codec: MPEG AAC Audio (mp4a)
  • (VLC) Channels: Stereo
  • (VLC) Sample rate: 32000 Hz
  • (VLC) Bits per sample: 32
  • (ExifTool) ExifTool Version Number: 12.60
  • (ExifTool) Major Brand: MP4 v2 [ISO 14496-14]
  • (ExifTool) Duration: 0:00:33
  • (ExifTool) Audio Format: mp4a
  • (ExifTool) Audio Channels: 1
  • (ExifTool) Audio Bits Per Sample: 16
  • (ExifTool) Audio Sample Rate: 32000
  • (ExifTool) Avg Bitrate: 32.1 kbps

ExifTool displays also additional metadata for these m4a files, in this case 53 metadata elements:
ExifTool Version Number
File Name
Directory
File Size
File Modification Date/Time
File Access Date/Time
File Inode Change Date/Time
File Permissions
File Type
File Type Extension
MIME Type
Major Brand
Minor Version
Compatible Brands
Media Data Size
Media Data Offset
Movie Header Version
Create Date
Modify Date
Time Scale
Duration
Preferred Rate
Preferred Volume
Preview Time
Preview Duration
Poster Time
Selection Time
Selection Duration
Current Time
Next Track ID
Play Mode
Android Version
Track Header Version
Track Create Date
Track Modify Date
Track ID
Track Duration
Track Layer
Track Volume
Matrix Structure
Media Header Version
Media Create Date
Media Modify Date
Media Time Scale
Media Duration
Handler Type
Handler Description
Balance
Audio Format
Audio Channels
Audio Bits Per Sample
Audio Sample Rate
Avg Bitrate
So recording in m4a instead of amr allows to store additional information inside audio files, which is not lost even if you rename the filename.

JSON FORMAT

Each audio recorded by Cube ACR is accompanied by its own json file, inside ".props" subfolder.
JSON files are encoded in UTF-8 with UNIX end of line.
Each json file consists only of one line of text, with no newline at the end (the cursor stays at the end of the line without a carriage return). Inside the line, there are metadata parameters, and the value for each parameter. Not all the parameters have to be in all json files, so the number of them can vary from one recording to another.
A sample line with quite a lot of parameters would be:
{"duration":"29572","loc":"20.12475138089561;-5.396703243813537","tlm":"5681 23919","callee":"555123456","comment":"imported-from-android-call-recorder","addr":"1199-1111 Kensington Rd NW, Calgary, AB, Canada","direction":"Outgoing"}
This is what each one means. Parameters are comma separated, and if a value is required for it just follows after a colon:
  • duration: the call duration or length in milliseconds.
  • loc: means that has a GPS lock, with the coordinates. For this you must enable Settings > Miscellaneous settings > Enable geo tagging.
  • tlm: the time in milliseconds where marks are placed in the timeline, separated by a space. To have this parameter you must set Settings > Miscellaneous settings > Enable shake-to-mark.
  • callee: is the phone number.
  • comment: this is a comment you can add to each recording, clicking on the 3 dots right to each recording in the app > Comment. I've added a comment to those recordings which I imported from other call recording applications. Comments are displayed in the app directly below each call, so they are easy to see.
  • addr: is the address obtained from the GPS.
  • direction: Incoming (you received it) or Outgoing (you made it).
If the duration in the json does not match the actual duration of the audio, the json will be updated once you play the recording from Cube ACR, so in case you put it wrong won't matter much, it's just for the previsualization. However, all the other metadata won't be updated if it's wrong, since the app doesn't have other way of knowing it. If the phone number on the audio filename and in the json differ, it will use the one in the json.
Once the app loads all the imported or migrated recordings, it will keep its metadata in app's data instead of reading the jsons each time, which makes the app much faster. If you want to force regenerate the entire list of calls displayed in the app (after modifying any json for example), you have to clear app's data, or reinstall it. Next time you open it, migrate the recordings again and regenerate the list. You may need to force close and reopen the app otherwise gets stuck with the loading icon.

CONVERTING CALLS TO MPEG-4 HQ

To convert audio calls to Cube's ACR MPEG-4 format, read this:

The command would look something like:
ffmpeg -i recording.ogg -c:a libfdk_aac -b:a 32k -ac 1 -ar 32000 -brand mp42 recording.m4a
The resulting file will be pretty similar to those generated by Cube ACR. It may not have the same cutoff frequency (which you can change), but the important stuff will be the same. Also, some metadata will be different, which you can check with ExifTool, or even modify the ffmpeg command to alter it.

Really you can convert any audio or song, and will be played as a call recording once imported to Cube ACR.

Useful links:

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.