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:

conda install -c anaconda pyaudio
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.

pyrecorder

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:

pyrecorder --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.10.tar.gz (10.7 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.10-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for py_remote_recorder-0.0.10.tar.gz
Algorithm Hash digest
SHA256 23f92c369407767a4befb0a5ce23109d81966705623d15a7efb95b56c14a081a
MD5 241f066e0873827e849d614898b172ef
BLAKE2b-256 7ae333c1beee5d73103d72ab0815d241a1720599e74446760660edfb78acdb9a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for py_remote_recorder-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 feb185e2c8374203d1669ec3382dda5bfb891a32b99775ba2743c1a79a27175f
MD5 2bef5269d0b4665114bee5fc3eaebc0f
BLAKE2b-256 7a810769ec450c39896e1a5c410aea0ea5e308a196f4f7bad7d792ca2c89702d

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