From 70502c3d63e101e7d588f5fdaca88925a1d4275a Mon Sep 17 00:00:00 2001 From: Chris Griffith Date: Sat, 16 Sep 2023 09:35:07 -0500 Subject: [PATCH] Version 1.7.1 (#31) --- .gitignore | 1 - .idea/raspberry_pi_streaming_setup.iml | 8 ---- README.md | 61 ++++++++++++-------------- compile_ffmpeg.py | 24 +++++++++- streaming_setup.py | 37 ++++++++++------ 5 files changed, 76 insertions(+), 55 deletions(-) delete mode 100644 .idea/raspberry_pi_streaming_setup.iml diff --git a/.gitignore b/.gitignore index c8515c6..dc31d8c 100644 --- a/.gitignore +++ b/.gitignore @@ -108,4 +108,3 @@ venv*/ .idea/ config.yaml -*.log diff --git a/.idea/raspberry_pi_streaming_setup.iml b/.idea/raspberry_pi_streaming_setup.iml deleted file mode 100644 index 69c0779..0000000 --- a/.idea/raspberry_pi_streaming_setup.iml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/README.md b/README.md index ba13fef..829c0a3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Raspberry Pi Camera / Webcam streaming helper scripts This script is designed to help automate turing a raspberry pi with a -compatible video4linux2 camera into a MPEG-DASH / HLS streaming server. +compatible video4linux2 camera into a MPEG-DASH / HLS / RTSP streaming server. The steps it will attempt to take: @@ -11,8 +11,6 @@ The steps it will attempt to take: * (DASH/HLS) Create index.html file to view video stream at * Create systemd service and enable it -Note: THERE IS NO NEED TO COMPILE FFMPEG YOURSELF IN MOST CASES. ONLY DO IT IF YOU KNOW YOU NEED AN UNUSUAL ENCODER. - This script requires Python 3.6+ ## Grab the script @@ -50,33 +48,12 @@ If you are connecting to an external RTSP server, pass in the `rtsp-url` argumen sudo python3 streaming_setup.py --rtsp --rtsp-url rtsp://192.168.1.123:8554/raspberrypi ``` -## Compile FFmpeg -If you want to compile FFmpeg you will need to grab the `compile_ffmpeg.py` file. - - -``` -curl -O https://raw.githubusercontent.com/cdgriffith/pi_streaming_setup/master/compile_ffmpeg.py -``` - -I suggest setting the user to `pi` if making in your home directory. - -``` -sudo python3 streaming_setup.py --run-as pi -``` - -If you will be compiling while running over SSH, please use in a background terminal like "tmux" or "screen". - -If you are compilng FFmpeg, be aware, this will build a NON REDISTRIBUTABLE FFmpeg. -You will not be able to share the built binaries under any license. - - ## Streaming Setup Script Options ``` sudo python streaming_setup.py --help usage: 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] - [--index-file INDEX_FILE] [--on-reboot-file ON_REBOOT_FILE] [--systemd-file SYSTEMD_FILE] [--compile-ffmpeg] [--compile-only] [--camera-info] [--minimal] - [--safe] + [--index-file INDEX_FILE] [--on-reboot-file ON_REBOOT_FILE] [--systemd-file SYSTEMD_FILE] [--camera-info] [--minimal] [--safe] streaming_setup version 1.7 @@ -101,17 +78,38 @@ optional arguments: --index-file INDEX_FILE --on-reboot-file ON_REBOOT_FILE --systemd-file SYSTEMD_FILE - --compile-ffmpeg - --compile-only --camera-info Show all detected cameras [/dev/video(0-9)] and exit - --minimal Minimal FFmpeg compile including h264, x264, alsa sound and fonts --safe disable overwrite of existing or old scripts ``` -## License +## Compile FFmpeg +If you want to compile FFmpeg you will need to grab the `compile_ffmpeg.py` file. -MIT License - Copyright (c) 2023 Chris Griffith +> This will take hours on most Raspberry Pi devices! +Note: THERE IS NO NEED TO COMPILE FFMPEG YOURSELF IN MOST CASES. ONLY DO IT IF YOU KNOW YOU NEED AN UNUSUAL ENCODER. + +``` +curl -O https://raw.githubusercontent.com/cdgriffith/pi_streaming_setup/master/compile_ffmpeg.py +``` + +I suggest setting the user to `pi` if making in your home directory. + +``` +sudo python3 compile_ffmpeg.py --run-as pi +``` + +If you will be compiling while running over SSH, please use in a background terminal like "tmux" or "screen". + +Adding `--install` it will install it to `/usr/local/bin/ffmpeg`. You can always do this later yourself by +going into the `FFmpeg` folder and typing `make install` + +If you are compiling FFmpeg, be aware, this will build a NON-REDISTRIBUTABLE FFmpeg. +You will not be able to share the built binaries under any license. + +## License + +MIT License - Copyright (c) 2020-2023 Chris Griffith ## Debuging @@ -119,8 +117,7 @@ MIT License - Copyright (c) 2023 Chris Griffith Go 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)) - -## Changes +## Major Changes ### 1.7 diff --git a/compile_ffmpeg.py b/compile_ffmpeg.py index 3508da6..4101d1b 100644 --- a/compile_ffmpeg.py +++ b/compile_ffmpeg.py @@ -4,6 +4,28 @@ Be aware, this will build a NON-REDISTRIBUTABLE FFmpeg. You will not be able to share the built binaries under any license. + +The MIT License + +Copyright (c) 2020-2023 Chris Griffith + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. """ import logging import os @@ -17,7 +39,7 @@ from argparse import ArgumentParser __author__ = "Chris Griffith" -__version__ = "1.7" +__version__ = "1.7.1" log = logging.getLogger("compile_ffmpeg") command_log = logging.getLogger("compile_ffmpeg.command") diff --git a/streaming_setup.py b/streaming_setup.py index bc29a42..50602bc 100644 --- a/streaming_setup.py +++ b/streaming_setup.py @@ -11,13 +11,35 @@ * Update rc.local to run required setup script on reboot * Create index.html file to view video stream at * Create systemd service and enable it + + +The MIT License + +Copyright (c) 2020-2023 Chris Griffith + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. """ import logging import os import sys import shutil -import pwd import datetime import json from subprocess import run, CalledProcessError, PIPE, STDOUT, Popen @@ -25,7 +47,7 @@ from argparse import ArgumentParser __author__ = "Chris Griffith" -__version__ = "1.7" +__version__ = "1.7.1" log = logging.getLogger("streaming_setup") command_log = logging.getLogger("streaming_setup.command") @@ -84,16 +106,9 @@ def parse_arguments(): parser.add_argument("--index-file", default="/var/lib/streaming/index.html") parser.add_argument("--on-reboot-file", default="/var/lib/streaming/setup_streaming.sh") parser.add_argument("--systemd-file", default="/etc/systemd/system/stream_camera.service") - parser.add_argument("--compile-ffmpeg", action="store_true") - parser.add_argument("--compile-only", action="store_true") parser.add_argument( "--camera-info", action="store_true", help="Show all detected cameras [/dev/video(0-9)] and exit" ) - parser.add_argument( - "--minimal", - action="store_true", - help="Minimal FFmpeg compile including h264, x264, alsa sound and fonts", - ) parser.add_argument("--safe", action="store_true", help="disable overwrite of existing or old scripts") return parser.parse_args() @@ -525,10 +540,6 @@ def main(): install_ffmpeg() - if args.compile_only: - log.info("Compile complete!") - return - if args.rtsp and not args.rtsp_url: rtsp_systemd = Path("/etc/systemd/system/rtsp_server.service") install_rtsp(rtsp_systemd)