Skip to main content

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-python library

Installation

  1. Install FFmpeg: Ensure ffmpeg is installed and available in your system's PATH.

  2. 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:

  1. Connect to the configured stream URL.
  2. Start recording.
  3. Save files as chunk_000.mp4, chunk_001.mp4, etc., in the target directory.
  4. Stop whenever the stop_recording function is called.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cv_stream_recorder-0.1.3.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cv_stream_recorder-0.1.3-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

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

Hashes for cv_stream_recorder-0.1.3.tar.gz
Algorithm Hash digest
SHA256 ebe1fea7a6643379c5d14b83a7cede1a80c776872125766810f31ee9ba88586d
MD5 3446a12227e2bc9ef39d3462154ff70d
BLAKE2b-256 16abcf5f963e8ab23c2eb40a5b2f15b66d3def8aab0139db973a6888af51653b

See more details on using hashes here.

File details

Details for the file cv_stream_recorder-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for cv_stream_recorder-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 44f192295f2a0f08dbfaf47c9de2e91d2e45aba26de2770692db6b732d2175bc
MD5 41e9f79716744ac8bd1683d753b34790
BLAKE2b-256 5629f4b18dbbd2cc4288e98180959207d11e1dd5dd52d3e185f1ac9ef514c5bd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page