Add your description here
Project description
LongSoraGen
English | 简体中文
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.
⚠️ Note: This codebase has not been fully tested yet because I don't have access to the OpenAI API. It should work well generally. If you encounter any problems and are kind enough to help improve this project, I would really appreciate it.
2. How It Works
LongSoraGen's main idea follows mshumer's ideas and operates in three main stages:
-
We segment the total video durations into segmentations, and generate prompt for each segmentation.
-
We use the frame from the last video as the frame reference to generate the following frames.
-
Finally, we combine all the video segments.
3. Installation
FFmpeg is needed for video processing, please install it first.
- Install from pypi:
We have distributed our library to PyPI, check it out:
pip install longsora
- 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
Set up OpenAI API Key:
export OPENAI_API_KEY='your-api-key-here'
4. Quick Start
Basic Example (Synchronous)
from pathlib import Path
from 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 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file longsora-0.1.4.tar.gz.
File metadata
- Download URL: longsora-0.1.4.tar.gz
- Upload date:
- Size: 447.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5abea027fb838a98da192d29c6b863aad3b424d3bb6a959953688764553b2ea4
|
|
| MD5 |
d7ce50b10474b69e98f25d30f25febae
|
|
| BLAKE2b-256 |
99a6e513b37d3997d2a721c1c51b5bbc234f839b77e451e266a142bfda03e82d
|
File details
Details for the file longsora-0.1.4-py3-none-any.whl.
File metadata
- Download URL: longsora-0.1.4-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01894ec07d13db46c59b15c736a251788277a5e1e7cdf8d20edc7219f679654d
|
|
| MD5 |
b9e3756cbe11af6e12afcf13e3e39bf9
|
|
| BLAKE2b-256 |
37d96a7a6c06b2f24942b5f5a6cf806c652b03ea141a1a29c2b22f183d90c8be
|