Record video stream and save it to consecutive chunks
Project description
CV Stream Recorder
A Python tool to record video streams and save them into consecutive chunks using FFmpeg.
Description
cv-stream-recorder connects to a video stream URL (e.g., HLS .m3u8) and records the content into segmented MP4 files. This is useful for capturing live streams for later processing or analysis.
Features
- Records live video streams.
- Segments output into consecutive files (e.g.,
chunk_000.mp4,chunk_001.mp4). - Stream copy mode (no transcoding) for minimal CPU usage.
- Configurable segment time and total duration.
Requirements
- Python >= 3.11
- FFmpeg installed on your system
ffmpeg-pythonlibrary
Installation
-
Install FFmpeg: Ensure
ffmpegis installed and available in your system's PATH. -
Install the package:
pip install cv-stream-recorder
Usage
Import the module and use it in your code:
import asyncio
import time
from cv_stream_recorder import record_stream, stop_recording
def done(path):
print("Chunk saved to:", path)
async def main():
url = "http://example.com/stream.m3u8"
folder_path = "/path/to/output"
pid = await record_stream(url, folder_path, done, segment_length=60)
print("Recording started with PID:", pid)
# Record for 3 minutes
time.sleep(180)
stop_recording(pid)
if __name__ == "__main__":
asyncio.run(main())
By default, it will:
- Connect to the configured stream URL.
- Start recording.
- Save files as
chunk_000.mp4,chunk_001.mp4, etc., in the target directory. - Stop whenever the
stop_recordingfunction is called.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cv_stream_recorder-0.1.3.tar.gz.
File metadata
- Download URL: cv_stream_recorder-0.1.3.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebe1fea7a6643379c5d14b83a7cede1a80c776872125766810f31ee9ba88586d
|
|
| MD5 |
3446a12227e2bc9ef39d3462154ff70d
|
|
| BLAKE2b-256 |
16abcf5f963e8ab23c2eb40a5b2f15b66d3def8aab0139db973a6888af51653b
|
File details
Details for the file cv_stream_recorder-0.1.3-py3-none-any.whl.
File metadata
- Download URL: cv_stream_recorder-0.1.3-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44f192295f2a0f08dbfaf47c9de2e91d2e45aba26de2770692db6b732d2175bc
|
|
| MD5 |
41e9f79716744ac8bd1683d753b34790
|
|
| BLAKE2b-256 |
5629f4b18dbbd2cc4288e98180959207d11e1dd5dd52d3e185f1ac9ef514c5bd
|