This page describes how to use the attached scripts to record Real Time Streaming Protocol (RTSP) streams.


Bash Script

To record RTSP streams on Linux or macOS machines, run the attached record_segments.sh script as shown below:

Usage:
record_segments.sh -i "RTSP_URL" "TITLE" SEGMENT_DURATION FOLDER FILENAME
Example:
record_segments.sh -i "rtsp://user:pwd@10.1.1.1/axis-media/media.amp" "My title" 300 recordings video


  • RTSPURL should be fully formatted URL for playback of the live stream.
  • TITLE is added as metadata inside the file. (Media players will show this.)
  • FOLDER and FILENAME are where the recordings are stored. FILENAME will be appended with 001.mp4, 002.mp4, etc.


Windows Batch Script

To record RTSP streams on Windows machines, you must first set up ffmpeg on your machine:


  1. Install FFMPEG and unzip it to C:\Program Files\ffmpeg\bin. 
  2. Create a PATH entry.
    1. Open the Windows menu and type "Path".
    2. Click "Edit System Environment path".
    3. Click "Edit variables".
    4. Add a new entry to "Path" under "User variables". (e.g. "C:\Program Files\ffmpeg\bin")


You can now record RTSP streams by running the attached record_segments.bat script as shown below:


Usage:
record_segments.bat -i "RTSP_URL" "TITLE" SEGMENT_DURATION FOLDER FILENAME
Example:
record_segments.bat -i "rtsp://user:pwd@10.1.1.1/axis-media/media.amp" "My title" 300 recordings video


  • RTSPURL should be fully formatted URL for playback of the live stream.
  • TITLE is added as metadata inside the file. (Media players will show this.)
  • FOLDER and FILENAME are where the recordings are stored. FILENAME will be appended with 001.mp4, 002.mp4, etc.
  • Make sure to use double quotes. (Single quotes don't work.)