{"id":448,"date":"2011-06-23T12:48:27","date_gmt":"2011-06-23T11:48:27","guid":{"rendered":"http:\/\/www.streppone.it\/cosimo\/blog\/2011\/06\/capture-a-webcam-image-with-a-simple-bash-script\/"},"modified":"2011-06-23T12:48:27","modified_gmt":"2011-06-23T11:48:27","slug":"capture-a-webcam-image-with-a-simple-bash-script","status":"publish","type":"post","link":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/06\/capture-a-webcam-image-with-a-simple-bash-script\/","title":{"rendered":"Capture a webcam image with a simple bash script"},"content":{"rendered":"<p>I did that a few months ago to make a poor man&#39;s time-lapse video. <a href=\"http:\/\/www.youtube.com\/watch?v=NrEcwRxIe8k\" rel=\"nofollow\">This one<\/a>. I said I&#39;d post how to do it somewhere. Here it is.<\/p>\n<p>This is a bash script that will capture an image from a webcam or similar video acquisition device. Works on Linux only I guess. Makes use of gstreamer and video for linux.<\/p>\n<pre><code>\r\n#!\/bin\/bash\r\n\r\nDEST_DIR=&quot;$HOME\/Pictures\/Webcam&quot;\r\n\r\nif [ ! -e $DEST_DIR ]; then\r\n    mkdir $DEST_DIR\r\nfi\r\n\r\nDAY_DIR=&quot;$DEST_DIR\/`date +&#39;%Y%m%d&#39;`&quot;\r\nif [ ! -e $DAY_DIR ]; then\r\n    mkdir $DAY_DIR\r\nfi\r\n\r\nPIC_FILE=&quot;$DAY_DIR\/webcam-`date +&#39;%H%M%S&#39;`.jpg&quot;\r\ngst-launch v4l2src num-buffers=1 ! jpegenc ! filesink location=$PIC_FILE\r\n<\/code><\/pre>\n<p>Save as <code>~\/bin\/camera-snapshot<\/code>, and put it in crontab every minute if you want :)<br \/>\nAfter a while you will have a folder filled with pictures.<\/p>\n<p>If you also want to assemble them into a movie file, use the excellent <code>ffmpeg<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I did that a few months ago to make a poor man&#39;s time-lapse video. This one. I said I&#39;d post how to do it somewhere. Here it is. This is a bash script that will capture an image from a webcam or similar video acquisition device. Works on Linux only I guess. Makes use of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[304,302,308,305,306,307,300,301,303],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Capture a webcam image with a simple bash script - Random hacking<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/06\/capture-a-webcam-image-with-a-simple-bash-script\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Capture a webcam image with a simple bash script - Random hacking\" \/>\n<meta property=\"og:description\" content=\"I did that a few months ago to make a poor man&#039;s time-lapse video. This one. I said I&#039;d post how to do it somewhere. Here it is. This is a bash script that will capture an image from a webcam or similar video acquisition device. Works on Linux only I guess. Makes use of [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/06\/capture-a-webcam-image-with-a-simple-bash-script\/\" \/>\n<meta property=\"og:site_name\" content=\"Random hacking\" \/>\n<meta property=\"article:published_time\" content=\"2011-06-23T11:48:27+00:00\" \/>\n<meta name=\"author\" content=\"cosimo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"cosimo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/06\/capture-a-webcam-image-with-a-simple-bash-script\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/06\/capture-a-webcam-image-with-a-simple-bash-script\/\"},\"author\":{\"name\":\"cosimo\",\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1\"},\"headline\":\"Capture a webcam image with a simple bash script\",\"datePublished\":\"2011-06-23T11:48:27+00:00\",\"dateModified\":\"2011-06-23T11:48:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/06\/capture-a-webcam-image-with-a-simple-bash-script\/\"},\"wordCount\":108,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1\"},\"keywords\":[\"camera\",\"ffmpeg\",\"gst-launch\",\"gstreamer\",\"movie\",\"snapshot\",\"time-lapse\",\"v4l\",\"webcam\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/06\/capture-a-webcam-image-with-a-simple-bash-script\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/06\/capture-a-webcam-image-with-a-simple-bash-script\/\",\"url\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/06\/capture-a-webcam-image-with-a-simple-bash-script\/\",\"name\":\"Capture a webcam image with a simple bash script - Random hacking\",\"isPartOf\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#website\"},\"datePublished\":\"2011-06-23T11:48:27+00:00\",\"dateModified\":\"2011-06-23T11:48:27+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/06\/capture-a-webcam-image-with-a-simple-bash-script\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/06\/capture-a-webcam-image-with-a-simple-bash-script\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/06\/capture-a-webcam-image-with-a-simple-bash-script\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.streppone.it\/cosimo\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Capture a webcam image with a simple bash script\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#website\",\"url\":\"https:\/\/www.streppone.it\/cosimo\/blog\/\",\"name\":\"Random hacking\",\"description\":\"Assume nothing. Code defensively. Keep it simple, stupid!\",\"publisher\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.streppone.it\/cosimo\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1\",\"name\":\"cosimo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cb1d938720df45a2720724aae99e3bfc?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cb1d938720df45a2720724aae99e3bfc?s=96&r=g\",\"caption\":\"cosimo\"},\"logo\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/image\/\"},\"url\":\"https:\/\/www.streppone.it\/cosimo\/blog\/author\/cosimo\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Capture a webcam image with a simple bash script - Random hacking","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/06\/capture-a-webcam-image-with-a-simple-bash-script\/","og_locale":"en_US","og_type":"article","og_title":"Capture a webcam image with a simple bash script - Random hacking","og_description":"I did that a few months ago to make a poor man&#39;s time-lapse video. This one. I said I&#39;d post how to do it somewhere. Here it is. This is a bash script that will capture an image from a webcam or similar video acquisition device. Works on Linux only I guess. Makes use of [&hellip;]","og_url":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/06\/capture-a-webcam-image-with-a-simple-bash-script\/","og_site_name":"Random hacking","article_published_time":"2011-06-23T11:48:27+00:00","author":"cosimo","twitter_card":"summary_large_image","twitter_misc":{"Written by":"cosimo","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/06\/capture-a-webcam-image-with-a-simple-bash-script\/#article","isPartOf":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/06\/capture-a-webcam-image-with-a-simple-bash-script\/"},"author":{"name":"cosimo","@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1"},"headline":"Capture a webcam image with a simple bash script","datePublished":"2011-06-23T11:48:27+00:00","dateModified":"2011-06-23T11:48:27+00:00","mainEntityOfPage":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/06\/capture-a-webcam-image-with-a-simple-bash-script\/"},"wordCount":108,"commentCount":0,"publisher":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1"},"keywords":["camera","ffmpeg","gst-launch","gstreamer","movie","snapshot","time-lapse","v4l","webcam"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.streppone.it\/cosimo\/blog\/2011\/06\/capture-a-webcam-image-with-a-simple-bash-script\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/06\/capture-a-webcam-image-with-a-simple-bash-script\/","url":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/06\/capture-a-webcam-image-with-a-simple-bash-script\/","name":"Capture a webcam image with a simple bash script - Random hacking","isPartOf":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#website"},"datePublished":"2011-06-23T11:48:27+00:00","dateModified":"2011-06-23T11:48:27+00:00","breadcrumb":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/06\/capture-a-webcam-image-with-a-simple-bash-script\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.streppone.it\/cosimo\/blog\/2011\/06\/capture-a-webcam-image-with-a-simple-bash-script\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/06\/capture-a-webcam-image-with-a-simple-bash-script\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.streppone.it\/cosimo\/blog\/"},{"@type":"ListItem","position":2,"name":"Capture a webcam image with a simple bash script"}]},{"@type":"WebSite","@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#website","url":"https:\/\/www.streppone.it\/cosimo\/blog\/","name":"Random hacking","description":"Assume nothing. Code defensively. Keep it simple, stupid!","publisher":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.streppone.it\/cosimo\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1","name":"cosimo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cb1d938720df45a2720724aae99e3bfc?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cb1d938720df45a2720724aae99e3bfc?s=96&r=g","caption":"cosimo"},"logo":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/image\/"},"url":"https:\/\/www.streppone.it\/cosimo\/blog\/author\/cosimo\/"}]}},"_links":{"self":[{"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/posts\/448"}],"collection":[{"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/comments?post=448"}],"version-history":[{"count":0,"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/posts\/448\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/media?parent=448"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/categories?post=448"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/tags?post=448"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}