{"id":636,"date":"2019-09-21T11:16:56","date_gmt":"2019-09-21T11:16:56","guid":{"rendered":"http:\/\/james-batchelor.com\/?p=636"},"modified":"2019-09-04T11:23:44","modified_gmt":"2019-09-04T11:23:44","slug":"motioneye-timelapse-capture","status":"publish","type":"post","link":"https:\/\/james-batchelor.com\/index.php\/2019\/09\/21\/motioneye-timelapse-capture\/","title":{"rendered":"MotionEye Timelapse Capture"},"content":{"rendered":"\n<p>It\u2019s been a while since I had my last <a href=\"https:\/\/james-batchelor.com\/index.php\/2016\/09\/03\/automated-time-lapse-solution\/\">automated time-lapse solution<\/a>, and since the change of location and change of servers the setup has been lost in the ether.<\/p>\n\n\n\n<p>Back then, it was achieved with an off the shelf IP Camera, a Windows Server share and a batch script. Now that the <a href=\"https:\/\/james-batchelor.com\/index.php\/2019\/06\/29\/motioneye-cent-os-cctv-server\/\">Linux \/ Raspberry Pi CCTV solution<\/a> is up and running, I hope to re-instate the automated time lapse in a simpler way using MotionEye and Cent OS.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"254\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2019\/09\/mtc00.jpg\" alt=\"\" class=\"wp-image-637\" srcset=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2019\/09\/mtc00.jpg 640w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2019\/09\/mtc00-300x119.jpg 300w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/figure>\n\n\n\n<!--more-->\n\n\n\n<h3 class=\"wp-block-heading\">Capture Setup<\/h3>\n\n\n\n<p>Beginning with the image capture, which is setup much in the\nsame way as any other MotionEye Server setup.<\/p>\n\n\n\n<p>On the Pi, set the camera up as a Fast Network Camera then\nadd it to the server as a network camera.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"608\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2019\/09\/mtc01-1024x608.png\" alt=\"\" class=\"wp-image-638\" srcset=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2019\/09\/mtc01-1024x608.png 1024w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2019\/09\/mtc01-300x178.png 300w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2019\/09\/mtc01-768x456.png 768w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2019\/09\/mtc01.png 1085w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<p>In the Preference options, choose Still Images from the\ncapture options. I find a 20 second interval for skyline capture a good balance\nbetween smoothness of video and speed of changes.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"568\" height=\"242\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2019\/09\/mtc02.png\" alt=\"\" class=\"wp-image-639\" srcset=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2019\/09\/mtc02.png 568w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2019\/09\/mtc02-300x128.png 300w\" sizes=\"auto, (max-width: 568px) 85vw, 568px\" \/><\/figure>\n\n\n\n<p>Do not change the filename template as this needs to match\nthe script.<\/p>\n\n\n\n<p>Images only need to be stored for one day, as the converted\nvideo will not be subject to the file removal.<\/p>\n\n\n\n<p>Finally, on the web GUI, make a note of the File Storage\npath, this will help with the next step.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"556\" height=\"153\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2019\/09\/mtc03.png\" alt=\"\" class=\"wp-image-640\" srcset=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2019\/09\/mtc03.png 556w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2019\/09\/mtc03-300x83.png 300w\" sizes=\"auto, (max-width: 556px) 85vw, 556px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Video Setup<\/h3>\n\n\n\n<p>Log into the server via SSH and navigate to the directory\nthat contains the Camera folders<\/p>\n\n\n\n<pre class=\"wp-block-verse\">ls \/cctv<\/pre>\n\n\n\n<p>Create a new folder for the video output<\/p>\n\n\n\n<pre class=\"wp-block-verse\">mkdir Timelapse<\/pre>\n\n\n\n<p>Now navigate back to your home directory<\/p>\n\n\n\n<pre class=\"wp-block-verse\">cd<\/pre>\n\n\n\n<p>Create a new script file<\/p>\n\n\n\n<pre class=\"wp-block-verse\">nano timelapse.sh<\/pre>\n\n\n\n<p>Paste the following into the new text document, replacing\nwith your parameters<\/p>\n\n\n\n<pre class=\"wp-block-verse\">cd \/cctv\/Camera3\/ &amp;&amp;\ncd \"$(\\ls -1dt .\/*\/ | head -n 1)\" &amp;&amp; cat *.jpg | ffmpeg\n-framerate 25 -f image2pipe -vcodec mjpeg -i - -vcodec mpeg4 -b:v 9999999\n-qscale:v 0.1 -f avi \/cctv\/Timelapse\/\"timelapse_`date +%Y-%m-%d-%H-%M-%S`.avi\"<\/pre>\n\n\n\n<p>Where  <em>\/cctv\/Camera3\/<\/em>  is the images saved from the camera<br>and  <em>\/cctv\/Timelapse\/<\/em>  is the time-lapse directory just created.<\/p>\n\n\n\n<p>Save the script and exit with<\/p>\n\n\n\n<pre class=\"wp-block-verse\">Ctrl &amp; O<br>Ctrl &amp; X<\/pre>\n\n\n\n<p>Make the script executable with<\/p>\n\n\n\n<pre class=\"wp-block-verse\">chmod +x timelapse.sh<\/pre>\n\n\n\n<p>If there are images ready in todays folder, you can test the\nscript by running this from the home directory.<\/p>\n\n\n\n<pre class=\"wp-block-verse\">.\/timelapse.sh<\/pre>\n\n\n\n<p>Next let\u2019s create a trigger to run this script automatically<\/p>\n\n\n\n<pre class=\"wp-block-verse\">crontab -e<\/pre>\n\n\n\n<p>Enter the following in the new nano screen<\/p>\n\n\n\n<pre class=\"wp-block-verse\">58 23 * * * \/root\/timelapse.sh<\/pre>\n\n\n\n<p>This instructs the system to run the script at 23:58 every\nday<\/p>\n\n\n\n<p>Save the cron and exit with<\/p>\n\n\n\n<pre class=\"wp-block-verse\">Ctrl &amp; O<br>Ctrl &amp; X<\/pre>\n\n\n\n<p>It\u2019s now set, time to wait until the next day to see if it has run!<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"360\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2019\/09\/mtc04.gif\" alt=\"\" class=\"wp-image-641\"\/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>It\u2019s been a while since I had my last automated time-lapse solution, and since the change of location and change of servers the setup has been lost in the ether. Back then, it was achieved with an off the shelf IP Camera, a Windows Server share and a batch script. Now that the Linux \/ &hellip; <a href=\"https:\/\/james-batchelor.com\/index.php\/2019\/09\/21\/motioneye-timelapse-capture\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;MotionEye Timelapse Capture&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-636","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts\/636","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/comments?post=636"}],"version-history":[{"count":1,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts\/636\/revisions"}],"predecessor-version":[{"id":642,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts\/636\/revisions\/642"}],"wp:attachment":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/media?parent=636"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/categories?post=636"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/tags?post=636"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}