Last active
March 26, 2022 04:23
-
-
Save SgtPooki/cbd960145031c50d7a2a9cad0c146304 to your computer and use it in GitHub Desktop.
Comma.ai video+log downloading via sftp via the command line
This file contains 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
#!/usr/bin/env bash | |
COMMA_AI_IP="192.168.1.11" | |
function comma-download { | |
local REMOTE_DIRECTORY="/data/media/0/realdata/$1" && shift | |
local LOCAL_DIRECTORY="${1:-}" | |
if [ -n "$LOCAL_DIRECTORY" ]; then | |
mkdir -p $LOCAL_DIRECTORY | |
fi | |
if comma-check-for-directory "$REMOTE_DIRECTORY"; then | |
sftp comma@$COMMA_AI_IP <<< "get -afR ${REMOTE_DIRECTORY} $LOCAL_DIRECTORY" | |
else | |
echo "Could not find '$REMOTE_DIRECTORY' on your comma device" | |
fi | |
} | |
function comma-check-for-directory { | |
local REMOTE_DIRECTORY="$1" && shift | |
sftp comma@$COMMA_AI_IP 2>&1 <<< "ls -la $REMOTE_DIRECTORY" | grep -v '^sftp>\|^Connected' | grep -Esv '^Can.t ls:.*not found.*$' 2>&1 >/dev/null | |
} |
And then to overlay the driver camera on the driving video.. something like this:
cat /Users/sgtpooki/Downloads/2022-03-22--18-50-33/*/ecamera.hevc > /Users/sgtpooki/Downloads/2022-03-22--18-50-33/ecamera-all.hevc
cat /Users/sgtpooki/Downloads/2022-03-22--18-50-33/*/dcamera.hevc > /Users/sgtpooki/Downloads/2022-03-22--18-50-33/dcamera-all.hevc
cat /Users/sgtpooki/Downloads/2022-03-22--18-50-33/*/fcamera.hevc > /Users/sgtpooki/Downloads/2022-03-22--18-50-33/fcamera-all.hevc
ffmpeg -r 20 -i /Users/sgtpooki/Downloads/2022-03-22--18-50-33/ecamera-all.hevc -c copy /Users/sgtpooki/Downloads/2022-03-22--18-50-33/ecamera-all.mp4
ffmpeg -r 20 -i /Users/sgtpooki/Downloads/2022-03-22--18-50-33/dcamera-all.hevc -c copy /Users/sgtpooki/Downloads/2022-03-22--18-50-33/dcamera-all.mp4
ffmpeg -r 20 -i /Users/sgtpooki/Downloads/2022-03-22--18-50-33/fcamera-all.hevc -c copy /Users/sgtpooki/Downloads/2022-03-22--18-50-33/fcamera-all.mp4
cd /Users/sgtpooki/Downloads/2022-03-22--18-50-33
ffmpeg -r 20 -thread_queue_size 64 -i ecamera-all.mp4 -vf 'movie=dcamera-all.mp4, scale=300:-1[inner];[in][inner]overlay=main_w-(overlay_w+10):main_h-(overlay_h+10) [out]' combined.mp4
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How-to
Prerequisites:
sftp comma@$MY_COMMA_IP
Getting started
. filename.sh
, etc..route_name
for the route you want to download as the first argument and the local directory where you want to save the files as the second argument.route_name
format:<dongle_id>|<yyyy>-<mm>-<dd>--<hh>-<mm>-<ss>
Example: