{"id":16790283,"url":"https://github.com/cdgriffith/pi_streaming_setup","last_synced_at":"2025-08-17T01:10:21.092Z","repository":{"id":55925700,"uuid":"274953952","full_name":"cdgriffith/pi_streaming_setup","owner":"cdgriffith","description":"Raspberry Pi camera / webcam streaming setup","archived":false,"fork":false,"pushed_at":"2023-10-25T14:06:40.000Z","size":28,"stargazers_count":66,"open_issues_count":2,"forks_count":12,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-01-11T20:11:57.674Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/cdgriffith.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,"publiccode":null,"codemeta":null}},"created_at":"2020-06-25T15:40:05.000Z","updated_at":"2025-01-05T22:59:48.000Z","dependencies_parsed_at":"2024-10-27T12:11:29.912Z","dependency_job_id":null,"html_url":"https://github.com/cdgriffith/pi_streaming_setup","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdgriffith%2Fpi_streaming_setup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdgriffith%2Fpi_streaming_setup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdgriffith%2Fpi_streaming_setup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdgriffith%2Fpi_streaming_setup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cdgriffith","download_url":"https://codeload.github.com/cdgriffith/pi_streaming_setup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235208997,"owners_count":18953003,"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":[],"created_at":"2024-10-13T08:29:23.472Z","updated_at":"2025-08-17T01:10:21.075Z","avatar_url":"https://github.com/cdgriffith.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Raspberry Pi Camera / Webcam streaming helper scripts\n\nThis script is designed to help automate turing a raspberry pi with a\ncompatible video4linux2 camera into a MPEG-DASH / HLS / RTSP streaming server.\n\nThe steps it will attempt to take:\n\n* Install FFmpeg\n* Install nginx for DASH / HLS OR install RTSP server if desired\n* (DASH/HLS) Update rc.local to run required setup script on reboot\n* (DASH/HLS) Create index.html file to view video stream at\n* Create systemd service and enable it\n\nThis script requires Python 3.6+\n\n## Grab the script\n\n```\ncurl -O https://raw.githubusercontent.com/cdgriffith/pi_streaming_setup/master/streaming_setup.py\n```\n\nYou could also clone the repo, or use wget, or whatever you desire. You just need the `streaming_setup.py` file.\n\n\n## MPEG DASH / HLS\n\nDASH is a great way to use your device as standalone streaming server with a easy to view webpage hosted on the Pi.\nThe disadvantage is the delay due to buffering and the way DASH / HLS work with manifest files. You will have a 5~20\nsecond lag from the camera to when you view it.\n\nTo use the pre-built FFmpeg and MPEG DASH, just need to run the script as root / sudo then you're good to go:\n\n```\nsudo python3 streaming_setup.py\n```\n\n## RTSP\n\nIf you want near instant real time streaming, it's best to use the aptly named Real Time Streaming Protocol, RTSP.\n\n```\nsudo python3 streaming_setup.py --rtsp\n```\n\nIf you are connecting to an external RTSP server, pass in the `rtsp-url` argument.\n\n```\nsudo python3 streaming_setup.py --rtsp --rtsp-url rtsp://192.168.1.123:8554/raspberrypi\n```\n\n## Streaming Setup Script Options\n\n```\nsudo python streaming_setup.py --help\nusage: streaming_setup [-h] [-v] [--ffmpeg-command] [-d DEVICE] [-s VIDEO_SIZE] [-r] [--rtsp-url RTSP_URL] [-f INPUT_FORMAT] [-b BITRATE] [-c CODEC] [--ffmpeg-params FFMPEG_PARAMS]\n                       [--index-file INDEX_FILE] [--on-reboot-file ON_REBOOT_FILE] [--systemd-file SYSTEMD_FILE] [--camera-info] [--minimal] [--safe]\n\nstreaming_setup version 1.8\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -v, --version\n  --ffmpeg-command      print the automated FFmpeg command and exit\n  -d DEVICE, -i DEVICE, --device DEVICE\n                        Camera. Selected: /dev/video0\n  -s VIDEO_SIZE, --video-size VIDEO_SIZE\n                        The video resolution from the camera (using 1280x720)\n  -r, --rtsp            Use RTSP instead of DASH / HLS\n  --rtsp-url RTSP_URL   Provide a remote RTSP url to connect to and don't set up a local server\n  -f INPUT_FORMAT, --input-format INPUT_FORMAT\n                        The format the camera supports (using mjpeg)\n  -b BITRATE, --bitrate BITRATE\n                        Streaming bitrate, is auto calculated by default. (Will be ignored if the codec is 'copy')\n  -c CODEC, --codec CODEC\n                        Conversion codec (using 'h264_v4l2m2m')\n  --ffmpeg-params FFMPEG_PARAMS\n                        specify additional FFmpeg params, MUST be doubled quoted! helpful if not copying codec e.g.: '\"-b:v 4M -maxrate 4M -g 30 -num_capture_buffers 128\"'\n  --index-file INDEX_FILE\n  --on-reboot-file ON_REBOOT_FILE\n  --systemd-file SYSTEMD_FILE\n  --camera-info         Show all detected cameras [/dev/video(0-9)] and exit\n  --safe                disable overwrite of existing or old scripts\n```\n\n## Compile FFmpeg\nIf you want to compile FFmpeg you will need to grab the `compile_ffmpeg.py` file.\n\n\u003e This will take hours on most Raspberry Pi devices!\n\nNote: THERE IS NO NEED TO COMPILE FFMPEG YOURSELF IN MOST CASES. ONLY DO IT IF YOU KNOW YOU NEED AN UNUSUAL ENCODER.\n\n```\ncurl -O https://raw.githubusercontent.com/cdgriffith/pi_streaming_setup/master/compile_ffmpeg.py\n```\n\nI suggest setting the user to `pi` if making in your home directory.\n\n```\nsudo python3 compile_ffmpeg.py --run-as pi\n```\n\nIf you will be compiling while running over SSH, please use in a background terminal like \"tmux\" or \"screen\".\n\nAdding `--install` it will install it to `/usr/local/bin/ffmpeg`. You can always do this later yourself by\ngoing into the `FFmpeg` folder and typing `make install`\n\nIf you are compiling FFmpeg, be aware, this will build a NON-REDISTRIBUTABLE FFmpeg.\nYou will not be able to share the built binaries under any license.\n\n## License\n\nMIT License - Copyright (c) 2020-2025 Chris Griffith\n\n## Debuging\n\n### Error: ioctl(VIDIOC_STREAMON) failure : 1, Operation not permitted\n\nGo into raspi-config and up the video memory (memory split) to 256 and reboot. (thanks to #15 [rezrov](https://github.com/cdgriffith/pi_streaming_setup/issues/15))\n\n## Major Changes\n\n### 1.8\n\n* Adding check for existing ffmpeg ahead of time (thanks to Noah Abu-Hajar)\n* Fix download for mediamtx (thanks to Christopher Brown)\n\n### 1.7\n\n* Adding support for 64-bit OSes (aarch64)\n* Changing default codec to h264_v4l2m2m (removing h264_omx)\n* Splitting out compile_ffmpeg.py into its own file\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdgriffith%2Fpi_streaming_setup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcdgriffith%2Fpi_streaming_setup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdgriffith%2Fpi_streaming_setup/lists"}