Skip to main content

Screen Recorder Gradio Custom Component

Project description


tags: [custom-component-track, gradio-custom-component, screen-recorder, PIP, picture-in-picture] title: gradio_screenrecorder short_description: Screen Recorder with Picture in Picture Gradio Custom Component colorFrom: blue colorTo: yellow sdk: gradio pinned: false app_file: space.py

gradio_screenrecorder

Static Badge

Screen Recorder Gradio Custom Component

Installation

pip install gradio_screenrecorder

Usage

import gradio as gr
from gradio_screenrecorder import ScreenRecorder

def handle_recording(recording_data):
    """Handle recorded video data"""
    print(f'Received recording data: {recording_data}')
    
    if not recording_data or not recording_data.get('video'):
        return None
    
    try:
        video_info = recording_data['video']
        # Return the video path that can be used by the Video component
        return video_info.get('path')
    except Exception as e:
        print(f'Error processing recording: {e}')
        return None


css = """
.screen-recorder-demo {
    max-width: 800px;
    margin: 0 auto;
}
"""

with gr.Blocks(css=css, title="Screen Recorder Demo") as demo:
    gr.HTML("""
    <h1 style='text-align: center'>
        Gradio Screen Recorder Component Demo
    </h1>
    """)
    
    with gr.Row():
        with gr.Column():
            recorder = ScreenRecorder(
                audio_enabled=True,
                webcam_overlay=True,  # Disabled for now
                webcam_position="top-left",
                recording_format="webm",
                max_duration=60,
                label="Screen Recorder"
            )
        
        with gr.Column():
            output_video = gr.Video(label="Recorded Video")
    
    # Event handler
    recorder.change(
        fn=handle_recording,
        inputs=recorder,
        outputs=output_video
    )

if __name__ == "__main__":
    demo.launch()

ScreenRecorder

Initialization

name type default description
audio_enabled
bool
True None
webcam_overlay
bool
False None
webcam_position
"top-left" | "top-right" | "bottom-left" | "bottom-right"
"bottom-right" None
recording_format
str
"webm" None
max_duration
typing.Optional[int][int, None]
None None
interactive
bool
True None

Events

name description
record_start
record_stop
stream_update
change

User function

The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).

  • When used as an Input, the component only impacts the input signature of the user function.
  • When used as an output, the component only impacts the return signature of the user function.

The code snippet below is accurate in cases where the component is used as both an input and an output.

def predict(
    value: typing.Optional[
   gradio_screenrecorder.screenrecorder.ScreenRecorderData
][ScreenRecorderData, None]
) -> Unknown:
    return value

ScreenRecorderData

class ScreenRecorderData(GradioModel):
    video: Optional[FileData] = None
    duration: Optional[float] = None
    audio_enabled: bool = True
    status: Literal["recording", "stopped", "error"] = (
        "stopped"
    )

    class Config:
        json_encoders = {
            FileData: lambda v: v.model_dump()
            if v
            else None
        }

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

gradio_screenrecorder-0.0.1.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

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

gradio_screenrecorder-0.0.1-py3-none-any.whl (1.1 MB view details)

Uploaded Python 3

File details

Details for the file gradio_screenrecorder-0.0.1.tar.gz.

File metadata

  • Download URL: gradio_screenrecorder-0.0.1.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for gradio_screenrecorder-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f20b7a232c159bd687a67f31a66e49019bd631218d048cf62f3c742fc1750f7e
MD5 2387a0bd77eda5d5c6c47e5cb69997fa
BLAKE2b-256 614d9e93e3fb0d75b2399935af15cb78b22d2186b6b598185b98a5646b0737b4

See more details on using hashes here.

File details

Details for the file gradio_screenrecorder-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for gradio_screenrecorder-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7f1a68f37c585d250b97e10527aa7ad243edb98691be598c57ff2bb637af76b6
MD5 e89a065caa849ee9fdef2d1081741205
BLAKE2b-256 7e5edeab3e64b2b7a3df8537942d52fb29440e565ca3cd1353e7f71b8f4f6d64

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