Skip to content

Conversation

@devin-ai-integration
Copy link

@devin-ai-integration devin-ai-integration bot commented Jun 15, 2025

  • I agree to license my contribution under AGPL-3.0-only with my contribution automatically being licensed under LGPL-3.0 additionally after 6 months

Add Crop Action Type and Parameters for Video Segment Cropping

Summary

This PR extends the SponsorBlockServer to support a new Crop action type and crop parameters for video segments, enabling users to define crop regions for both timestamp-bound cropping (chapter + crop) and full-video cropping (windowbox + crop).

Changes Made

Type System Updates

  • Added Crop = "crop" to the ActionType enum
  • Added windowbox category to the category list and type definitions
  • Extended IncomingSegment, Segment, and DBSegment interfaces with optional crop parameters:
    • cropLeft?: number (0-255, left crop ratio * 256)
    • cropRight?: number (0-255, right crop ratio * 256)
    • cropTop?: number (0-255, top crop ratio * 256)
    • cropBottom?: number (0-255, bottom crop ratio * 256)

Category Support Configuration

  • Added windowbox category with support for full and crop actions
  • Added crop action support to existing chapter category
  • This enables two distinct cropping behaviors:
    • Chapter + Crop: Timestamp-bound cropping for specific time segments
    • Windowbox + Crop: Full-video cropping for the entire video

Database Schema

  • Created migration script _upgrade_sponsorTimes_45.sql to add crop fields to sponsorTimes table
  • Updated database version to 45

Server-Side Logic

  • Validation: Added comprehensive validation for crop parameters including:
    • Individual field validation (0-255 range for each crop parameter)
    • Combined constraints (left+right ≤ 256, top+bottom ≤ 256)
  • Storage: Updated database insertion logic to store crop parameters
  • Retrieval: Updated database queries to include crop fields in SELECT statements

Testing

  • TypeScript compilation passes successfully
  • Existing test suite runs with 741/746 tests passing (5 pre-existing failures unrelated to crop functionality)
  • No regressions introduced by the new crop functionality

Implementation Details

The crop parameters use integer values 0-255 representing crop ratios multiplied by 256, allowing precise crop region definitions while maintaining efficient storage and transmission.


Link to Devin run: https://app.devin.ai/sessions/d603923e56b246339b2c69516e4818c1

Requested by: Erkin Alp Güney (erkinalp9035@gmail.com)

devin-ai-integration bot and others added 2 commits June 15, 2025 09:23
…tegories

- Add Crop to ActionType enum
- Add windowbox category with full and crop action support
- Extend segment interfaces with optional crop parameters (cropLeft, cropRight, cropTop, cropBottom)
- Add database migration to add crop fields to sponsorTimes table
- Add validation for crop parameters (0-255 range, left+right ≤ 256, top+bottom ≤ 256)
- Update database insertion and retrieval logic for crop fields

Co-Authored-By: Erkin Alp Güney <erkinalp9035@gmail.com>
…s table

- Update migration to add crop fields to both sponsorTimes and archivedSponsorTimes
- Ensures archive job SELECT * operations work correctly with new crop parameters
- Maintains transaction consistency as requested

Co-Authored-By: Erkin Alp Güney <erkinalp9035@gmail.com>
@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@erkinalp erkinalp merged commit 5883c39 into master Jul 4, 2025
4 checks passed
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.

2 participants