Storing Videos in Postgres: Using JSONB to Version Control Your Timelines
October 31, 2026 · By VideoFlowLearn how to treat video as data by storing VideoFlow timelines in Postgres JSONB for version control, programmatic diffing, and instant previews.
Storing Videos in Postgres: Using JSONB to Version Control Your Timelines
How do you version control a video? If you are using traditional binary formats like MP4 or proprietary project files from After Effects, the answer is usually "you don't"—at least not in a way that is meaningful for developers. You end up with final_v2_edit_fixed.mp4 and zero visibility into what actually changed between renders.
VideoFlow changes this by treating videos as data. Because every VideoFlow project compiles into a portable, schema-validated VideoJSON document, you can treat your video timelines exactly like your application data.
In this guide, we'll explore how to store video timelines in Postgres using JSONB, enabling powerful features like instant previews, multi-user versioning, and programmatic diffing.
Why JSONB is the Perfect "Video Format"
When you call $.compile() in the @videoflow/core builder, you get a plain JavaScript object. This object contains everything needed to reconstruct the video: layer definitions, keyframes, effect stacks, and timing logic.
Storing this in a Postgres JSONB column gives you several immediate advantages:
- Structural Integrity: JSONB validates that your timeline is well-formed JSON on every write.
- Indexing: You can index specific fields within the video (like
fpsorwidth) to query your video library. - Diffability: You can use standard SQL or application-level logic to see exactly which layers or keyframes changed between two versions.
- Portability: The same JSON blob can be rendered in the browser via @videoflow/renderer-browser or on a server via @videoflow/renderer-server.

Implementation: Saving a Timeline
Let's look at a practical example. Imagine a SaaS platform that generates personalized welcome videos for new users. Instead of rendering and storing a 50MB MP4 for every user, you can store a 5KB JSON blob and render it on-demand or in the background.
import VideoFlow from '@videoflow/core';
async function createPersonalizedVideo(userName) {
const $ = new VideoFlow({ width: 1280, height: 720, fps: 30 });
// Add a background
$.addImage({ fit: 'cover' }, { source: 'https://cdn.example.com/bg.jpg' });
// Add personalized text
const title = $.addText({
text: `Welcome, ${userName}!`,
fontSize: 6,
color: '#FF5A1F',
position: [0.5, 0.5]
});
title.fadeIn('500ms');
$.wait('3s');
// Compile to VideoJSON
const videoData = await $.compile();
// Store in Postgres (using your favorite ORM or raw SQL)
// db.query('INSERT INTO videos (user_id, timeline) VALUES ($1, $2)', [userId, videoData]);
return videoData;
}
Versioning and Diffing
Because the timeline is just JSON, versioning becomes trivial. You can use a simple video_versions table to keep a history of edits.

When a user wants to "undo" a change in your React Video Editor, you aren't reloading a massive binary file; you are simply swapping one JSON object for another. You can even use JSON patches to store only the deltas between versions, making your storage extremely efficient.
The Three-Renderer Rule
One of the most powerful aspects of storing VideoJSON in Postgres is that it remains renderer-agnostic. Once you fetch that JSON from the database, you can:
- Pass it to the Playground for live debugging.
- Mount it in the
@videoflow/renderer-domfor a frame-accurate Live Preview. - Send it to a Node.js worker to produce a final MP4 using
@videoflow/renderer-server.
This workflow is significantly more flexible than the patterns used in tools like Remotion or FFmpeg. While those tools are powerful, they often tie your video logic to a specific runtime or complex shell commands. VideoFlow's JSON-first approach treats video as a first-class citizen of your database.
Beyond Simple Storage
Storing videos as JSONB opens up advanced automation possibilities. You can run SQL queries to find all videos that use a specific asset URL (useful for cleaning up S3), or bulk-update the backgroundColor of 1,000 videos with a single UPDATE statement.
If you're coming from a background of chaining FFmpeg scripts, this transition feels like moving from assembly to a high-level language. You get types, you get structure, and you get a database-backed source of truth.
Get Started with VideoFlow
Ready to start treating your videos like data? You can explore the full VideoJSON schema in our docs or try building your first timeline in the interactive Playground.
VideoFlow is fully open-source (Apache-2.0). Check out the source code and join the community on GitHub.
Related Reading: Building a Video Editor in React with @videoflow/react-video-editor