Skip to content

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/76dd5d48068f7c286807754c2bc59fb7f1ee5444/gradio-5.30.0-py3-none-any.whl

Install Gradio Python Client from this PR

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

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/76dd5d48068f7c286807754c2bc59fb7f1ee5444/gradio-client-1.15.0.tgz

Use Lite from this PR

<script type="module" src="https://gradio-lite-previews.s3.amazonaws.com/76dd5d48068f7c286807754c2bc59fb7f1ee5444/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

@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?

@hannahblair
Copy link
Collaborator

Screenshot 2025-05-13 at 22 29 58

Wdyt if we change this and the tab to something like

Start recording
Open the tab: [Sharing] Gradio Tab

@abidlabs
Copy link
Member

Hmm sorry I just tested this @dawoodkhan82 and the zooms are off. Here's the deployed Space I tested: https://gradio-pr-deploys-pr-10832-all-demos.hf.space/demo/audio_debugger/?__theme=dark

and here's the video it produced:

gradio-screen-recording-2025-05-14T02-10-31.mp4

@abidlabs
Copy link
Member

Ah okay it looks like the issue is because I selected an example. But that's a common enough use case that we should definitely support it.

If I select a file, it works fine:

gradio-screen-recording-2025-05-14T02-18-51.mp4

Although a couple of things:

  • While I'm selecting a file, there's a few seconds where it seems like nothing is happening. Can we remove these frames from the video? i.e. consecutive frames that are unchanged
  • It still looks like the resolution is a little bit off. Notice how at the beginning of the video the screen stretches vertically -- what's happening there?

@dawoodkhan82
Copy link
Collaborator Author

@abidlabs from our discussion: moved "Screen Studio" to settings.

screen_recording.mov

@abidlabs
Copy link
Member

Nice looks good! I also liked the idea of having a checkboxes there to enable/disable zooming and enable/disable trimming

@dawoodkhan82
Copy link
Collaborator Author

dawoodkhan82 commented May 15, 2025

Nice looks good! I also liked the idea of having a checkboxes there to enable/disable zooming and enable/disable trimming

Added!

Screenshot 2025-05-15 at 4 35 01 PM

@hannahblair
Copy link
Collaborator

Added!

Oh that's neat!

@abidlabs
Copy link
Member

abidlabs commented May 16, 2025

Some minor points noted above, once those are addressed should be ready to merge!

@dawoodkhan82 dawoodkhan82 requested a review from abidlabs May 20, 2025 14:59
Copy link
Member

@abidlabs abidlabs left a comment

Choose a reason for hiding this comment

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

LGTM @dawoodkhan82 thanks for putting this together! Let's get it out and get feedback from the community

@dawoodkhan82 dawoodkhan82 merged commit d457438 into main May 20, 2025
22 of 23 checks passed
@dawoodkhan82 dawoodkhan82 deleted the screen-recording branch May 20, 2025 15:55
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.

6 participants