Skip to content

Instantly share code, notes, and snippets.

@scribblemaniac
Created August 1, 2015 00:00
Show Gist options
  • Select an option

  • Save scribblemaniac/b532f0f6904ceb627854 to your computer and use it in GitHub Desktop.

Select an option

Save scribblemaniac/b532f0f6904ceb627854 to your computer and use it in GitHub Desktop.
Vergence converter for animated stereograms
#!/bin/bash
# This script converts side-by-side animated stereograms between parallel and cross-eyed viewing methods.
# In other words, it splits a video vertically in the middle and swaps the two halves
# Dependencies:
# FFmpeg
# Usage:
# ./cross-converter.sh <input_file> <output_file>
print_usage() {
echo "Usage: ./cross-converter.sh <input_file> <output_file> [options]"
exit
}
if [[ $# -ne 2 ]]; then
echo "Invalid number of arguments: $#"
print_usage
fi
if [[ ! -f $1 ]]; then
echo "$1 does not exist."
print_usage
fi
if [ "$(which ffmpeg)" == "\n" ]; then
echo "This script requires ffmpeg to be installed"
echo $(which ffmpeg)
exit
fi
# [left] and [right] labels are referring to their side in the original video
ffmpeg -i "$1" -filter_complex "[0:0]crop=iw/2:ih:0:0[left];[0:0]crop=iw/2:ih:iw/2:0,pad=2*iw:ih[right];[right][left]overlay=main_w/2:0" -codec:a copy "$2"
echo "Conversion complete!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment