{"id":3593,"date":"2021-01-22T21:48:04","date_gmt":"2021-01-23T05:48:04","guid":{"rendered":"http:\/\/192.168.3.4\/?p=3593"},"modified":"2021-09-10T20:58:20","modified_gmt":"2021-09-11T03:58:20","slug":"cleaning-up-underwater-video","status":"publish","type":"post","link":"https:\/\/www.cloudacm.com\/?p=3593","title":{"rendered":"Cleaning Up Underwater Video"},"content":{"rendered":"<p>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&#8217;s a 720p camera and I wasn&#8217;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.<\/p>\n<p>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.<\/p>\n<p><iframe loading=\"lazy\" title=\"Submersible Video\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/evhswOHZAuk?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<p>Here is the script I used.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">#!\/bin\/bash\r\n\r\nffmpeg -i \"MINI0057.MOV\" -vf fps=30 \"MINI0057_%04d.png\"\r\n# see - https:\/\/ffmpeg.org\/ffmpeg.html#Video-and-Audio-file-format-conversion\r\n# This extracts images from each of the videos frames using the ffmpeg command.\r\n# Each image file is sequentally named MINI0057_0001.png, MINI0057_0002.png, etc.\r\nmogrify -channel RGB -equalize +channel *.png\r\n# see - https:\/\/imagemagick.org\/script\/command-line-options.php#equalize\r\n# This performs a histogram equalization using the imagemagick command.\r\nmogrify -unsharp 1.5x1.0+1.5+0.02 *.png\r\n# see - https:\/\/imagemagick.org\/script\/command-line-options.php#unsharp\r\n# This sharpens the image using the imagemagick command.\r\n# I tested a variety of values and this produced the best results for this footage.\r\nls *.png &amp;gt; ImageFiles.txt\r\n# The image list is output into a text file.\r\nffmpeg -y -r 30 -f concat -safe 0 -i \"ImageFiles.txt\" -c:v libx264 -vf \"fps=30,format=yuv420p\" MINI0057_Filtered.MOV\r\n# This creates a video from the image file list contained in the text file.\r\nffmpeg -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\r\n# This create a side by side video of the original on the left and the processed video on the right.\r\nrm *.png\r\n# This deletes the image files processed, done for housekeeping.\r\n<\/pre>\n<p>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.\u00a0 It&#8217;s too bad vReveal pulled the plug on its paying customers, something I&#8217;ll always remember. This was one of many nudges for me to move to open sourced tools like FFMpeg and ImageMagick.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;s a 720p camera and I wasn&#8217;t too&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.cloudacm.com\/?p=3593\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,3],"tags":[],"class_list":["post-3593","post","type-post","status-publish","format-standard","hentry","category-computer-vision","category-rd"],"_links":{"self":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts\/3593","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3593"}],"version-history":[{"count":6,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts\/3593\/revisions"}],"predecessor-version":[{"id":3823,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts\/3593\/revisions\/3823"}],"wp:attachment":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3593"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3593"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3593"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}