Created
November 28, 2012 16:28
-
-
Save muellermartin/4162360 to your computer and use it in GitHub Desktop.
Exposure fusion (a.k.a. "Fake HDR") workflow for Magic Lantern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Exposure fusion (a.k.a. "Fake HDR") workflow for Magic Lantern | |
# 2012-11-28 17:20:30 | |
# Martin Müller <[email protected]> | |
# | |
# REQUIREMENTS: | |
# ffmpeg | |
# enfuse | |
# hugin (for align_image_stack) | |
# | |
# TO DO: | |
# - check for existing (and working) commands | |
# - option for cleaning up to save disk space | |
# - GUI (Graphical User Interface) | |
# SETTINGS: | |
# Where to search for the movie clips (set to . for current directory) | |
SEARCHPATH=. | |
# Resulting frame rate | |
FPS=25 | |
# Path to align_image_stack executable | |
AIS=/Applications/Hugin/HuginTools/align_image_stack | |
for VIDEO in $(ls "$SEARCHPATH/"*".MOV") | |
do | |
# Extract filename without extension from whole path to file | |
FILE=$(basename "$VIDEO") | |
FILENAME=${FILE%.*} | |
# Check if directory exists | |
if [ ! -d "$FILENAME" ] | |
then | |
# Create directory with video name | |
mkdir "$FILENAME" | |
# Split odd frames from video to image sequence with ffmpeg | |
ffmpeg -i "$FILE" -filter:v select="not(mod(n\,2))",setpts="N/($FPS*TB)" -pix_fmt rgb24 -vcodec tiff "$FILENAME/$FILENAME-HDRa-%04d.tif" | |
# Split even frames from video to image sequence with ffmpeg | |
ffmpeg -i "$FILE" -filter:v select="mod(n\,2)",setpts="N/($FPS*TB)" -pix_fmt rgb24 -vcodec tiff "$FILENAME/$FILENAME-HDRb-%04d.tif" | |
fi | |
if [ ! -d "$FILENAME/aligned" ] | |
then | |
mkdir "$FILENAME/aligned" | |
for f in $(ls "$FILENAME/$FILENAME-HDRa-"*".tif") | |
do | |
NUMBER=${f##*-} | |
$AIS -a "$FILENAME-HDRb-aligned-" -o "$FILENAME/aligned/" "$f" "$FILENAME-HDRb-$NUMBER" | |
done | |
fi | |
if [ ! -d "$FILENAME/HDR" ] | |
then | |
mkdir "$FILENAME/HDR" | |
# Merge HDRa and HDRb image sequences to single image sequence with exposure fusion | |
for f in $(ls "$FILENAME/aligned/$FILENAME-HDRa-"*".tif") | |
do | |
NUMBER=${f##*-} | |
echo "$f (+) $FILENAME/aligned/$FILENAME-HDRb-$NUMBER => $FILENAME/HDR/HDR-$NUMBER" | |
enfuse -o "$FILENAME/HDR/$FILENAME-HDR-$NUMBER" "$f" "$FILENAME/aligned/$FILENAME-HDRb-$NUMBER" | |
done | |
fi | |
# Merge enfused image sequence to ProRes 422 QuickTime video | |
ffmpeg -r 25 -i "$FILENAME/HDR/$FILENAME-HDR-%04d.tif" -r 25 -vcodec prores -profile:v 2 "$FILENAME/HDR/$FILENAME-HDR.mov" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment