feat(cli): add video2yaml command to generate test scripts from video#2169
feat(cli): add video2yaml command to generate test scripts from video#2169
Conversation
Deploying midscene with
|
| Latest commit: |
ada2091
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://9750da8a.midscene.pages.dev |
| Branch Preview URL: | https://feat-video-to-script.midscene.pages.dev |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aa8f72b4d7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| format: VideoScriptFormat, | ||
| ): string { | ||
| const ext = format === 'playwright' ? '.test.ts' : '.yaml'; | ||
| return inputPath.replace(/\.[^.]+$/, ext); |
There was a problem hiding this comment.
Preserve input file when deriving default output path
For extensionless video paths (for example midscene video2yaml ./recording), inputPath.replace(/\.[^.]+$/, ext) returns the original path unchanged, so outputPath becomes the same file as the input. The subsequent writeFileSync(outputPath, result.content, 'utf-8') then overwrites the source video with generated script content, which is destructive data loss in a realistic CLI usage scenario.
Useful? React with 👍 / 👎.
…n recordings Add a new CLI subcommand `midscene video2yaml` that extracts frames from a video file using ffmpeg and sends them to a VLM to generate runnable Midscene test scripts in YAML or Playwright format. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The npm packages @ffmpeg-installer/ffmpeg and @ffprobe-installer/ffprobe may install binaries without execute permission. Add chmod +x before use and verify executability with a test spawn, falling back to system binaries when the npm binary is not usable. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Long videos (>20 frames) are now automatically split into segments using ffmpeg scene detection, each segment analyzed independently by the VLM, then merged into a single coherent script. - Add segment-frames.ts with detectSceneChanges and segmentFrames - Add segment/merge prompts in video-to-yaml.ts - Short videos (<= 20 frames) still use single-call path unchanged - Add --max-frames-per-segment and --scene-threshold CLI options - Add 19 unit tests covering segmentation and CLI parsing - Extract prependWebConfigIfMissing to eliminate duplicate code - Add MAX_TOTAL_FRAMES=600 cap to prevent OOM on very long videos Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
9f9f47d to
eb7eff4
Compare
…LI args - Make maxFrames the global budget for both short and long video paths, capped by MAX_TOTAL_FRAMES (600) - Add validation for all numeric CLI parameters (fps, maxFrames, maxFramesPerSegment, sceneThreshold) with clear error messages - Add 5 new test cases for numeric validation edge cases Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove unused `format` parameter from `generateFromVideoSegment` - Remove redundant second sort in `detectSceneChanges` (already sorted in `parseSceneTimestamps`) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
midscene video2yamlCLI subcommand that generates runnable Midscene test scripts (YAML or Playwright) from screen recording videos@ffmpeg-installer/ffmpegwith system fallback)--format yaml|playwrightNew files
packages/core/src/ai-model/prompt/video-to-yaml.tspackages/cli/src/video/extract-frames.tspackages/cli/src/video/index.tsvideo2yaml()orchestrator: extract → analyze → writepackages/cli/src/video/cli.tsvideo2yamlsubcommandpackages/cli/tests/unit-test/video-cli.test.tspackages/core/tests/unit-test/video-to-yaml.test.tsUsage
Test plan
pnpm run lintpassesnpx nx build @midscene/clibuilds successfullynpx vitest --run tests/unit-test/video-cli.test.ts— 8 tests passnpx vitest --run tests/unit-test/video-to-yaml.test.ts— 2 tests passpage.goto()for navigation🤖 Generated with Claude Code