Skip to main content

Add your description here

Project description

LongSoraGen

This project provides a full OpenAI-compatible API for generating longer Sora videos by intelligently splitting them into segments and ensuring seamless continuity.

1. Overview

LongSoraGen overcomes Sora's duration limitations by breaking down long video generation requests into multiple connected segments. The system uses AI-powered planning to create coherent narratives across segments and maintains visual continuity by using the last frame of each segment as a reference for the next.

Some of the code and idea is from https://github.com/mshumer/sora-extend, thank you for their work.

2. How It Works

LongSoraGen's main idea follows mshumer's ideas and operates in three main stages:

  1. We segment the total video durations into segmentations, and generate prompt for each segmentation.

  2. We use the frame from the last video as the frame reference to generate the following frames.

  3. Finally, we comibine all the video segments.

3. Installation

FFmpeg is needed for video processing, please install it first.

  1. Install from pypi:

We have distribute our lib into the pypi, check this our:

pip install longsora
  1. Install from scratch:

We highly recommend using the uv to install the environments:

uv sync

The environment will be installed in .venv. Activate it using:

source .venv/bin/activate

4. Quick Start

Basic Example (Synchronous)

from pathlib import Path

from src.longsora import OpenAI

output_dir = Path("resources") / "case1"
prompt = "A woman is dancing in a bunch of trees."
model = "sora-2"
seconds_per_segment = 8
num_generations = 3
print(f"the video will be {seconds_per_segment * num_generations} seconds long")

if __name__ == "__main__":
    client = OpenAI()
    client.create_video(
        prompt=prompt,
        model=model,
        seconds_per_segment=seconds_per_segment,
        output_dir=output_dir,
        num_generations=num_generations,
        verbose=True,
        save_segments=True,
        plan_model="gpt-5",
    )

Async Example

import asyncio
from pathlib import Path

from src.longsora import AsyncOpenAI

output_dir = Path("resources") / "case2"
prompt = "A woman is dancing in a bunch of trees."
seconds_per_segment = 8
model = "sora-2"
num_generations = 2

print(f"the video will be {seconds_per_segment * num_generations} seconds long")


async def main():
    client = AsyncOpenAI()
    await client.create_video(
        prompt=prompt,
        model=model,
        seconds_per_segment=seconds_per_segment,
        output_dir=output_dir,
        num_generations=num_generations,
        verbose=True,
        save_segments=True,
        plan_model="gpt-5",
    )


if __name__ == "__main__":
    asyncio.run(main())

5. License

MIT License

Copyright (c) 2025 LLinkedlist

See LICENSE for details.

6. Citation

If you use this project in your research or applications, please cite:

@misc{longsoragen2025,
  author = {linkedlist771},
  title = {LongSoraGen: Extended Video Generation with OpenAI Sora},
  year = {2025},
  url = {https://github.com/linkedlist771/LongSoraGen}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

longsora-0.1.1.tar.gz (447.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

longsora-0.1.1-py3-none-any.whl (1.0 MB view details)

Uploaded Python 3

File details

Details for the file longsora-0.1.1.tar.gz.

File metadata

  • Download URL: longsora-0.1.1.tar.gz
  • Upload date:
  • Size: 447.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.0

File hashes

Hashes for longsora-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1e922d377172ccdd973df8a1561a02f17afadcf55b9e5c6e1389f825bf805525
MD5 8bdc1308ff4d6a1dc9fa395a38e32b8c
BLAKE2b-256 df5397d04e72229c238e97c2157a36563ebe1c61f276210c0fcdcf4f66f0ad45

See more details on using hashes here.

File details

Details for the file longsora-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: longsora-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.0

File hashes

Hashes for longsora-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2cb7e6c4db712ec0e7e5fa5884c245e6d40b82453a20eb21b1263f9e16661a31
MD5 a0990e4c528d51312a785a9fc1822dca
BLAKE2b-256 f4153cd4526f2c743ee85595a292c793797a6570206807570949ba884c2b65a8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page