Skip to content

Instantly share code, notes, and snippets.

@kkew3
Last active December 15, 2021 02:59
Show Gist options
  • Save kkew3/d20d7c18f7e29e5a406ab4ff13e588f3 to your computer and use it in GitHub Desktop.
Save kkew3/d20d7c18f7e29e5a406ab4ff13e588f3 to your computer and use it in GitHub Desktop.
Check whether a video file has been corrupted
# original command adapted from https://superuser.com/a/100290
import subprocess
filename = ...
try:
_ = subprocess.check_call(['ffmpeg', '-v', 'error', '-i',
filename, '-f', 'null', '-'])
except subprocess.CalledProcessError:
# the subprocess call returns non-zero, which means filename
# has been corrupted;
# do whatever you want to do here
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment