Last summer was a chance for me and my family to do some water activities in the area. Snorkeling was a big favorite for my son. One of the locations had a fresh stock of fish that drew our attention. Unfortunately, the water in the lake grew cloudy due to our movement and it was a challenge to see. On a follow up visit, we brought one of my 808-16 video cameras. It’s a 720p camera and I wasn’t too worried about bricking it from water damage. We placed it in a plastic air tight food container with some added weight. It was suspended using some kite line that we used to move it around.
After capturing some video, we looked at it and noticed how cloudy it was. I figured that FFMpeg and ImageMagick could clean up the video.
Here is the script I used.
# Start of file
ffmpeg -i “MINI0057.MOV” -vf fps=30 “MINI0057_%04d.png”
# see – https://ffmpeg.org/ffmpeg.html#Video-and-Audio-file-format-conversion
# This extracts images from each of the videos frames using the ffmpeg command.
# Each image file is sequentally named MINI0057_0001.png, MINI0057_0002.png, etc.
mogrify -channel RGB -equalize +channel *.png
# see – https://imagemagick.org/script/command-line-options.php#equalize
# This performs a histogram equalization using the imagemagick command.
mogrify -unsharp 1.5×1.0+1.5+0.02 *.png
# see – https://imagemagick.org/script/command-line-options.php#unsharp
# This sharpens the image using the imagemagick command.
# I tested a variety of values and this produced the best results for this footage.
ls *.png > ImageFiles.txt
# The image list is output into a text file.
ffmpeg -y -r 30 -f concat -safe 0 -i “ImageFiles.txt” -c:v libx264 -vf “fps=30,format=yuv420p” MINI0057_Filtered.MOV
# This creates a video from the image file list contained in the text file.
ffmpeg -i MINI0057.MOV -i MINI0057_Filtered.MOV -filter_complex “[0:v]setpts=PTS-STARTPTS, pad=iw*2:ih[bg]; [1:v]setpts=PTS-STARTPTS[fg]; [bg][fg]overlay=w” MINI0003_SideBySide.MOV
# This create a side by side video of the original on the left and the processed video on the right.
# This deletes the image files processed, done for housekeeping.
# End of file
This script is more streamlined than my earlier efforts. I was able to run it and leave it until completion. The process did take quite some time to finish. In any event, it was nice to have a single process script that I could run and repurpose.
Here is an image frame of unprocessed content.
Here is the same image with histogram equalization.
Lastly, here is the same image, this time with sharpening enhancements.
It’s too bad vReveal pulled the plug on its paying customers, something I’ll always remember. This was one of many nudges for me to move to open sourced tools like FFMpeg and ImageMagick.