Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - PhilFree

#1
Hi everyone!

Would it be possible to store movie recording start time in a more precise manner with frame number?
That could be stored into the log file that MOVIE_LOGGING is writing. Currently there is:
Start          : 2016/05/23 14:49:21
but it could be in timecode format like:
Start          : 2016/05/23 14:49:21.25

This could help to synchronize for multiple camera setups. In the beginning on shooting session one would take each camera and make a brief record of a screen with running time code - "master timecode" (e.g. an application on smartphone, or may be ML one day will generate such screen from current time).
Then on the PC we open the first frame of time code recording. On the screen we have the value of master time code. In the log file we have value of time on that camera. Now all we have is to calculate the difference between these two and, using that difference, create correct time code for all the clips, that were recorded from that camera in that shooting session (this probably could be accomplished by ffmpeg and some bash scripting or a simple application).

Sure, this will not be precise - after some time of shooting there will be 1 frame difference, then 2 frame and so on. But should be ok for 1-2 hour shooting, when 100% precision is not important.

P.S.
Of course, it would be cool, it cameras could just sync they time by themselves - with audio time code (do I understand correctly, that only on some models it's possible to generate or analyse the sound), or may be by generating bar/QR codes on the LCD screen and shooting this code with another camera - but this will require a lot of programming effort. But above approachi seems to be simple and efficient - or am I missing someting?
#2
I wonder why this topic does not seem to be popular. Is there a better/faster way on Linux, or no one is using Linux for processing? is I've tried the script on linux and I am satisfied with the results. Thanks to the author of the original script. The only disadvantage is the processing speed.
I modified it to use ffmpeg instead of mplayer/mencoder, since the latter were not available on ubuntu 15.10. And the output is in some lossless format. So the current code looks like this:


#!/bin/bash

# Usage: vid2hdr.sh namevid.mov
# Based on http://www.magiclantern.fm/forum/index.php?topic=1477.0

alignFrames() {
noframes=`ls frames/*.png | wc -l`

for i in `seq 1 2 $noframes`; do
in1=`printf "frames/%08d.png" "$i"`
in2=`printf "frames/%08d.png" "$((i+1))"`
out1a=`printf "%08d_A.tif" "$i"`
out1b=`printf "%08d_B.tif" "$i"`

out2a=`printf "%08d_A.tif" "$((i+1))"`
out2b=`printf "%08d_B.tif" "$((i+1))"`

align_image_stack -a first_frame $in1 $in2
mv first_frame0000.tif ./align/$out1a
mv first_frame0001.tif ./align/$out1b

align_image_stack -a second_frame $in2 $in1
mv second_frame0000.tif ./align/$out2b
mv second_frame0001.tif ./align/$out2a

done
}

myCropFrames() {
noframes=`ls ./align/*.tif | wc -l`
noframes=$(($noframes/2))  #delen door twee
for (( n=1; n<=$noframes; n++ )); do
in1=`printf "./align/%08d_A.tif" "$n"`
in2=`printf "./align/%08d_B.tif" "$n"`
echo "cropping frame $out from $in1 and $in2 ..."
#w=1920:h=1080
mogrify -crop 1820x1024+50+28 $in1    # crop, but maintain aspect ratio
mogrify -crop 1820x1024+50+28 $in2
done
}

myHdrFrames() {
noframes=`ls ./align/*.tif | wc -l`
noframes=$(($noframes/2))  #delen door twee
for (( n=1; n<=$noframes; n++ )); do
in1=`printf "./align/%08d_A.tif" "$n"`
in2=`printf "./align/%08d_B.tif" "$n"`
out=`printf "./align/hdr/%08d.png" "$n"`
echo "creating HDR frame $out from $in1 and $in2 ..."
#enfuse -f 1820x1024+50+28 --compression=95 -o $out $in1 $in2  #Doesn't crop, bug...
#enfuse --compression=95 -o $out $in1 $in2
enfuse -o $out $in1 $in2
done
}

encodeVideo() {
rm $output_filename
ffmpeg -start_number 1 -i ./align/hdr/%8d.png -vcodec ffv1 $output_filename
}

cleanup() {
rm -rf align
mkdir align
mkdir align/hdr
rm -rf frames
mkdir frames
}

output_filename=${1%.*}_hdr_ffv1.avi

echo === Cleaning up ===
cleanup                                     # Be sure this is what you want ;-)
echo === Extracting frames ===
ffmpeg -i $1 -t 00:00:01.0 "frames/%08d.png"  # process only first second of the video
#ffmpeg -i $1 %08d.png                      # process everyting

echo === Aligning frames ===
alignFrames
echo === Cropping frames ===
myCropFrames                               
echo === HDRing frames ===
myHdrFrames
echo === Encoding video ===
encodeVideo
echo === Cleaning up ===
cleanup
exit


Ther's still a lot to improve:
- multithreading - I have no idea how to implement this
- create less temp files - it could keep only a few tif files and delete them as soon as final output frame is created
- autocrop calculation - is there a way to get data from align_image_stack about maximum offset, that is encountered?
- any other approach instead of cropping - is there some temporal filter, that could take data from previous/consecutive frame to avoid cropping?