{"id":15148688,"url":"https://github.com/cesiumcz/rtsp-timelapse","last_synced_at":"2026-01-20T04:31:48.096Z","repository":{"id":192777123,"uuid":"577316713","full_name":"cesiumcz/rtsp-timelapse","owner":"cesiumcz","description":"Shell script-based routine that takes full-resolution snapshots from IP cam RTSP stream and periodically creates a HEVC timelapse video using FFmpeg.","archived":false,"fork":false,"pushed_at":"2024-02-10T22:51:43.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-04-07T04:31:32.063Z","etag":null,"topics":["ffmpeg","ipcam","openbsd","rtsp","timelapse","webcam"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cesiumcz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-12-12T13:23:31.000Z","updated_at":"2024-12-02T22:48:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"899a07b7-50f0-4575-99db-2cdf5cb72933","html_url":"https://github.com/cesiumcz/rtsp-timelapse","commit_stats":null,"previous_names":["cesiumcz/webcam-timelapse","cesiumcz/ipcam-timelapse","cesiumcz/rtsp-timelapse"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/cesiumcz/rtsp-timelapse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesiumcz%2Frtsp-timelapse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesiumcz%2Frtsp-timelapse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesiumcz%2Frtsp-timelapse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesiumcz%2Frtsp-timelapse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cesiumcz","download_url":"https://codeload.github.com/cesiumcz/rtsp-timelapse/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesiumcz%2Frtsp-timelapse/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28596079,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T02:08:49.799Z","status":"ssl_error","status_checked_at":"2026-01-20T02:08:44.148Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["ffmpeg","ipcam","openbsd","rtsp","timelapse","webcam"],"created_at":"2024-09-26T13:21:44.926Z","updated_at":"2026-01-20T04:31:48.079Z","avatar_url":"https://github.com/cesiumcz.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cesium RTSP timelapse\nShell script-based routine that takes full-resolution snapshots from IP cam RTSP stream and periodically creates a HEVC timelapse video using FFmpeg.\n\n## Prerequisities\n- Shell - `bash` or Korn shell `ksh` (OpenBSD's default shell)\n- `ffmpeg` installed from package system or [built with required flags](#compiling-custom-ffmpeg).\n\n## Installation\n### System user\n\n\tuseradd -c \"Webcam routine\" -b /var/webcam/ -d /var/webcam/ -s /sbin/nologin _webcam\n\tinstall -d -m 770 -o root -g _webcam /var/webcam/\n\n### Clone \u0026 file copy\n\n\tcd /tmp/\n\tgit clone https://github.com/cesiumcz/rtsp-timelapse.git\n\nDetermine correct version `bash`/`ksh`:\n\n\tmv snap.(bash|ksh) snap.sh\n\tmv render.(bash|ksh) render.sh\n\nInstall the scripts and set correct permissions\n\n\tinstall -d -m 755 -o root -g _webcam /usr/local/webcam/\n\tinstall -m 770 -o root -g _webcam conf.sh /usr/local/webcam/\n\tinstall -m 754 -o root -g _webcam snap.sh /usr/local/webcam/\n\tinstall -m 754 -o root -g _webcam render.sh /usr/local/webcam/\n\trm -rf /tmp/rtsp-timelapse/\n\n### Configuration\n#### Paths\nSet your environment-specific paths and ffmpeg parameters in `conf.sh`\n\n\tvim /usr/local/webcam/conf.sh\n\n#### Camera list\n\n\tvim /usr/local/webcam/cameras.txt\n\nFor each webcam, insert a line according to the following syntax:\n\n\tcam_name jpg_quality ffmpeg_crf rtsp_uri\n\n- *cam_name* = unique string camera name. Use short and simple names.\n- *jpg_quality* = JPEG snapshot quality. The normal range for JPEG is 2-31 with 31 being the worst quality. Can be used to optimize storage footprint.  \n  **Once a snapshot is taken, its quality cannot be increased.**\n- *ffmpeg_crf* = Use Constant Rate Factor (CRF) to control the quality of the timelapse video. The default is 28. See [H.265 documentation](https://trac.ffmpeg.org/wiki/Encode/H.265).\n- *rtsp_uri* = RTSP stream URI\n\nA line starting with `#` is ignored.\n\nExample contents of `cameras.txt`\n\n\tentrance 20 28 rtsp://192.168.1.100/user=monitor_password=pdTzQLK6Iq_channel=1_stream=0.sdp\n\tbackyard 25 40 rtsp://192.168.1.101/user=monitor_password=6oLA64UG_channel=1_stream=0.sdp\n\nSet proper permissions (`cameras.txt` is likely to contain credentials)\n\n\tchown -R root:_webcam /usr/local/webcam/\n\tchmod 660 /usr/local/webcam/cameras.txt\n\n### Cron\nGrab a snapshot every hour, and render video once a day. In this manner, one day equals 1 second in the final 24 FPS timelapse video.  \n**NOTICE: Prevent render to execute at the same time as snap and set sufficient delay as follows.**\n\n\tcrontab -e -u _webcam\n\t0 * * * * /usr/local/webcam/snap.sh\n\t5 3 * * * /usr/local/webcam/render.sh\n\n## Changing timelapse video parameters\nSince `render.sh` appends a new video segment at the end of the timelapse without reencoding it completely, any change of output timelapse video parameters (FPS, CRF, Preset) must be followed by a complete reencode.  \n**WARNING: This operation may be very source consumptive and can take a long time.**  \nUsers are discouraged to execute a such operation on a production machine. Use a dedicated machine instead.\n\n\ttar -czf /tmp/webc_backup.tar.gz /var/webcam/cam1/img/\n\nTransfer the archive to dedicated machine and reencode the video\n\n\tffmpeg -pattern_type glob -i \"cam1/img/*.jpg\" -r \u003cFFMPEG_FPS\u003e -c:v libx265 -crf \u003cCRF\u003e -preset \u003cPRESET\u003e -pix_fmt yuv420p cam1/timelapse.hevc\n\n...and place the video back on the server\n\n## Testing\n\n\tsu -l _webcam /usr/local/webcam/snap.sh\n\tsu -l _webcam /usr/local/webcam/render.sh\n\n[Alternatively] using `doas` command:\n\n\tdoas -u _webcam /usr/local/webcam/snap.sh\n\n## Modus operandi\n**`snap.sh`** does the following sequentially for each webcam:\n- takes a JPEG snapshot of specified quality,\n- saves the output image in webcam specific directory with a filename containing the date and time of the snapshot,\n- appends the filename to the list of unprocessed files `unprocessed.txt`\n\n**`render.sh`** does the following sequentially for each webcam:\n- creates a temporary copy of `unprocessed.txt` list of images that are to be encoded and clears the original list,\n- renders a short video to the temporary directory from images in `unprocessed.txt` list,\n- appends the short video at the end of the existing timelapse without reencoding the whole video using ffmpeg's demuxer\n\n*A temporary video is necessary because ffmpeg cannot append images directly to the existing video, it supports video concatenation instead.*\n\n### Directory structure\n\t/var/webcam/\n\t|-- cam1\n\t|   |-- img\n\t|   |   |-- 202402041000.jpg\n\t|   |   `-- 202402041100.jpg\n\t|   |-- timelapse.hevc\n\t|   `-- unprocessed.txt\n\t`-- cam2\n\t    |-- img\n\t    |   |-- 202402041000.jpg\n\t    |   `-- 202402041100.jpg\n\t    |-- timelapse.hevc\n\t    `-- unprocessed.txt\n\n## Compiling custom `ffmpeg`\nBelow is the very minimal build configuration needed to run `rtsp-timelapse` with H.264 and H.265 cameras. It produces ~4.8 MiB executable for amd64 with `gcc`. This may be useful for resource-limited or security-oriented scenarios.  \n\n### Prerequisities\n- [`libx264`](https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu#libx264)\n- [`libx265`](https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu#libx265)\n\nIn case you do not need timelapse video generation, you can omit `--enable-encoder=libx265`, `--enable-demuxer=concat`, `--enable-decoder=mjpeg`, `--enable-muxer=hevc`.  \nFurthermore, you can choose `libx264/h264` / `libx265/h265` according to your IP camera capabilities.\n```\ncd /tmp\ngit clone https://github.com/FFmpeg/FFmpeg.git\ncd FFmpeg\n\n./configure \\\n  --enable-gpl --enable-version3 \\\n  --enable-libopenjpeg --enable-libx264 --enable-libx265 \\\n  --disable-ffplay --disable-ffprobe --disable-doc \\\n  --disable-logging --disable-debug \\\n  --disable-iconv --disable-lzma --disable-zlib \\\n  --disable-swresample --disable-postproc --disable-pixelutils \\\n  --disable-everything \\\n  --enable-encoder=mjpeg --enable-encoder=libx265 \\\n  --enable-decoder=h264 --enable-decoder=hevc --enable-decoder=mjpeg \\\n  --enable-protocol=concat --enable-protocol=file --enable-protocol=tcp --enable-protocol=udp \\\n  --enable-muxer=rtsp --enable-muxer=image2 --enable-muxer=hevc \\\n  --enable-demuxer=rtsp --enable-demuxer=concat --enable-demuxer=image2 \\\n  --enable-filter=scale \\\n  --enable-parser=h264 --enable-parser=hevc\n\nmake -j4\nmake install\n```\n\n## Author\n[Matyáš Vohralík](https://mv.cesium.cz), 2024\n\n## License\n[BSD 3-Clause](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcesiumcz%2Frtsp-timelapse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcesiumcz%2Frtsp-timelapse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcesiumcz%2Frtsp-timelapse/lists"}