Sanzan is a simple encryption library to encrypt and decrypt videos while maintaining playability.
It uses NumPy and OpenCV to perform video frame manipulation, while using FFmpeg and Pydub for audio manipulation. Sanzan can be used either from the command line or in a Python program.
FFmpeg must be installed and in PATH
.
pip install sanzan
sz original.mp4 -k <key> -e -o encrypted.mp4
sz https://youtu.be/dQw4w9WgXcQ -k <key> -e -o encrypted.mp4
sz encrypted.mp4 -k <key> -d -o decrypted.mp4
sz encrypted.mp4 -k <key> -d -o decrypted.mp4 -p
Omit the -k
argument to encrypt using randomly generated keyfiles.
Use the -m
argument to specify mode: audio
, video
or full
(default).
Use the -q
flag for quiet mode.
Use the -a
argument to specify output audio format: mp3
, wav
(default), flac
, etc.
Use the -l
flag to use light encryption/decryption.
Use the -dn
flag to apply denoising to the output audio.
Use the -pp
flag to disable audio padding.
Use the -s
argument to specify scramble method: rows
(default), cols
, full
.
Use the -f
flag to generate a different scramble order every frame.
Alternatively, Sanzan provides a Python interface to programmatically access its functionality.
from sanzan import Sanzan
if __name__ == "__main__":
s = Sanzan("original.mp4")
s.set_password("1234")
s.encrypt("encrypted.mp4")
from sanzan import Sanzan
if __name__ == "__main__":
s = Sanzan("encrypted.mp4")
s.set_password("1234")
s.decrypt("decrypted.mp4", preview=True, denoise=True)