Add video recording configuration options to BrowserSession

- Introduced `record_video_framerate` and `record_video_size` parameters to the BrowserSession class for enhanced video recording capabilities.
- Updated example in video_recording.py to reflect changes, switching from BrowserSession to Browser for video recording setup.

This update allows users to customize video recording settings more effectively.
This commit is contained in:
Magnus Müller
2025-09-06 12:29:19 -07:00
parent 61ac7af239
commit be6fd1a92e
2 changed files with 6 additions and 5 deletions

View File

@@ -244,6 +244,8 @@ class BrowserSession(BaseModel):
record_har_mode: str | None = None,
record_har_path: str | Path | None = None,
record_video_dir: str | Path | None = None,
record_video_framerate: int | None = None,
record_video_size: dict | None = None,
# From BrowserLaunchPersistentContextArgs
user_data_dir: str | Path | None = None,
# From BrowserNewContextArgs

View File

@@ -1,14 +1,13 @@
import asyncio
from pathlib import Path
from browser_use import Agent, BrowserProfile, BrowserSession, ChatOpenAI
from browser_use import Agent, Browser, ChatOpenAI
# NOTE: To use this example, install imageio[ffmpeg], e.g. with uv pip install "browser-use[video]"
async def main():
# Define a profile that enables video recording
video_profile = BrowserProfile(headless=False, record_video_dir=Path('./tmp/recordings'))
browser_session = BrowserSession(browser_profile=video_profile)
browser_session = Browser(record_video_dir=Path('./tmp/recordings'))
agent = Agent(
task='Go to github.com/trending then navigate to the first trending repository and report how many commits it has.',