Skip to content

Video generation using Sora 2 and Sora 2 pro#79

Merged
kailashahirwar merged 1 commit intomainfrom
feature/openai-sora-video
Dec 18, 2025
Merged

Video generation using Sora 2 and Sora 2 pro#79
kailashahirwar merged 1 commit intomainfrom
feature/openai-sora-video

Conversation

@kailashahirwar
Copy link
Collaborator

@kailashahirwar kailashahirwar commented Dec 18, 2025

🚀 Added: OpenAI Sora Video Generation Adapter (Sora 2 & Sora 2 Pro)

This update introduces a comprehensive video generation adapter for OpenAI’s Sora models, enabling both text-to-video and image-to-video workflows with robust resolution handling, flexible waiting strategies, and a clean developer experience.


Key Features

Core Functionality

  • Sora 2 & Sora 2 Pro support
    • Model-specific resolution validation and constraints
  • Text-to-Video
    • Generate high-quality videos directly from text prompts
  • Image-to-Video
    • Animate static images with text-based guidance
  • Automatic Image Resizing
    • Intelligent resizing to the closest supported resolution
    • Aspect-ratio–aware scaling
  • Dual Wait Strategies
    • Synchronous (blocking) execution
    • Asynchronous (callback-based) generation for long-running jobs

Technical Implementation

  • Model-specific resolution sets
    • Sora 2: 2 supported resolutions
    • Sora 2 Pro: 4 supported resolutions
  • Automatic aspect ratio detection with closest-match resolution selection
  • High-quality image resizing using LANCZOS resampling
  • Comprehensive validation and error handling
  • Generation progress tracking and status monitoring

Developer Experience

  • Clean, intuitive Python API consistent with existing adapters
  • Full CLI support via sora_video.py
  • Extensive Docusaurus documentation
  • Strong typing with type hints
  • Detailed docstrings for all public interfaces

Why This Matters

This adapter makes Sora video generation production-ready:

  • No manual resolution guessing
  • No brittle polling logic
  • No mismatched APIs

Developers can move from experimentation to deployment with minimal friction.

Documentation

Full API reference, quickstart guide, and usage examples added to Docusaurus documentation.


Note

Adds Sora 2/2 Pro video generation (text/image-to-video) with sync/async APIs, a CLI, and comprehensive documentation updates.

  • Backend/API:
    • Add SoraVideoAdapter in tryon/api/openAI/video_adapter.py supporting text-to-video, image-to-video, sync polling, async callbacks, status retrieval, and downloads; model-specific durations/resolutions.
    • Export adapter in tryon/api/openAI/__init__.py.
  • CLI:
    • Introduce sora_video.py for video generation with options for --model, --duration, --resolution, async mode, and API key handling.
  • Docs:
    • Add new page docs/docs/api-reference/sora-video.md (usage, API reference, supported options).
    • Update README.md with “Video Generation with OpenAI Sora” section and examples.
    • Update docs/docs/getting-started/quickstart.md to include Sora examples and add link.
    • Update docs/docs/intro.md to mention Sora and add relevant keywords.
    • Update sidebar docs/sidebars.ts to include api-reference/sora-video.

Written by Cursor Bugbot for commit 2abcd7f. This will update automatically on new commits. Configure here.

@kailashahirwar kailashahirwar merged commit 9c244a7 into main Dec 18, 2025
2 checks passed
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This is the final PR Bugbot will review for you during this billing cycle

Your free Bugbot reviews will reset on January 16

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

"1024x1792", # Tall vertical
"1792x1024", # Wide horizontal
}
}
Copy link

Choose a reason for hiding this comment

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

Bug: Missing Full HD resolutions in MODEL_RESOLUTIONS validation

The MODEL_RESOLUTIONS dictionary is missing 1920x1080 and 1080x1920 resolutions that are documented in the README and accepted by the CLI's choices parameter. When users try to use these documented resolutions (e.g., --resolution 1920x1080), the adapter's _validate_common_params method will raise a ValueError because these resolutions aren't in the model-specific sets. The CLI accepts 6 resolutions but the adapter only supports 4.

Additional Locations (1)

Fix in Cursor Fix in Web

f"Image dimensions {image_resolution} do not match any supported video resolution. "
f"Supported resolutions: {VALID_RESOLUTIONS}. "
f"Set auto_resize=True to automatically resize, or resize your image manually."
)
Copy link

Choose a reason for hiding this comment

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

Bug: Error message shows wrong resolutions for model

The error messages in generate_image_to_video and generate_image_to_video_async use the global VALID_RESOLUTIONS constant instead of the model-specific model_resolutions variable that was computed earlier in the same functions. This causes the error to display all resolutions across all models rather than the resolutions actually supported by the user's selected model, which is inconsistent with the validation logic and could mislead users.

Additional Locations (1)

Fix in Cursor Fix in Web

time.sleep(1)
except KeyboardInterrupt:
print("\nExiting... (video generation continues on server)")
sys.exit(0)
Copy link

Choose a reason for hiding this comment

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

Bug: CLI async mode never exits after completion or error

In async mode, the main thread runs an infinite while True loop that only exits on keyboard interrupt. The on_complete callback saves the video but doesn't signal the main thread to exit, and the on_error callback calls sys.exit(1) which doesn't work from a background thread (it only terminates that thread, not the process). Users must manually press Ctrl+C even after successful video generation or after an error occurs.

Additional Locations (1)

Fix in Cursor Fix in Web

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.

1 participant