baptx

pinephone_call_recording_scripts

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