Automated frame-by-frame rendering and video synthesis for physics simulations and generative game shorts.
Project description
DeepFlow-Engine
🚀 What is DeepFlow?
DeepFlow is a frame-by-frame simulation engine designed for games and physics systems that lets you:
- 🎮 Run games interactively (like normal pygame) with optional playback recording
- ⚙️ Simulate them headlessly (no window) for batch processing
- 🎞️ Generate frames automatically for video synthesis
- 🔊 Log events (like collisions) and trigger audio events
- 🎬 Render videos with perfectly synced audio (ready for reels/shorts)
- 📤 Publish outputs directly (Telegram, Discord coming soon)
🧠 Core Idea
Write your game once, and use it in multiple modes:
Game Logic → Engine → Frames → Video → Publish
This separation of concerns allows you to:
- Develop interactively with real-time feedback
- Generate content programmatically for automation
- Test deterministically in headless mode
- Scale to batch video generation
📦 Installation
pip install deepflow-engine
Requirements: Python 3.12+
📚 Documentation & Examples
For complete working examples, check out the example/ directory:
- 🎮 Full game implementation with collision detection
- 🎬 Interactive and headless modes
- 📹 Video rendering with audio
- 🎯 Best practices and patterns
Run examples:
cd example
python main.py --help
⚡ Quick Start
1. Create a Game
Extend DeepFlowGame with your game logic:
import deepflow_engine as dfe
import pygame
class MyGame(dfe.DeepFlowGame):
def start(self):
"""Initialize game state"""
self.x = 100
def update(self):
"""Update game logic (called every frame)"""
self.x += 100 * self.dt # Always use dt for frame-independent movement!
def render(self, canvas):
"""Render game state to canvas"""
canvas.fill((255, 255, 255))
pygame.draw.circle(canvas, (0, 0, 255), (int(self.x), 200), 20)
def get_audio_map(self):
"""Map event types to audio files"""
return {}
2. Run the Engine
Interactive Mode (Preview & Play)
game = MyGame()
engine = dfe.DeepFlowEngine(game, interactive=True)
dfe.run_pipeline(engine)
Headless Mode (Generate Video)
game = MyGame()
engine = dfe.DeepFlowEngine(
game,
interactive=False,
frames_dir="frames",
video_length_seconds=10,
)
output = dfe.run_pipeline(engine)
print(f"Video saved: {output}")
🎯 Complete Example
For a complete, production-ready example with collision detection, event handling, and video generation, see the example/ directory:
# Run interactive mode
python example/main.py --interactive
# Generate video headlessly
python example/main.py --headless --duration 10
The example demonstrates best practices for building games with DeepFlow.
🎥 Output
DeepFlow automatically:
- Simulates your game frame-by-frame
- Saves frames to disk
- Logs events (collisions, audio triggers, etc.)
- Renders video with synced audio
Output structure:
frames/ # Individual frames
collisions_log.json # Event log
deepflow_output.mp4 # Final video
🔊 Audio System
Define Audio Assets
In your game class:
def get_audio_map(self):
return {
"collision": "assets/crash.wav",
"score": "assets/point.wav",
}
Trigger Events
During gameplay:
def update(self):
if self.collision_detected():
self.play_audio("collision")
Behavior
- Interactive mode: Plays sound instantly
- Headless mode: Logs event for final video rendering
🎮 Input Handling
Use get_input() abstraction:
def get_input(self):
if self._engine.interactive:
return pygame.key.get_pressed()
return None
⏱️ Time-Based Movement (IMPORTANT)
Always use dt:
self.x += speed * self.dt
❌ Don’t do:
self.x += 5
🧩 Engine Modes
| Mode | Use Case | Interactive |
|---|---|---|
| Interactive | Play/preview the game in real-time | Yes |
| Interactive + Record | Play while recording frames for video | Yes |
| Headless | Batch generate deterministic simulations | No |
| Pipeline | Full automated video generation | No |
📤 Publishing (Optional)
Telegram
Send generated videos directly to Telegram:
from deepflow_engine.publisher import TelegramPublisher
publisher = TelegramPublisher(bot_token="YOUR_BOT_TOKEN", chat_id="YOUR_CHAT_ID")
publisher.send_video("deepflow_output.mp4")
Discord (Open for Contributions 🚀)
A Discord publisher is in the roadmap.
Interested in implementing it?
- Implement
DiscordPublisherextendingBasePublisher - Follow the existing
TelegramPublisherpattern - Open a PR with tests
🧠 Design Philosophy
DeepFlow follows clean architecture principles:
Game → Pure game logic (independent of engine)
Engine → Execution engine (runs game at any speed)
Renderer → Video output (handles frame->video conversion)
Publisher→ Distribution (sends to external services)
This separation ensures:
- ✅ Games are testable and reusable
- ✅ Easy to add new modes (headless, interactive, streaming)
- ✅ Simple to integrate with other tools
🔥 Use Cases
- 🎮 Game Automation: Auto-play games and record gameplay
- 🎬 Content Creation: Generate Instagram Reels/YouTube Shorts automatically
- 🧪 Simulation & Visualization: Physics simulations with video output
- 🤖 AI/RL Training: Gym-style environments with video logging (coming soon)
- 🧠 Generative Content: Batch create variations of games for viral content
🛠️ Roadmap
- Discord publisher
- CLI tool (
deepflow run game.py) - Gymnasium/Gym integration for RL
- Multi-event timeline system
- Streaming output support
- WebGL renderer for browser playback
🤝 Contributing
We welcome contributions! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes and write tests
- Commit with clear messages (
git commit -m 'Add amazing feature') - Push and open a Pull Request
Guidelines:
- Keep the API clean and intuitive
- Avoid tight coupling between game and engine
- Prefer composition over inheritance
- Add tests for new features
- Update documentation
📜 License
Apache 2.0 License - see LICENSE for details
👀 Final Note
DeepFlow is not just a game engine.
It's a content engine - designed to transform game logic into automated, scalable content production.
Use it to build interactive experiences, and let it generate the reels.
Made with ❤️ by deependujha
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 deepflow_engine-0.1.6.tar.gz.
File metadata
- Download URL: deepflow_engine-0.1.6.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3acaac3525b6807b059d0f142485f971c7c0210a718e939bc62677b30a70091
|
|
| MD5 |
6cb35bed30a1b0146d5ad061acb88eea
|
|
| BLAKE2b-256 |
9ea03a49379879234946a425069d1138e5b8b1ef03a1f8a1c1b833bb3d9581e5
|
Provenance
The following attestation bundles were made for deepflow_engine-0.1.6.tar.gz:
Publisher:
release-pypi.yml on deependujha/DeepFlow-Engine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
deepflow_engine-0.1.6.tar.gz -
Subject digest:
f3acaac3525b6807b059d0f142485f971c7c0210a718e939bc62677b30a70091 - Sigstore transparency entry: 1172508146
- Sigstore integration time:
-
Permalink:
deependujha/DeepFlow-Engine@2385c0aacc09177da75221b40d9561e352c0d108 -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/deependujha
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@2385c0aacc09177da75221b40d9561e352c0d108 -
Trigger Event:
release
-
Statement type:
File details
Details for the file deepflow_engine-0.1.6-py3-none-any.whl.
File metadata
- Download URL: deepflow_engine-0.1.6-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87f6baf8736ae14e416cd0d4b046faccabb2970d2a78778a4002f437b282aceb
|
|
| MD5 |
da3f365e994a1b6de08920fbb102357d
|
|
| BLAKE2b-256 |
173d47b1840357689a0a7e5b44006b37fe020349f73fe00b38d97a73d3a9846b
|
Provenance
The following attestation bundles were made for deepflow_engine-0.1.6-py3-none-any.whl:
Publisher:
release-pypi.yml on deependujha/DeepFlow-Engine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
deepflow_engine-0.1.6-py3-none-any.whl -
Subject digest:
87f6baf8736ae14e416cd0d4b046faccabb2970d2a78778a4002f437b282aceb - Sigstore transparency entry: 1172508153
- Sigstore integration time:
-
Permalink:
deependujha/DeepFlow-Engine@2385c0aacc09177da75221b40d9561e352c0d108 -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/deependujha
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@2385c0aacc09177da75221b40d9561e352c0d108 -
Trigger Event:
release
-
Statement type: