Author Topic: HDR script keep original framerate (Mac)  (Read 321 times)

Danne

  • Hero Member
  • *****
  • Posts: 3612
HDR script keep original framerate (Mac)
« on: January 09, 2018, 09:25:37 PM »
Been testing enfuse and align_image to refine some ideas around HDR recording and after some tinkering I managed to get some decent results. For now it works with MOV(H.264) files. The script processes frames in a consecutive manner so the original fps will be kept. Now this doesn´t mean HDR will suddenly work with 24 and 25 fps without ghosting and so on but as the script will use align_image most movement will be aligned so feel free to test lower framerates such as 24, 25 and 30 fps.
The script will actually work three files creating a new one then proceed to the next three files creating the next frame etc. Why three? I can´t combine enfuse and align_image and just process two files after each other without having flicker going on(some interpolation caveat).

The script will create two files. One called HDR_tblend_ and the other one HDR_enfuse_. This is for comparison reasons. The HDR_enfuse should look better. The tblend filter is used with ffmpeg so that one isn´t even touching enfuse/align_image. Recommended to film with 50 or 60 fps but feel free to test slower framerates as well.

You need following installed for the script to work:
Homebrew
Code: [Select]
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"Exiftool
Code: [Select]
brew install exiftoolffmpeg
Code: [Select]
brew install ffmpegenfuse/hugin
Code: [Select]
brew cask install hugin
Script 1
Put some HDR MOV files insisde a folder and run following script from within the folder in terminal:
Code: [Select]
#Scripts for testing purposes
#Drop HDR MOV files into a folder and run the script i terminal from within the folder with MOV files. Hit enter when prompted
#The script will create three different types of HDR files. Please compare and report results
#All scripts combines consecutive frames so original fps is kept

#dependencies:
#install homebrew if not already:
#in terminal:
#/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

#Then install:
#brew install exiftool
#brew install ffmpeg
#brew cask install hugin
cat <<'EOF' > HDR_script
#!/bin/bash

for FILE in `ls *.MOV 2>/dev/null`; do
ffmpeg -i $(ls *.MOV | head -1) -pix_fmt rgb24 %06d.tif

#crop and rescale is needed is needed after aligning. Will take place in #output cropped and aligned images section
cr_W=$(echo $(exiftool $(ls *.MOV | head -1) | awk '/Image Size/ { print $5; exit }' | cut -d "x" -f1 ))
cr_H=$(echo $(exiftool $(ls *.MOV | head -1) | awk '/Image Size/ { print $5; exit }' | cut -d "x" -f2 ))
cr_Ws=$(echo $cr_W*0.98 | bc -l | cut -d "." -f1)
cr_Hs=$(echo $cr_H*0.98 | bc -l | cut -d "." -f1)
crp_fix=$(echo crop=$cr_Ws:$cr_Hs,scale=$cr_W:$cr_H)

#First script combines enfused and aligned tif files then exports it to a prores mov file

while grep -E "tif" <<< $(find . -maxdepth 1 -iname '*.tif')
do

#align images and rename
/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned.tif $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 1') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 2') && mv aligned.tif0000.tif 1.tiff && mv aligned.tif0001.tif 2.tiff & pid1=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned2.tif $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 2') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 3') && mv aligned2.tif0000.tif 01.tiff && mv aligned2.tif0001.tif 02.tiff & pid2=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned3.tif $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 3') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 4') && mv aligned3.tif0000.tif 001.tiff && mv aligned3.tif0001.tif 002.tiff & pid3=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned4.tif $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 4') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 5') && mv aligned4.tif0000.tif 0001.tiff && mv aligned4.tif0001.tif 0002.tiff & pid4=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned5.tif $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 5') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 6') && mv aligned5.tif0000.tif 00001.tiff && mv aligned5.tif0001.tif 00002.tiff & pid5=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned6.tif $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 6') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 7') && mv aligned6.tif0000.tif 0000001.tiff && mv aligned6.tif0001.tif 0000002.tiff & pid6=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned7.tif $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 7') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 8') && mv aligned7.tif0000.tif 00000001.tiff && mv aligned7.tif0001.tif 00000002.tiff & pid7=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned8.tif $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 8') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 9') && mv aligned8.tif0000.tif 000000001.tiff && mv aligned8.tif0001.tif 000000002.tiff & pid8=$!

#wait for jobs to end
    wait < <(jobs -p)

#output cropped and aligned images
ffmpeg -i %09d.tiff -pix_fmt rgb24 -vf tblend=all_mode=average,$crp_fix $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 8' | cut -d "." -f2 | tr -d "/").tiff
ffmpeg -i %08d.tiff -pix_fmt rgb24 -vf tblend=all_mode=average,$crp_fix $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 7' | cut -d "." -f2 | tr -d "/").tiff
ffmpeg -i %07d.tiff -pix_fmt rgb24 -vf tblend=all_mode=average,$crp_fix $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 6' | cut -d "." -f2 | tr -d "/").tiff
ffmpeg -i %05d.tiff -pix_fmt rgb24 -vf tblend=all_mode=average,$crp_fix $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 5' | cut -d "." -f2 | tr -d "/").tiff
ffmpeg -i %04d.tiff -pix_fmt rgb24 -vf tblend=all_mode=average,$crp_fix $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 4' | cut -d "." -f2 | tr -d "/").tiff
ffmpeg -i %03d.tiff -pix_fmt rgb24 -vf tblend=all_mode=average,$crp_fix $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 3' | cut -d "." -f2 | tr -d "/").tiff
ffmpeg -i %02d.tiff -pix_fmt rgb24 -vf tblend=all_mode=average,$crp_fix $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 2' | cut -d "." -f2 | tr -d "/").tiff
ffmpeg -i %01d.tiff -pix_fmt rgb24 -vf tblend=all_mode=average,$crp_fix $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 1' | cut -d "." -f2 | tr -d "/").tiff

#remove unwanted files
rm 000000001.tiff 000000002.tiff 00000001.tiff 00000002.tiff 0000001.tiff 0000002.tiff 00001.tiff 00002.tiff 0001.tiff 0002.tiff 001.tiff 002.tiff 01.tiff 02.tiff 1.tiff 2.tiff

rm $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 8') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 7') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 6') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 5') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 4') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 3') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 2') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 1')

done

#output to prores
ffmpeg -r $(exiftool $(ls *.MOV | head -1) | grep 'Video Frame Rate' | cut -d ":" -f2) -i %06d.tiff -vcodec prores -pix_fmt yuv422p10le HDR_enfuse_$(ls *.MOV | head -1 | cut -d "." -f1).mov

mkdir -p HDR_ORIGINALS
mv $(ls *.MOV | head -1) HDR_ORIGINALS
rm *.tiff

done

EOF
sleep 0.2 && clear && echo "Hit enter" &
. HDR_script && rm HDR_script

Teamsleepkid

  • Member
  • ***
  • Posts: 188
Re: HDR script keep original framerate (Mac)
« Reply #1 on: January 11, 2018, 07:05:17 AM »
I really want to try this but it seems pretty hard. I'm basically retarded.   :P
EOS M

Danne

  • Hero Member
  • *****
  • Posts: 3612
Re: HDR script keep original framerate (Mac)
« Reply #2 on: January 11, 2018, 08:40:40 AM »
Here comes the dummy solution  :P:

Installing dependencies:
1 - Open up terminal and copy paste following into it:
Code: [Select]
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install exiftool
brew install ffmpeg
brew cask install hugin
press enter


Running the script:
1 - open up terminal
2 - write cd hit space and drag a folder with MOV files onto terminal after the word cd
3 - Press enter
4 - Copy paste the entire script below into terminal and hit enter if needed(sometimes it starts without)
Code: [Select]
cat <<'EOF' > HDR_script
#!/bin/bash

for FILE in `ls *.MOV 2>/dev/null`; do
ffmpeg -i $(ls *.MOV | head -1) -pix_fmt rgb24 %06d.tif

#First script combines enfused and aligned tif files then exports it to a prores mov file

while grep -E "tif" <<< $(find . -maxdepth 1 -iname '*.tif')
do
/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned.tif $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 1') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 2') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 3') && /Applications/Hugin/tools_mac/enfuse --exposure-optimum=0.5 --exposure-width=0.5 -o $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 1' | cut -d "." -f2 | tr -d "/").tiff aligned.tif0000.tif aligned.tif0001.tif aligned.tif0002.tif && rm aligned.tif0000.tif aligned.tif0001.tif aligned.tif0002.tif & pid1=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned2.tif $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 2') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 1') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 3') && /Applications/Hugin/tools_mac/enfuse --exposure-optimum=0.5 --exposure-width=0.5 -o $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 2' | cut -d "." -f2 | tr -d "/").tiff aligned2.tif0000.tif aligned2.tif0001.tif aligned2.tif0002.tif && rm aligned2.tif0000.tif aligned2.tif0001.tif aligned2.tif0002.tif & pid2=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned3.tif $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 3') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 4') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 5') && /Applications/Hugin/tools_mac/enfuse --exposure-optimum=0.5 --exposure-width=0.5 -o $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 3' | cut -d "." -f2 | tr -d "/").tiff aligned3.tif0000.tif aligned3.tif0001.tif aligned3.tif0002.tif && rm aligned3.tif0000.tif aligned3.tif0001.tif aligned3.tif0002.tif & pid3=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned4.tif $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 4') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 3') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 5') && /Applications/Hugin/tools_mac/enfuse --exposure-optimum=0.5 --exposure-width=0.5 -o $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 4' | cut -d "." -f2 | tr -d "/").tiff aligned4.tif0000.tif aligned4.tif0001.tif aligned4.tif0002.tif && rm aligned4.tif0000.tif aligned4.tif0001.tif aligned4.tif0002.tif & pid4=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned5.tif $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 5') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 6') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 7') && /Applications/Hugin/tools_mac/enfuse --exposure-optimum=0.5 --exposure-width=0.5 -o $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 5' | cut -d "." -f2 | tr -d "/").tiff aligned5.tif0000.tif aligned5.tif0001.tif aligned5.tif0002.tif && rm aligned5.tif0000.tif aligned5.tif0001.tif aligned5.tif0002.tif & pid5=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned6.tif $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 6') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 5') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 7') && /Applications/Hugin/tools_mac/enfuse --exposure-optimum=0.5 --exposure-width=0.5 -o $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 6' | cut -d "." -f2 | tr -d "/").tiff aligned6.tif0000.tif aligned6.tif0001.tif aligned6.tif0002.tif && rm aligned6.tif0000.tif aligned6.tif0001.tif aligned6.tif0002.tif & pid6=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned7.tif $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 7') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 8') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 9') && /Applications/Hugin/tools_mac/enfuse --exposure-optimum=0.5 --exposure-width=0.5 -o $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 7' | cut -d "." -f2 | tr -d "/").tiff aligned7.tif0000.tif aligned7.tif0001.tif aligned7.tif0002.tif && rm aligned7.tif0000.tif aligned7.tif0001.tif aligned7.tif0002.tif & pid7=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned8.tif $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 8') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 7') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 9') && /Applications/Hugin/tools_mac/enfuse --exposure-optimum=0.5 --exposure-width=0.5 -o $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 8' | cut -d "." -f2 | tr -d "/").tiff aligned8.tif0000.tif aligned8.tif0001.tif aligned8.tif0002.tif && rm aligned8.tif0000.tif aligned8.tif0001.tif aligned8.tif0002.tif & pid8=$!

#wait for jobs to end
    wait < <(jobs -p)

mkdir -p tiftmp

mv $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 1') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 2') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 3') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 4') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 5') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 6') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 7') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 8') tiftmp

done

#Command below produces a prores mov file by working the tblend filter in ffmpeg
ffmpeg -i $(ls *.MOV | head -1) -vcodec prores -pix_fmt yuv444p10 -vf tblend=all_mode=average HDR_tblend_$(ls *.MOV | head -1 | cut -d "." -f1).mov

ffmpeg -r $(exiftool $(ls *.MOV | head -1) | grep 'Video Frame Rate' | cut -d ":" -f2) -i %06d.tiff -vcodec prores -pix_fmt yuv444p10 HDR_enfuse_$(ls *.MOV | head -1 | cut -d "." -f1).mov

rm *.tiff
rm -r tiftmp
mkdir -p HDR_ORIGINALS
mv $(ls *.MOV | head -1) HDR_ORIGINALS
done

EOF
sleep 0.2 && clear && echo "Hit enter" &
. HDR_script && rm HDR_script
press enter if needed(if it doesn´t start right away)

DeafEyeJedi

  • Hero Member
  • *****
  • Posts: 3064
  • 5D3 / M1 / 7D / 70D / SL1
Re: HDR script keep original framerate (Mac)
« Reply #3 on: January 12, 2018, 11:22:18 PM »
So happy to see good old HDR still being in the works...  gonna definitely try this one out and thanks @Danne!
5D3.113 • 5D3.123 • EOSM.203 • 7D.203 • 70D.112 • 100D.101

Danne

  • Hero Member
  • *****
  • Posts: 3612
Re: HDR script keep original framerate (Mac)
« Reply #4 on: January 13, 2018, 12:13:26 AM »
You're welcome man  :)

reddeercity

  • Hero Member
  • *****
  • Posts: 1437
Re: HDR script keep original framerate (Mac)
« Reply #5 on: January 13, 2018, 05:03:23 AM »
Don't that this the wrong way but why reinvent the wheel , unless you like scripting
alex4d-fcpx-magic-lantern-hdr pluggin
This been here since 2012 , thou it's for Final Cut Pro X work with h264 , ml raw converted to prores , works will .


Danne

  • Hero Member
  • *****
  • Posts: 3612
Re: HDR script keep original framerate (Mac)
« Reply #6 on: January 13, 2018, 07:48:02 AM »
He's using the old principle loosing half of the frames(at least my understanding from reading the post, didn't test). I am grabbing the following frame(consecutive) thus retaining original framerate. This effectively means you could shoot in 24fps without the need for interpolation of lost frames. I am also using align_image which will makes a massive difference when reducing ghosting.

Danne

  • Hero Member
  • *****
  • Posts: 3612
Re: HDR script keep original framerate (Mac)
« Reply #7 on: January 15, 2018, 02:39:54 PM »
Here´s another script roundtrip to obtain a flicker free HDR output using ffmpeg tblend average filter instead of applying enfuse. I´m using a combination of hugin align_image and then I crop and scale back to original aspect ratio leaving a prores file ready to use. The issue with enfuse is that interpolation of borders will cause flicker and tblend does not:
Code: [Select]
#Scripts for testing purposes
#Drop HDR MOV files into a folder and run the script i terminal from within the folder with MOV files. Hit enter when prompted
#The script will create three different types of HDR files. Please compare and report results
#All scripts combines consecutive frames so original fps is kept

#dependencies:
#install homebrew if not already:
#in terminal:
#/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

#Then install:
#brew install exiftool
#brew install ffmpeg
#brew cask install hugin
cat <<'EOF' > HDR_script
#!/bin/bash

for FILE in `ls *.MOV 2>/dev/null`; do
ffmpeg -i $(ls *.MOV | head -1) -pix_fmt rgb24 %06d.tif

#crop and rescale is needed is needed after aligning. Will take place in #output cropped and aligned images section
cr_W=$(echo $(exiftool $(ls *.MOV | head -1) | awk '/Image Size/ { print $5; exit }' | cut -d "x" -f1 ))
cr_H=$(echo $(exiftool $(ls *.MOV | head -1) | awk '/Image Size/ { print $5; exit }' | cut -d "x" -f2 ))
cr_Ws=$(echo $cr_W*0.98 | bc -l | cut -d "." -f1)
cr_Hs=$(echo $cr_H*0.98 | bc -l | cut -d "." -f1)
crp_fix=$(echo crop=$cr_Ws:$cr_Hs,scale=$cr_W:$cr_H)

#First script combines enfused and aligned tif files then exports it to a prores mov file

while grep -E "tif" <<< $(find . -maxdepth 1 -iname '*.tif')
do

#align images and rename
/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned.tif $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 1') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 2') && mv aligned.tif0000.tif 1.tiff && mv aligned.tif0001.tif 2.tiff & pid1=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned2.tif $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 2') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 3') && mv aligned2.tif0000.tif 01.tiff && mv aligned2.tif0001.tif 02.tiff & pid2=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned3.tif $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 3') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 4') && mv aligned3.tif0000.tif 001.tiff && mv aligned3.tif0001.tif 002.tiff & pid3=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned4.tif $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 4') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 5') && mv aligned4.tif0000.tif 0001.tiff && mv aligned4.tif0001.tif 0002.tiff & pid4=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned5.tif $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 5') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 6') && mv aligned5.tif0000.tif 00001.tiff && mv aligned5.tif0001.tif 00002.tiff & pid5=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned6.tif $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 6') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 7') && mv aligned6.tif0000.tif 0000001.tiff && mv aligned6.tif0001.tif 0000002.tiff & pid6=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned7.tif $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 7') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 8') && mv aligned7.tif0000.tif 00000001.tiff && mv aligned7.tif0001.tif 00000002.tiff & pid7=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned8.tif $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 8') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 9') && mv aligned8.tif0000.tif 000000001.tiff && mv aligned8.tif0001.tif 000000002.tiff & pid8=$!

#wait for jobs to end
    wait < <(jobs -p)

#output cropped and aligned images
ffmpeg -i %09d.tiff -pix_fmt rgb24 -vf tblend=all_mode=average,$crp_fix $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 8' | cut -d "." -f2 | tr -d "/").tiff
ffmpeg -i %08d.tiff -pix_fmt rgb24 -vf tblend=all_mode=average,$crp_fix $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 7' | cut -d "." -f2 | tr -d "/").tiff
ffmpeg -i %07d.tiff -pix_fmt rgb24 -vf tblend=all_mode=average,$crp_fix $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 6' | cut -d "." -f2 | tr -d "/").tiff
ffmpeg -i %05d.tiff -pix_fmt rgb24 -vf tblend=all_mode=average,$crp_fix $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 5' | cut -d "." -f2 | tr -d "/").tiff
ffmpeg -i %04d.tiff -pix_fmt rgb24 -vf tblend=all_mode=average,$crp_fix $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 4' | cut -d "." -f2 | tr -d "/").tiff
ffmpeg -i %03d.tiff -pix_fmt rgb24 -vf tblend=all_mode=average,$crp_fix $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 3' | cut -d "." -f2 | tr -d "/").tiff
ffmpeg -i %02d.tiff -pix_fmt rgb24 -vf tblend=all_mode=average,$crp_fix $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 2' | cut -d "." -f2 | tr -d "/").tiff
ffmpeg -i %01d.tiff -pix_fmt rgb24 -vf tblend=all_mode=average,$crp_fix $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 1' | cut -d "." -f2 | tr -d "/").tiff

#remove unwanted files
rm 000000001.tiff 000000002.tiff 00000001.tiff 00000002.tiff 0000001.tiff 0000002.tiff 00001.tiff 00002.tiff 0001.tiff 0002.tiff 001.tiff 002.tiff 01.tiff 02.tiff 1.tiff 2.tiff

rm $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 8') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 7') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 6') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 5') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 4') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 3') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 2') $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 1')

done

#output to prores
ffmpeg -r $(exiftool $(ls *.MOV | head -1) | grep 'Video Frame Rate' | cut -d ":" -f2) -i %06d.tiff -vcodec prores -pix_fmt yuv422p10le HDR_enfuse_$(ls *.MOV | head -1 | cut -d "." -f1).mov

mkdir -p HDR_ORIGINALS
mv $(ls *.MOV | head -1) HDR_ORIGINALS
rm *.tiff

done

EOF
sleep 0.2 && clear && echo "Hit enter" &
. HDR_script && rm HDR_script

I´m curious if 30 fps could work somewhat ok with this script so if there could be some testing around that it would be cool.