HDR script keep original framerate (Mac)

Started by Danne, January 09, 2018, 09:25:37 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Danne

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
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Exiftool
brew install exiftool
ffmpeg
brew install ffmpeg
enfuse/hugin
brew cask install hugin

Script
Put some HDR MOV files insisde a folder and run following script from within the folder in terminal:
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

Teamsleepkid

I really want to try this but it seems pretty hard. I'm basically retarded.   :P
EOS M

Danne

Here comes the dummy solution  :P:

Installing dependencies:
1 - Open up terminal and copy paste following into it:
/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)
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

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 | EOSM2.* | 50D.109

Danne


reddeercity

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

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

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:
#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.

Danne

Here is yet another take to HDR recording. I still focus on MOV and this time in conjunction with the very nice function fps override. Since it´s possible to override 1920x1080p H.264 MOV thanks to A1ex reverse engineering sourcery let´s try what can be done to reduce movement/ghosting and still achieve some good quality merged HDR output with some decent 1920x1080p footage.

This is needed:
Only thing needed are one or more MOV files recorded in HDR mode in regular mv1080p with fps override set to 38. End result will become merged mov 24fps files with nice quality and flow to it. Except for aligning and rescaling through hugin and ffmpeg(tblend filter) this script will also use ffmpeg minterpolate filter to drop frames with smooth high quality results. FFmpeg end part looking like this:
ffmpeg -r 38 -i %06d.tiff -vcodec prores -pix_fmt yuv422p10le -vf "minterpolate='fps=24'" HDR_enfuse_$(ls *.MOV | head -1 | cut -d "." -f1).mov

Added to this script are safeguards since multiprocessing sometimes seems to skip or loose a few frames. This will be checked upon now so should work more reliable.

Run the following script inside a folder with 38fps MOV files:
#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

#safeguards
   if ! [ -f 1.tiff ] || ! [ -f 2.tiff ]
   then
   sleep 2
rm $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 1' | cut -d "." -f2 | tr -d "/").tiff
/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
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
   fi

   if ! [ -f 01.tiff ] || ! [ -f 02.tiff ]
   then
   sleep 2
rm $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 2' | cut -d "." -f2 | tr -d "/").tiff
/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
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
   fi

   if ! [ -f 001.tiff ] || ! [ -f 002.tiff ]
   then
   sleep 2
rm $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 3' | cut -d "." -f2 | tr -d "/").tiff
/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
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
   fi

   if ! [ -f 0001.tiff ] || ! [ -f 0002.tiff ]
   then
   sleep 2
rm $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 4' | cut -d "." -f2 | tr -d "/").tiff
/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 
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
   fi

   if ! [ -f 00001.tiff ] || ! [ -f 00002.tiff ]
   then
   sleep 2
rm $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 5' | cut -d "." -f2 | tr -d "/").tiff
/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 
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
   fi

   if ! [ -f 0000001.tiff ] || ! [ -f 0000002.tiff ]
   then
   sleep 2
rm $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 6' | cut -d "." -f2 | tr -d "/").tiff
/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   
ffmpeg -i %06d.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
   fi

   if ! [ -f 00000001.tiff ] || ! [ -f 00000002.tiff ]
   then
   sleep 2
rm $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 7' | cut -d "." -f2 | tr -d "/").tiff
/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   
ffmpeg -i %07d.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
   fi

   if ! [ -f 000000001.tiff ] || ! [ -f 000000002.tiff ]
   then
   sleep 2
rm $(find -s . -maxdepth 1 -iname '*.tif' | awk 'FNR == 8' | cut -d "." -f2 | tr -d "/").tiff
/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   
ffmpeg -i %08d.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
   fi

#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 with very fine function 38fps MOV h.264 thanks to A1ex
ffmpeg -r 38 -i %06d.tiff -vcodec prores -pix_fmt yuv422p10le -vf "minterpolate='fps=24'" 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



Short example clip:
https://www.youtube.com/watch?v=v0zGwUSOasU&feature=youtu.be

DeafEyeJedi

This is so gnarly, @Danne and can't wait to get my hands dirty and dandy on this 38p hack of yours!
5D3.113 | 5D3.123 | EOSM.203 | 7D.203 | 70D.112 | 100D.101 | EOSM2.* | 50D.109

Danne

This script will run up to 4 processes simultaneously. Terminal will cat out subprocessing scripts and when all is done clean the folder leaving all files merged and ready. If any dependency is missing you will be asked to install what´s missing.
You will also be asked if you want to specify in and outcome of fps or leave it on auto. Why the in and out fps? Well, let´s say you record files in 30 or even 38 fps. Now you a can reduce frames nicely to 24 fps using ffmpeg minterpolate filter.
Inside a folder with HDR MOV files run this script:
(using pastebin, too many characters...)
https://pastebin.com/x4cM7EFC



DeafEyeJedi

Seriously you STILL just somehow manage to find ways to continue in maximizing the versatility of your amazing scripts all together.

It is extremely intriguing to know that we can finally be able keep the HDR fun alive and well lit even in its original frame rates.

Especially to go from 38p to 24p while in H.264 format. I mean that's just unheard of. There's a saying that goes 'legends never die' and that's the true legendary in you, @Danne!
5D3.113 | 5D3.123 | EOSM.203 | 7D.203 | 70D.112 | 100D.101 | EOSM2.* | 50D.109