Skip to content

Instantly share code, notes, and snippets.

@m-rey
Last active June 18, 2021 16:55
Show Gist options
  • Save m-rey/3d64b393936fb64360052ee7ee8c61d6 to your computer and use it in GitHub Desktop.
Save m-rey/3d64b393936fb64360052ee7ee8c61d6 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Copyright 2021 Martin Rey
# REQUIREMENTS
# bash, xargs, gpg2, ffmpeg, jq
#
# USAGE
# cryptocam_decrypt.sh INPUT_DIR OUTPUT_DIR
#
# NOTE
# `pwd` is the default if a directory isn't set
shopt -s nullglob
# only add slash to directry path if a path is set
test -z "${1}" || INPUT_DIR=$(realpath "${1}")/
test -z "${2}" || OUTPUT_DIR=$(realpath "${2}")/
# go through every encrypted metadata file, read its content
# and use it to decrypt the corresponding, encrypted media file
for encrypted_file in "${INPUT_DIR}"*.pgp; do
gpg -q --decrypt "${encrypted_file}" | jq -r ".timestamp, .encryptionKey" | xargs sh -c "ffmpeg -decryption_key \$1 -i ${encrypted_file%%.*}.mp4 ${OUTPUT_DIR}/\$0.mp4"
done
@m-rey
Copy link
Author

m-rey commented Jun 18, 2021

Note: This in incompatible with the cryptocam versions >=2.0.0 !

Upstream has revamped basically every part of the project with the release of version 2. They've also switched to age for encrypting, among other things. That's one of the main reasons why this won't work anymore on videos captured with cryptocam 2.x.x
Luckily, they now also provide both a GUI and a CLI tool to decrypt the videos!

Take a look at https://gitlab.com/cryptocam/cryptocam-companion-cli (CLI) and https://gitlab.com/cryptocam/cryptocam-companion (GUI) if interested.

There's also a dedicated website over at https://cryptocam.gitlab.io/ with step by step guides, feature showcases and documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment