HTML

Random musings in IT

Friss topikok

Címkék

21 days (14) addon (3) Alfresco (1) analysis (1) android (6) angel investment (1) angularjs (2) ant (1) architect (2) architecture (2) Atoll (1) awstats (1) axis (1) axis2 (1) beta (1) blog (4) blogging (2) bluetoth keyboard (1) bofh (1) boxee (1) breakfast (1) build (1) cassandra (1) CGI (1) challenge (10) challenge cup (1) chinese (4) chromium (1) CMS (1) compaq contura aero (1) conference (1) consulting (1) continous-integration (2) Dark Data (1) DB2 (5) Debian (1) developer (1) development (1) document outliner (1) driver (1) Eclipse (3) ECM (2) education (1) EJB (1) ejb-client (1) emulator (1) etcd (1) experience (1) facebook (1) female (1) FileNet (1) firefox (2) freeplane (17) freeplaneGTD (17) fun (8) Geronimo (1) getting things done (1) gitlab (1) gnome (1) gtd (15) habit (3) hack (1) hacking (1) hdmi to vga (1) hibernate (1) HR (2) Hungary (1) I18N (1) IBM (1) in (1) Information Lifecycle Governance (1) interview (1) invitel (1) issues (1) It (2) J2ME (1) java (11) javascript (3) java security (1) JAX-WS (1) JBoss (1) JSF (1) kernel (1) Keyboard (1) layout (1) lighttpd (1) Linux (11) LXC (1) macro (1) maven (3) meetup (1) mercury (1) microservice (1) mindweb (5) motorola vip1910-9 (1) movie (1) MQ (1) mw3030r (1) natty (1) nginx (1) node.js (1) nodejs (1) nosql (1) OpenUP (1) Oracle (1) overheat (1) php (1) plugin (1) PrimeFaces (1) project (5) project management (1) RCP (1) recruiter (2) regexp (1) release (11) reporting (1) retrospective (2) rootkit (1) rss (1) RUP (1) script (1) server (1) shared library (1) SharePoint (1) SOA (1) spam (2) spellchecker (1) SQL (1) SSL (1) startup (2) stb (1) story (1) swing (1) SWT (2) tablet (4) tapermonkey (1) tech-beer (1) test (1) thoughts (1) timelapse (1) tomcat (1) toys (1) translate (2) typescript (1) ubuntu (1) ui (1) unified-process (1) University (1) usb (1) VirtualBox (2) virtualization (2) web-service (2) webcam (1) WebSphere (2) wicket (1) widget (1) Windows 8.1 (1) wordpress (3) X11 (1) Címkefelhő

This post is for summarizing the information about the time-lapse movie I mentioned in my earlier posts titled Using a standard web camera to capture a time-lapse on Linux and Compiling UVC driver for Linux with still image support.

As it turns out this topic is one that was actually read by someone out there (based on two feedbacks I received), I decided to publish my findings.

Software required

Software used as the basis

I've tested several set of scripts and going through them, I eventually settled on using a very well written and  almost fully working set of scripts and instructions off the web somewhere. Unfortunately I didn't keep track of my downloads, and there doesn't seem to be much about the author in the files. The original source of the application is available at https://github.com/jaufrec/webcam.

The scripts are very versatile and provided support for:

  • Cron based photo capture using
    • GPhoto2
    • uvccapture
    • jpegpixi
  • Creation and automatic maintenance of thumbnails and static index pages for daily/monthly indexes
  • Creation of daily/monthly strips extracted from the original movie
  • Cron based creation of daily movies in low and high resolution modes, with and option of adding a second stream as picture-in-picture
  • Cron based creation of monthly movies

Modification to the original code

The scripts came almost as I wanted, the only problem with it was that it didn't actually work on my setup. Neither of the capture modes listed above work on my environment, so I made several modifications to the scripts.
  • Added support for avconv/ffmpeg based capture.
  • Added detection of dark frames based on average saturation of the image. (crude and ugly, but easier to set up than checking for the sunrise/sunset times)
  • Removed (most of) the script that created the static pages and modified the web interface to dynamically create the index pages.
  • Modified the monthly movie creation to use a set of frames relative to the sunset time instead of using all the frames. This in my case produces a much smoother video.
  • Created a "forever" script that uses all the available frames and the logic above to create a movie.
  • Added two output formats OGV and MP4 so it can be used on more browsers.
  • The PHP scripts were updated to include both output formats in the HTML5 format.
  • Added running text to show capture time to the frames.
  • Added progress counter to all converting scripts to show progress
The original scripts contained really nice and well designed methods to use parametrized solutions. Unfortunately I had too little time to polish my changes, so some of the parameters are fixed.

Environment

The scripts run on Linux, initially I used Debian Testing distribution, but since I wanted to port the uvc driver's still image patch to a more current kernel I upgraded to Ubuntu Raring. The scripts should be able to work on any distribution, provided it has all the basic Linux tools installed.

I used a simple web camera to capture images, but since I'm trying to make a time-lapse movie of the garden it doesn't produce good enough images.

How to use the software

Getting the software

Either pull it from my github, or get the compressed version here.

Setting up capture

Get a source of images, such as a camera.  WebCam can collect images in any of four ways
  1. The GPhoto2 program. If you are lucky and have a camera that's supported, that's the best source for image capture.
  2. The Capture program.  To install on ubuntu:
    1. apt-get install libusb-dev pkg-config libgtk2.0-dev libreadline-dev
    2. download, compile, and install libptp2 from http://libptp.sourceforge.net:
      1. download and untar the tarball
      2. ./configure
      3. make
      4. make install
      5. ldconfig
    3. download, compile, and install capture from http://capture.sourceforge.net
      1. download and untar
      2. make
      3. make install
  3. Any source that puts new pictures into a directory.  For example http://www.airlink101.com/products/aic250.php
  4. When using a webcam it's easiest to use ffmpeg/avconv to grab image from v4l2 streams. This will use a very low resolution though.

Setting up webserver

Set up a webserver with PHP.  On Ubuntu:
apt-get install lighttpd php5-cgi
lighty-enable-mod fastcgi
service lighttpd force-reload
Copy the php, png, and txt files from the tarball's web directory to the webserver's target directory.
The user that runs the scripts should have permission to write to a directory on the webserver.  The directory structure will be:
/
index.php (provided in the package)
index_day.php (provided in the package)
index_day_video.php (provided in the package)
index_month.php (provided in the package)
title.txt (provided in the package - change it's content to your liking)
basic.css (provided in the package)
webcam/
full.mp4
full.ogv
YYYY/
YYYY-MM.mp4
YYYY-MM.ogv
YYYY-MM_low.mp4
YYYY-MM_low.ogv
YYYY-MM_thumb.jpg
YYYY-MM_thumb_dated.jpg
MM/
YYYY-MM-DD_low.mp4
YYYY-MM-DD_low.ogv
YYYY-MM-DD.mp4
YYYY-MM-DD.ogv
YYYY-MM-DD_strip.jpg
YYYY-MM-DD_thumb_dated.jpg
YYYY-MM-DD_thumb.jpg
YYYY-MM_thumb_dated.jpg
YYYY-MM_thumb.jpg
DD/
HH:MM:SS.jpg
HH:MM:SS_thumb.jpg
All files and directories in this structure are automatically created by the scripts unless otherwise noted.
index.php should be customized by changing "webcam" to whatever directory name you are using.

4) Install avconv and other prerequisites:
On ubuntu,
sudo apt-get install avconv normalize-audio \
libsox-fmt-all lame sox ttf-dejavu-extra

Test your configuration

Whatever capture method you choose make sure, that the user running the cron job has access the capture device and the target folder. The easiest way to ensure that is by running the cron commands before it's installed as a cron job.

Use the command
sudo su - www-data -s /bin/bash
to switch to the user running the web server, and issue your selection of commands to test if the capture can actually take place. If at first you don't succeed (and I'm pretty sure it won't work out of the box) try running the program using the -v (verbose) switch and see what commands are executed and try issuing the commands manually to have them fixed.

After testing with root user always make sure the file permissions and file ownership is set up correctly and the temporary directories from /tmp/tmp.* are removed! This can save lots of time on the long run.

Set up cron jobs

Use the command
sudo su - www-data -c 'crontab -e'
to edit the crontab of the www-data user.

Add the capture.sh script regularly, e.g., every minute between 5 and 21. Use the flags to customize For example, put this in your cron:
* 5-21  *   *   *     /usr/share/webcam/capture.sh -c /bin/capture -q /bin/avconv Add the daily_movie.sh script to run every hour when capture might take place.  For example:
3 6-22  *   *   *     /usr/share/webcam/daily_movie.sh -z 640x480 -o "" -m "your_music_dir" -f 15 -i 1 -1 -2 -3 -q Add the monthly_movie.sh script to run once per day, right after midnight.  For example:
30 2  *   *   *     /opt/webcam/monthly_movie.sh -z640x480 -o "" -m "your_music_dir" -f 10 -i 1 -1 -q Add the full_movie.sh script to run once per day, after the monthly movie is created.  for example:
35 2  *   *   *     /opt/webcam/full_movie.sh -z640x480 -m "your_music_dir" -f 30 -q Make sure your movie generating cron scripts do not contain -v flag, as that will clog up your /tmp directory! Also to receive cron notifications make sure the -q (quiet) flag is added to hide the progress indicator.

Címkék: movie timelapse Linux

Szólj hozzá!

A bejegyzés trackback címe:

https://itworks.blog.hu/api/trackback/id/tr445522371

Kommentek:

A hozzászólások a vonatkozó jogszabályok  értelmében felhasználói tartalomnak minősülnek, értük a szolgáltatás technikai  üzemeltetője semmilyen felelősséget nem vállal, azokat nem ellenőrzi. Kifogás esetén forduljon a blog szerkesztőjéhez. Részletek a  Felhasználási feltételekben és az adatvédelmi tájékoztatóban.

Nincsenek hozzászólások.
süti beállítások módosítása