Skip to main content

No project description provided

Project description

PyRemoteRecorder

Image description

py_remote_recorder is a Python package designed for remote screen and audio recording via API calls. It provides functionalities to start and stop screen and audio recordings on a specific monitor or input device, along with saving the recordings locally as video or audio files. This package is ideal for remote monitoring, screen capturing, and voice recording applications, with support for FastAPI-based backends and integration with frontend applications via API calls.

Features

  • Screen Recording: Record any screen or monitor by specifying the screen index. Capture high-quality screen recordings in .avi format.
  • Audio Recording: Record audio from the system's default input device (microphone) and save it as .wav files.
  • API-based Control: Start and stop both screen and audio recordings through API calls, enabling remote control via HTTP requests.
  • Ngrok Support: Expose the local FastAPI server to the internet using Ngrok, facilitating easy remote access for external clients.
  • Multi-monitor Support: Supports systems with multiple monitors, allowing selection of the desired screen for recording.
  • Customizable Frame Rates: Define the frame rate (fps) for screen recording, with default settings optimized for general use.
  • Data Streaming: Stream the recorded video or audio data directly via the API.

Installation

You can install the py_remote_recorder package via pip:

pip install py_remote_recorder

Alternatively, you can install it directly from the source:

git clone https://github.com/your-repo/py_remote_recorder.git
cd py_remote_recorder
pip install poetry 
poetry install

Usage

Basic Setup

First, you'll need to set up and run the FastAPI server provided by the package. The server exposes API endpoints for starting and stopping screen/audio recordings.

python -m py_remote_recorder

You can start the server with optional arguments:

  • --port: Specify the port to run the FastAPI server (default is 8000).
  • --use-ngrok: Use this flag to expose the server via Ngrok for remote access.

API Endpoints

Start Screen Recording

Start recording a specific screen by specifying the screen index.

Endpoint: POST /start-screen-recording/

Request:

{
  "screen_index": 1
}
  • screen_index: Index of the screen to record (1-based index).

Response:

{
  "status": "Recording started",
  "screen_index": 1,
  "output_file": "output_screen_1.avi"
}

Stop Screen Recording

Stop the ongoing screen recording and download the recorded video.

Endpoint: POST /stop-screen-recording/

Response: Binary video data in .avi format.

Start Audio Recording

Start recording audio from the system's default microphone.

Endpoint: POST /start-audio-recording/

Response:

{
  "status": "Audio recording started",
  "output_file": "output_audio.wav"
}

Stop Audio Recording

Stop the ongoing audio recording and download the recorded audio.

Endpoint: POST /stop-audio-recording/

Response: Binary audio data in .wav format.

Example Python Client

Here's a simple Python script to interact with the py_remote_recorder API:

  1. Video part
from py_remote_recorder.backend.call_apis import (
    save_binary_file,
    start_video_recording,
    stop_video_recording,
)

import time
current_end_point = "yout_end_point"

# Start the recording on screen 1
start_video_recording(end_point=current_end_point, screen_index=1)

time.sleep(3)

# Stop the recording and save the file as output.avi
data = stop_video_recording(end_point=current_end_point)

save_binary_file(data, output_file="local_file.avi")
  1. Audio part
import time

from py_remote_recorder.backend.call_apis import (
    save_binary_file,
    start_audio_recording,
    stop_audio_recording,
)

current_end_point = "https://3891-93-62-248-214.ngrok-free.app"

# Start the audio recording
start_audio_recording(end_point=current_end_point)

time.sleep(10)

# Stop the recording and save the file as output.wav
audio_data = stop_audio_recording(end_point=current_end_point)

if audio_data:
    save_binary_file(audio_data, output_file="local_audio_file.wav")

Ngrok Integration

  1. Download Ngrok from the official website: https://ngrok.com/download

  2. Extract the downloaded file to a folder where you have write permissions (e.g., C:\ngrok on Windows).

  3. If you want to access the API remotely, you can use the --use-ngrok flag to expose the local FastAPI server. For example:

python -m py_remote_recorder --use-ngrok --port 8000

The public Ngrok URL will be logged in the terminal, allowing you to interact with the API remotely.

Development

Running Tests

To run the unit tests, use the following command:

pytest

Tests are located in the tests directory and cover both audio and video recording functionalities.

Code Quality

The code adheres to PEP8 and Pylint guidelines. Before submitting a pull request, ensure that the code passes Pylint checks:

pylint py_remote_recorder

Contributions

Contributions are welcome! Please open an issue or submit a pull request if you'd like to contribute to the project.

Limitations

  • Platform-specific: The package is tested on Windows and Linux platforms. MacOS support may be limited.
  • Hardware Dependencies: The quality of screen and audio recording may vary based on the system's hardware capabilities.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Contact

For any inquiries or issues, please contact the maintainer via email or open an issue on GitHub.

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

py_remote_recorder-0.0.3.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

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

py_remote_recorder-0.0.3-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file py_remote_recorder-0.0.3.tar.gz.

File metadata

  • Download URL: py_remote_recorder-0.0.3.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.14 Linux/6.5.0-1025-azure

File hashes

Hashes for py_remote_recorder-0.0.3.tar.gz
Algorithm Hash digest
SHA256 95c014eae0e8adedc96ab6e42f8634af444687e34f9998e5a8a19e54ef67e6a2
MD5 4587e60b6b561fadffd423f643652ec3
BLAKE2b-256 049f211f5a434b5e677403e41fd359b14bece4f57e3e7079e37b70991c20d0fe

See more details on using hashes here.

File details

Details for the file py_remote_recorder-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: py_remote_recorder-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.14 Linux/6.5.0-1025-azure

File hashes

Hashes for py_remote_recorder-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fda00b73cadda22110bd44b372f4bc3914c5802db77540141c84c5fe6d0d1cb5
MD5 871bf25e01171f50dad73f4fa217cf10
BLAKE2b-256 4fdfb0e8969a9c6b392519c55b8c2e69e309b6ce5cd0625ac25c2b262bf1bbfb

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