Last active
July 30, 2016 14:34
-
-
Save eduo/e5bb6f48757cde29ec1b to your computer and use it in GitHub Desktop.
Bash Script to Split eCamm Call Recorder Skype files (sides of recorded conversation)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Rudimentary bash script to split Call Recorder files for import into Logic Pro X | |
# Files are saved as M4A (MP4 Audio) files, which are readily importable | |
# into Logic Pro X. | |
# Script should work with most formats FFMPEG recognizes, really. | |
# REMEMBER Call Recorder does this annoying thing of saving your file with the name of | |
# the other people in the call. So if "Eduo" and "Alex" are the participants, then Eduo's | |
# audio will be called "Alex LOCAL" and Alex's Audio will be called "Eduo LOCAL". | |
# Using the -r switch will produce also REMOTE files with the "other side" of the | |
# conversation. Useful for alignment purposes. | |
# 2015-03-06 - Changed conversion to remux, to drastically reduce processing times. For | |
# Call Recorder files resulting M4A can be imported directly into LPX without conversion. | |
# Script path | |
PWD=$( cd "$(dirname "$0")" ; pwd -P ) | |
# Only dependency is FFMPEG CLI, please change the path accordingly. | |
# Default FFMPEG location is in the same path as the script, under a directory called | |
# ffmpeg.cli | |
# FFMPEG CLI Binary path | |
FFMPEG="${PWD}/ffmpeg.cli/ffmpeg"; ## Get from http://ffmpegmac.net/ or http://www.evermeet.cx/ffmpeg/ | |
DOREMOTE=0 | |
TEMPLIST="/tmp/toLPX.$$.txt" | |
OVW="n" | |
while getopts ":ryh" opt; do | |
case ${opt} in | |
r) DOREMOTE=1 ;; | |
y) OVW="y" ;; | |
h) echo "";echo "Usage: $0 [-r|y|h] [file(s)]"; echo " -r Generate all tracks, not only the first one"; echo " -y Overwrite targets if necessary"; echo " -h Show this help text"; echo " File(s) optional. If not will process full dir. Mind your Ps and Qs (Paths and Quoted strings)";echo "";exit ;; | |
\?) echo "Invalid option: -$OPTARG" >&2; exit ;; | |
esac | |
done | |
echo "" | |
echo "Process Call Recorder Files into M4A with FFMPEG for Logic Pro X import" | |
echo "" | |
echo "Use -h for help" | |
#echo " $0" | |
shift $((OPTIND-1)) | |
if [ $# -eq 0 ] | |
then | |
ls -1 *.{mov,m4a,wav,aif,aiff,mp3} 2>/dev/null > "${TEMPLIST}" | |
else | |
ls -1 "$@" | grep -E 'm4a|mov|wav|mp3|aif|aiff' 2>/dev/null > "${TEMPLIST}" | |
fi | |
> cmds | |
cat "${TEMPLIST}" | while read MOV | |
do | |
# echo 'echo "Will process '${MOV}'"' >> cmds | |
CDATE=$(stat -f "%Sm" -t "%Y-%m-%d-%H:%M:%S" "${MOV}") | |
echo 'echo ""' >> cmds | |
echo 'echo "------------------------------------------------"' >> cmds | |
echo 'echo "FILE: '${MOV}'"' >> cmds | |
echo 'echo "---> PROCESSING..."' >> cmds | |
echo 'echo " - Original File Creation date: '${CDATE}'"' >> cmds | |
TEMPFILE="/tmp/${MOV}.$$.txt" | |
#echo " Temporary info storedWill save in $TEMPFILE" | |
"${FFMPEG}" -i "${MOV}" 2> "${TEMPFILE}" | |
CREATION=$(grep creation_time "${TEMPFILE}"|head -n1|cut -f2- -d:|sed -e's/^ //g'); #echo "Creation is $CREATION" | |
DURATION=$(grep Duration "${TEMPFILE}"|head -n1|cut -f2- -d:|cut -f1 -d,|sed -e's/ //g'); #echo "Duration is $DURATION" | |
ISON=$(echo "${MOV}"|grep -c " on ") | |
NAMES=${MOV%\.*} | |
if [[ ${ISON} -eq 1 ]] | |
then | |
NAMES="guest_"$(expr "${MOV}" : '^\(.*\) on .*') | |
fi | |
echo 'echo " Analyzing file..."' >> cmds | |
echo 'echo " - New Name Prefix: '${NAMES}'"' >> cmds | |
NEWFILEPRE=$(echo "${NAMES}-${CREATION}-${DURATION}"|sed -e's/:/_/g') | |
echo 'echo " - Final Name: '${NEWFILEPRE}'"' >> cmds | |
grep Stream "${TEMPFILE}" |grep Audio | while read stream | |
do | |
MAP=$(echo ${stream}|cut -f2 -d#|cut -f1 -d\() | |
#echo 'echo "MAP is '${MAP}'"' >> cmds | |
echo 'echo " Extracting/Convering Audio Tracks..."' >> cmds | |
REMOTE=$(echo ${MAP}|cut -f2 -d:) | |
if [ $REMOTE -eq 1 ] | |
then | |
SUF="REMOTE" | |
[ ${DOREMOTE} -eq 1 ] && echo "echo \" - Audio [$SUF] - Extracting and Converting Stream [${MAP}]\"" >> cmds | |
NEWNAME=$(echo "${NEWFILEPRE}-${SUF}.m4a"|sed -e's/ -/-/g' -e's/- /-/g') | |
# #[ ${DOREMOTE} -eq 1 ] && echo \"${FFMPEG}\" -\"${OVW}\" -i \"${MOV}\" -loglevel panic -strict -2 -map \"${MAP}\" -movflags +faststart -ar 44100 -c:a aac -ac 1 \"${NEWNAME}\" </dev/null >> cmds | |
[ ${DOREMOTE} -eq 1 ] && echo \"${FFMPEG}\" -\"${OVW}\" -i \"${MOV}\" -loglevel panic -strict -2 -map \"${MAP}\" -vn -c:a copy \"${NEWNAME}\" </dev/null >> cmds | |
else | |
SUF="LOCAL" | |
echo "echo \" - Audio [$SUF] - Extracting and Converting Stream [${MAP}]\"" >> cmds | |
NEWNAME=$(echo "${NEWFILEPRE}-${SUF}.m4a"|sed -e's/ -/-/g' -e's/- /-/g') | |
# echo \"${FFMPEG}\" -\"${OVW}\" -i \"${MOV}\" -loglevel panic -strict -2 -map \"${MAP}\" -movflags +faststart -ar 44100 -c:a aac -ac 1 \"${NEWNAME}\" </dev/null >> cmds | |
echo \"${FFMPEG}\" -\"${OVW}\" -i \"${MOV}\" -loglevel panic -strict -2 -map \"${MAP}\" -vn -c:a copy \"${NEWNAME}\" </dev/null >> cmds | |
fi | |
done | |
done | |
. ./cmds | |
echo " --- ${MOV} - AUDIO FILE PROCESSING COMPLETE ---" | |
echo "------------------------------------------------" | |
rm cmds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm curious why you don't drag and drop mov file directly into Logic Pro from Finder and let Logic do the conversion? Doing it this way brings in both sides of the conversation and you can choose whether to have two tracks or one.
The only problem I've found so far is that the imported tracks are SMPTE Locked (you can't move them horizontally) which you can unlock by right clicking the track and then selecting "SMPTE Lock" and then unlock.
I see that File --> Import --> Audio of the mov file only imports one side of the conversation... is that's why you created this script?