Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screen recording #10832

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Screen recording #10832

wants to merge 13 commits into from

Conversation

dawoodkhan82
Copy link
Collaborator

@dawoodkhan82 dawoodkhan82 commented Mar 18, 2025

Description

Adds a screen recording feature. Record button is in footer.

Edits the video to trim the prediction time.

Closes: #(issue)

🎯 PRs Should Target Issues

Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.

Not adhering to this guideline will result in the PR being closed.

Testing and Formatting Your Code

  1. PRs will only be merged if tests pass on CI. We recommend at least running the backend tests locally, please set up your Gradio environment locally and run the backed tests: bash scripts/run_backend_tests.sh

  2. Please run these bash scripts to automatically format your code: bash scripts/format_backend.sh, and (if you made any changes to non-Python files) bash scripts/format_frontend.sh

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Mar 18, 2025

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
Storybook ready! Storybook preview
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://gradio-pypi-previews.s3.amazonaws.com/a342fe6cc3dc2fbcce9993c2893c23c0721274a9/gradio-5.22.0-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@a342fe6cc3dc2fbcce9993c2893c23c0721274a9#subdirectory=client/python"

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/a342fe6cc3dc2fbcce9993c2893c23c0721274a9/gradio-client-1.13.1.tgz

Use Lite from this PR

<script type="module" src="https://gradio-lite-previews.s3.amazonaws.com/a342fe6cc3dc2fbcce9993c2893c23c0721274a9/dist/lite.js""></script>

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Mar 18, 2025

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/core minor
gradio minor
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Screen recording

Maintainers or the PR author can modify the PR title to modify this entry.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@dawoodkhan82 dawoodkhan82 marked this pull request as ready for review March 22, 2025 01:01
@dawoodkhan82 dawoodkhan82 changed the title [Draft] Screen recording Screen recording Mar 22, 2025
@yvrjsharma
Copy link
Collaborator

Hi @dawoodkhan82! It works wonderfully for me with this first app, but I found it didn't work quite as well with the second app:

import gradio as gr
def greet(name, intensity):
    return "Hello, " + name + "!" * int(intensity)
demo = gr.Interface(
    fn=greet,
    inputs=["text", "slider"],
    outputs=["text"],
)
demo.launch()
import gradio as gr
python_code = """
def fib(n):
    if n <= 0:
        return 0
    elif n == 1:
        return 1
    else:
        return fib(n-1) + fib(n-2)
"""
js_code = """
function fib(n) {
    if (n <= 0) return 0;
    if (n === 1) return 1;
    return fib(n - 1) + fib(n - 2);
}
"""

def chat(message, history):
    if "python" in message.lower():
        return "Type Python or JavaScript to see the code.", gr.Code(language="python", value=python_code)
    elif "javascript" in message.lower():
        return "Type Python or JavaScript to see the code.", gr.Code(language="javascript", value=js_code)
    else:
        return "Please ask about Python or JavaScript.", None

with gr.Blocks() as demo:
    code = gr.Code(render=False)
    with gr.Row():
        with gr.Column():
            gr.Markdown("<center><h1>Write Python or JavaScript</h1></center>")
            gr.ChatInterface(
                chat,
                examples=["Python", "JavaScript"],
                additional_outputs=[code],
                type="messages"
            )
        with gr.Column():
            gr.Markdown("<center><h1>Code Artifacts</h1></center>")
            code.render()

demo.launch()

Here are the first and second videos attached:
gradio-screen-recording-2025-03-23T06-34-55.webm
gradio-screen-recording-2025-03-23T06-40-34.webm

Comment on lines -1542 to -1558
raise HTTPException(status_code=404)

if size is None:
return FileResponse(favicon_path)

import PIL.Image

img = PIL.Image.open(favicon_path)
img = img.resize((size, size))

img_byte_array = io.BytesIO()
img.save(img_byte_array, format="PNG")
img_byte_array.seek(0)

return StreamingResponse(
io.BytesIO(img_byte_array.read()), media_type="image/png"
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we remove this processing logic?

@abidlabs
Copy link
Member

I'm not able to play the generated videos on my end. Here's mine for reference:

gradio-screen-recording-2025-03-24T16-57-24.webm

Are you able to play this @dawoodkhan82?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants