Skip to content

Instantly share code, notes, and snippets.

@Wuelle
Last active September 6, 2021 20:30
Show Gist options
  • Save Wuelle/95431c3101258829e39591f974b3cac9 to your computer and use it in GitHub Desktop.
Save Wuelle/95431c3101258829e39591f974b3cac9 to your computer and use it in GitHub Desktop.
Quick Shell Script to run my edge detection algorithm on a given video file
# use with https://github.com/Wuelle/Sobel-operator
# Create tmp directories
mkdir _tmp
mkdir _tmp/img
mkdir _tmp/processed
# Extract audio and source images from the input file
ffmpeg -nostdin -i input.mp4 _tmp/img/%06d.png
ffmpeg -nostdin -i input.mp4 _tmp/audio.mp3
# Apply the edge detection
NUM_IMG=$(ls _tmp/img/ | wc -l)
CURR_IMG=0
for filename in _tmp/img/*; do
BASE=$(basename $filename)
echo "[${CURR_IMG}/${NUM_IMG}]: $BASE"
python3 edge_detection.py ${filename} "_tmp/processed/$BASE"
CURR_IMG=$((CURR_IMG+1))
done
# Concatenate images into (silent) video
ffmpeg -nostdin -i _tmp/processed/%06d.png _tmp/silent.mp4
# Add the audio back in
ffmpeg -nostdin -i _tmp/silent.mp4 -i _tmp/audio.mp3 output.mp4
# Cleanup
rm -rf _tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment