baptx

pinephone_call_recording_scripts

Mar 1st, 2026 (edited)
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.71 KB | None | 0 0
  1. # get_recordings.sh
  2. #!/bin/bash
  3. # Get recordings and free space from the modem, necessary when using headphones only but recommended to always save downlink sound to modem in case we plug headphones during a recorded call
  4. # Adapted from the script in the repository https://github.com/the-modem-distro/pinephone_modem_sdk/issues/241
  5. # After enabling ADB, you may see an error when trying to pull files: "adb: error: remote object '...' does not exist"
  6. # It can be fixed by rebooting the modem: echo 'AT+CFUN=1,1' | sudo atinout - /dev/ttyUSB2 -
  7.  
  8. TARGETPATH=~/Documents/recordings/
  9. FILESPERSIST=`adb shell ls /data/ufs/`
  10. mkdir -p $TARGETPATH
  11. cd $TARGETPATH
  12. for file in $FILESPERSIST; do
  13.         if [[ $file =~ .*\.(wav) ]]; then
  14.                 THISFILE=$(echo $file|tr -d '\n'|tr -d '\r')
  15.                 echo "Pulling "$THISFILE
  16.                 adb  pull /data/ufs/${THISFILE} && adb shell rm /data/ufs/${THISFILE}
  17.         fi
  18. done;
  19.  
  20.  
  21. # record_call.sh
  22. # Selecting "Make a phone call" in Phosh sound settings before making a new call is recommended to prevent empty recording (maybe related to call crashing or phone reboot)
  23. # The script can be started before starting the call (otherwise use another command like "ls" with sudo before starting the script to not waste time typing the password during the call)
  24. # If the modem crashed after starting the script, you may need to send the command to stop the previous recording again when the modem is started to be able to make new recordings on the modem (otherwise you may get an empty file)
  25. # Not using the custom modem firmware due to issues: https://github.com/the-modem-distro/pinephone_modem_sdk/issues/259
  26. # Information to enable ADB on the original modem firmware:
  27. # https://github.com/Biktorgj/quectel_eg25_recovery/issues/26
  28. # https://xnux.eu/devices/feature/modem-pp.html#toc-unlock-adb-access
  29. # https://xnux.eu/devices/feature/qadbkey-unlock.c
  30.  
  31. #echo 'AT+QAUDRD=1,"'$(date +%Y%m%d%H%M%S)'_uplink.wav",13,0' | sudo atinout - /dev/ttyUSB2 -
  32.  
  33. time=$(date +%Y%m%d%H%M%S) # use date command only once to have the same recording time in both filenames
  34. echo 'AT+QAUDRD=1,"'$time'_downlink.wav",13,1' | sudo atinout - /dev/ttyUSB2 -
  35. pw-record ~/Documents/recordings/$time.wav # both microphone and speaker are recorded if not using headphones
  36. echo 'AT+QAUDRD=0' | sudo atinout - /dev/ttyUSB2 - # stop call recording on modem after pressing Ctrl+C for pw-record command
  37.  
  38. # trying to record both uplink and downlink from modem (not working correctly with headphones)
  39. #echo 'AT+QAUDRD=1,"'$(date +%Y%m%d%H%M%S)'.wav",13' | sudo atinout - /dev/ttyUSB2 -
  40.  
  41.  
  42. # recording_merge.sh
  43. # Merge downlink recording with microphone recording (necessary when using headphones only)
  44. # Time of the filename should be given as first parameter in Year-Month-Day-Hours-Minutes-Seconds format YYYYmmddHHMMSS
  45. # Delay in milliseconds should be given as second parameter (1000 should be fine but may be increased when plugging headphones during call recording)
  46.  
  47. # https://trac.ffmpeg.org/wiki/AudioVolume
  48. #ffmpeg -i ${1}.wav -filter:a "volume=50dB" ${1}_amplified.wav
  49. # https://superuser.com/questions/644768/how-to-merge-audio-using-ffmpeg-not-concat/645238#645238
  50. #ffmpeg -i ${1}_downlink.wav -i ${1}_amplified.wav -filter_complex amix ${1}_merged.wav
  51. # https://stackoverflow.com/questions/65488904/merge-both-audio-with-delay-use-ffmpeg/65496856#65496856
  52. #ffmpeg -i ${1}_downlink.wav -i ${1}_amplified.wav -filter_complex "[1:a]adelay=1000:all=1[a1];[0:a][a1]amix" ${1}_merged.wav
  53.  
  54. # https://stackoverflow.com/questions/64729433/ffmpeg-how-to-add-volume-to-filter-complex/64731319#64731319
  55. ffmpeg -i ${1}_downlink.wav -i ${1}.wav -filter_complex "[1:a]adelay=$2:all=1,volume=50dB[a1];[0:a][a1]amix" ${1}_merged.wav
  56.  
Advertisement
Add Comment
Please, Sign In to add comment