Introduction
This guide shows you how to use Happytime stream2file to record an RTSP video stream (e.g., from an IP camera) to a local file on your computer.
The recording behavior is controlled by editing the stream2file.cfg configuration file.
Basic Workflow
- Download and install Happytime stream2file.
- Locate the
stream2file.cfgconfiguration file. - Edit the
<stream2file>section with your stream details. - Start the stream2file application.
Configuration Example
Below is a fully configured example of the stream2file.cfg file with explanations.
stream2file.cfg
<stream2file>
<!-- RTSP stream URL (required) -->
<url>rtsp://192.168.3.36/live</url>
<!-- Authentication (if required) -->
<user>admin</user>
<pass>admin</pass>
<!-- Save directory (leave empty for current directory) -->
<savepath></savepath>
<!-- Output file format: AVI or MP4 -->
<filefmt>MP4</filefmt>
<!-- Recording frame rate (0 = auto) -->
<framerate>0</framerate>
<!-- Max recording size in KB (0 = no limit) -->
<recordsize>0</recordsize>
<!-- Max recording time in seconds (0 = no limit) -->
<recordtime>0</recordtime>
<!-- Enable segmented recording (1 = on, 0 = off) -->
<fragment>1</fragment>
<!-- Duration of each segment in milliseconds -->
<fragment_duration>5000</fragment_duration>
</stream2file>
Key Parameters Explained
- Fragmented Recording: Set
<fragment>1</fragment>to split recordings into smaller files (e.g., every 5 seconds withfragment_duration). Ideal for easier management and archiving. - Time-Limited: Use
<recordtime>3600</recordtime>to record for exactly 1 hour. - Size-Limited: Use
<recordsize>1048576</recordsize>to stop recording when the file reaches 1GB. - Authentication: Only include
<user>and<pass>if your RTSP stream requires login.
Recording Scenarios
Continuous Recording:
Timed Recording:
Segmented Recording:
recordtime=0, recordsize=0 → Records until manually stopped.Timed Recording:
recordtime=600 → Records for 10 minutes then switch to new recording.Segmented Recording:
fragment=1, fragment_duration=60000 → Creates a new 1-minute MP4 file every minute.
Best Practices
- Test First: Verify your RTSP URL works in VLC before configuring stream2file.
- Disk Space: Ensure sufficient free space, especially for continuous recording.
- File Format: Choose MP4 for better compatibility and smaller size, AVI for maximum compatibility with older systems.
- Fragmentation: Use segmented recording for long-term surveillance to avoid huge single files.
- Security: Store configuration files with passwords securely.