{"id":16060840,"url":"https://github.com/geerlingguy/pi-timelapse","last_synced_at":"2025-04-08T03:09:47.432Z","repository":{"id":52168403,"uuid":"84152673","full_name":"geerlingguy/pi-timelapse","owner":"geerlingguy","description":"Time-lapse app for Raspberry Pi computers.","archived":false,"fork":false,"pushed_at":"2021-05-06T15:42:26.000Z","size":35,"stargazers_count":305,"open_issues_count":15,"forks_count":58,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-03-31T17:18:46.940Z","etag":null,"topics":["gif","gifs","photography","raspberry-pi","raspbian","time-lapse","timelapse","video"],"latest_commit_sha":null,"homepage":"https://www.jeffgeerling.com/pi-timelapse","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geerlingguy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"geerlingguy","patreon":"geerlingguy"}},"created_at":"2017-03-07T03:58:11.000Z","updated_at":"2025-02-19T02:30:50.000Z","dependencies_parsed_at":"2022-09-09T12:12:07.606Z","dependency_job_id":null,"html_url":"https://github.com/geerlingguy/pi-timelapse","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geerlingguy%2Fpi-timelapse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geerlingguy%2Fpi-timelapse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geerlingguy%2Fpi-timelapse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geerlingguy%2Fpi-timelapse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geerlingguy","download_url":"https://codeload.github.com/geerlingguy/pi-timelapse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247767234,"owners_count":20992547,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gif","gifs","photography","raspberry-pi","raspbian","time-lapse","timelapse","video"],"created_at":"2024-10-09T04:06:44.868Z","updated_at":"2025-04-08T03:09:47.399Z","avatar_url":"https://github.com/geerlingguy.png","language":"Python","funding_links":["https://github.com/sponsors/geerlingguy","https://patreon.com/geerlingguy"],"categories":[],"sub_categories":[],"readme":"# Raspberry Pi Time-Lapse App\n\n[![Build Status](https://travis-ci.org/geerlingguy/pi-timelapse.svg?branch=master)](https://travis-ci.org/geerlingguy/pi-timelapse)\n\nThere are a ton of different Time-Lapse scripts and apps built for the Raspberry Pi, but I wanted to make a more customized setup for my own needs.\n\nHere's an example time-lapse video I recorded of cirrus clouds in the sky outside my window (click to view on YouTube):\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://www.youtube.com/watch?v=mThXDhkj0aA\"\u003e\u003cimg src=\"https://img.youtube.com/vi/mThXDhkj0aA/0.jpg\" alt=\"Cirrus clouds on a sunny day - Raspberry Pi Zero W time-lapse by Jeff Geerling\" /\u003e\u003c/a\u003e\u003c/p\u003e\n\nThere are many other examples in my \u003ca href=\"https://www.youtube.com/playlist?list=PL2_OBreMn7Fpviykd5nnuEjrymmF8fDc7\"\u003eTimelapses\u003c/a\u003e playlist on YouTube.\n\n## Usage\n\n\u003e For an in-depth overview, see my blog post [Raspberry Pi Zero W as a headless time-lapse camera](https://www.jeffgeerling.com/blog/2017/raspberry-pi-zero-w-headless-time-lapse-camera).\n\nFirst, make sure the camera interface is enabled—if you don't, you'll see the message `Camera is not enabled. Try running 'sudo raspi-config'`:\n\n  1. Run `sudo raspi-config`\n  2. Go to 'Interfacing Options'\n  3. Select 'Camera'\n  4. Select 'Yes' for enabling the camera\n  5. Select 'Finish' in the main menu and then 'Yes' to reboot the Pi\n\nNow, set up this timelapse app on your Raspberry Pi:\n\n  2. Install dependencies: `sudo apt-get install -y git python-picamera python-yaml`\n  3. Clone this repository to your Pi: `git clone https://github.com/geerlingguy/pi-timelapse.git`\n  4. Copy `example.config.yml` to `config.yml`.\n  5. Configure the timelapse by modifying values in `config.yml`.\n  6. In the Terminal, `cd` into this project directory and run `python timelapse.py`.\n\nAfter the capture is completed, the images will be stored in a directory named `series-[current date]`.\n\n## Run on Raspberry Pi Startup and manage timelapses via Systemd\n\nThis project includes a Systemd unit file that allows the timelapse script to be managed like any other service on the system (e.g. start with `systemctl start timelapse`, stop with `systemctl stop timelapse`).\n\nTo use this feature, do the following:\n\n  1. In your `config.yml`, set the `total_images` variable to a large number—as large as you want, within Python's limitations. This way you won't start a timelapse and it stops after very few images are taken.\n  1. Copy the `timelapse.service` file into the Systemd unit file location: `sudo cp timelapse.service /etc/systemd/system/timelapse.service`.\n  1. Reload the Systemd daemon (`sudo systemctl daemon-reload`) to load in the new unit file.\n  1. Choose how you want to manage the `timelapse` service:\n     1. **To start a timelapse at system boot**: `sudo systemctl enable timelapse` (`disable` to turn off, `is-enabled` to check current status)\n     1. **To start a timelapse at any time**: `sudo systemctl start timelapse` (if one is not already running)\n     1. **To stop a timelapse in progress**: `sudo systemctl stop timelapse`\n\nNote: You should not try running a timelapse via the Python script directly _and_ via Systemd at the same time. This could do weird things, and is not a typical mode of operation!\n\n## Creating animated gifs or videos\n\n### Animated gifs\n\nRequirements: You should install [ImageMagick](https://www.imagemagick.org/script/index.php) (`sudo apt-get -y install imagemagick`)\n\nIf you have `create_gif` set to `True` in `config.yml`, the Pi will also generate an animated gif immediately following the conclusion of the capture.\n\n\u003e Note: Animated gif generation can take a very long time on slower Pis, like the Pi Zero, A+, or original A or B.\n\n### Videos\n\nRequirements: You should install [FFmpeg](https://ffmpeg.org) (which is actually `avconv` on Raspbian — `sudo apt-get -y install libav-tools`)\n\nIf you have `create_video` set to `True` in `config.yml`, the Pi will also generate a video immediately following the conclusion of the capture.\n\n\u003e Note: Video generation can take a very long time on slower Pis, like the Pi Zero, A+, or original A or B.\n\n### Manually Compiling Videos with `ffmpeg`\n\nYou can use `ffmpeg` on other platforms (or `avconv` on the Pi) to put together image sequences after the fact. For example, to take a sequence like `image00001.jpg` to `image00248.jpg` and generate an MP4 video:\n\n    ffmpeg -framerate 20 -i image%05d.jpg -vf format=yuv420p timelapse.mp4\n\nAnd if you wanted to start the video in the middle of the sequence (e.g. instead of starting at `image00001.jpg`, start at `image00024.jpg`), you can pass the `-start_number` option:\n\n    ffmpeg -framerate 20 -start_number 634 -i image%05d.jpg -vf format=yuv420p timelapse.mp4\n\nThese commands assume you're inside the folder containing all the images, and output a file named `timelapse.mp4` in the same directory.\n\n## Manual Settings\n\nFor a more pleasing timelapse, it's best to lock in manual settings for exposure and white balance (otherwise the video has a lot of inconsistency from frame to frame). This project allows almost complete control over manual exposure settings through variables in `config.yml`, and below are listed some rules of thumb for your own settings.\n\n\u003e Read more about the [Raspberry Pi's Camera hardware](https://picamera.readthedocs.io/en/latest/fov.html).\n\n### Resolution\n\nThe most common and useful Pi Camera resolutions (assuming a V2 camera module—V1 modules have different optimal resolutions) are listed below:\n\n| Size (width x height) | Aspect | Common name            |\n| --------------------- | ------ | ---------------------- |\n| 3280 x 2464           | 4:3    | (max resolution)       |\n| 1920 x 1080           | 16:9   | 1080p                  |\n| 1280 x 720            | 16:9   | 720p (2x2 binning)     |\n| 640 x 480             | 4:3    | 480p (2x2 binning)     |\n\nBinning allows the Pi to sample a grid of four pixels and downsample the average values to one pixel. This makes for a slightly more color-accurate and sharp picture at a lower resolution than if the Pi were to skip pixels when generating the image.\n\n### ISO\n\nISO is basically an indication of 'light sensitivity'. Without getting too deep in the weeds, you should use lower ISO values (`60` (V2 camera only), `100`, `200`) in bright situations, and higher ISO values (`400`, `800`) in dark situations. There's a lot more to it than that, and as you find out creative ways to use shutter speed and ISO together, those rules go out the window, but for starters, you can choose the following manual values to lock in a particular ISO on the Pi Camera:\n\n  - `60` (not available on V1 camera module)\n  - `100`\n  - `200`\n  - `400`\n  - `800`\n\n### Shutter Speed\n\nMost photographers are familiar with the fractional values for common shutter speeds (1s, 1/10s, 1/30s, 1/60s, etc.), so here's a table to help convert some of the most common shutter speeds into microseconds (the value used in `config.yml`):\n\n| Fractional Shutter Speed | µs       |\n| ------------------------ | -------- |\n| 6 seconds (max)          | 6000000  |\n| 1 second                 | 1000000  |\n| 1/8                      | 125000   |\n| 1/15                     | 66666    |\n| 1/30                     | 33333    |\n| 1/60                     | 16666    |\n| 1/125                    | 8000     |\n| 1/250                    | 4000     |\n| 1/500                    | 2000     |\n| 1/500                    | 2000     |\n| 1/1000                   | 1000     |\n| 1/2000                   | 500      |\n\n### White Balance\n\nWhite balance values on the Raspberry Pi camera are set by adjusting the red and blue gain values—the green value is constant. You need to amplify red and blue certain amounts to set a specific color temperature, and here are some of the settings that worked in specific situations for _my_ camera. Note that you might need to adjust/eyeball things a little better for your own camera, as some unit-to-unit variance is to be expected on such an inexpensive little camera!\n\n| White Balance Setting | Color Temperature (approx) | red_gain | blue_gain |\n| --------------------- | -------------------------- | -------- | --------- |\n| Clear blue sky        | 8000K+                     | 1.5      | 1.5       |\n| Cloudy sky / overcast | 6500K                      | 1.5      | 1.2       |\n| Daylight              | 5500K                      | 1.5      | 1.45      |\n| Fluorescent / 'cool'  | 4000K                      | 1.3      | 1.75      |\n| Incandescent / 'warm' | 2700K                      | 1.25     | 1.9       |\n| Candle                | \u003c2000K                     | TODO     | TODO      |\n\nNote: These values will be updated over time as I find more time to calibrate my Pi camera against a few DSLRs and other devices which are much more accurate! Please file an issue if you can help make these mappings better, or find a nicer way to adjust calibrations rather than a `red_gain` and `blue_gain` value.\n\n### Rotation\n\nDepending on the placement of your camera, the picture taken could be upside down. To correct this, set `rotation` to a value of `0` (no rotation), or `90`, `180` or `270` degrees to rotate the image.\n\n## License\n\nMIT License.\n\n## Author\n\nThis project is maintained by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeerlingguy%2Fpi-timelapse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeerlingguy%2Fpi-timelapse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeerlingguy%2Fpi-timelapse/lists"}