Colorizing Black and White Video with DDColor and a Web UI
Colorizing an old black and white film with a neural network sounds like a one-command job. In practice, the model is slow, the result depends on taste, and a full render can run for hours. If you only find out the colors look wrong at the end, you have wasted an afternoon. I built Colorise to deal with that problem: it wraps DDColor in a local web app where I can judge the colors on a few frames first, and only then commit to the full render.
Why I built it
The project started as a set of command-line scripts around DDColor. They worked, but the workflow was awkward. DDColor inference on Apple Silicon runs at roughly 1 to 4 frames per second depending on the hardware, so a feature-length film takes a long time. Each experiment with colour grading meant re-running a lot of work, and a render that was already going could not be stopped cleanly.
I wanted three things: a way to preview the look quickly, a way to control the output file size without guessing bitrates, and a way to cancel a long render and have it actually stop. That became Colorizer Studio, a single-page app in the WebUI/ folder. The original scripts remain at the repo root for batch use, and an earlier self-contained pass for one specific film lives in its own GK/ folder, untouched.
What it does
You drag a black and white video into the app and it shows the clip in a Media Pool with a thumbnail and metadata. The layout is modelled loosely on a compact video editor: media pool, preview, properties and a timeline. From there:
- Preview sample frames. The app colorizes 2 to 10 frames spread across the clip, about 2 seconds per frame after a one-time model warm-up, and shows original and colorized side by side.
- Adjust the colour grade. Move a Color Grade slider and release it, and the preview grid updates in about a second.
- Inspect a frame. Clicking a sample opens a lightbox with zoom up to 6x, drag to pan, double-click for 2.5x, arrow keys to move between samples and Esc to close.
- Render the full clip. A status pill, a timeline progress bar with frame count, frames per second and ETA, and a Stop button.
- Cap the file size. Presets for 1, 2, 3, 5 or 8 GB, or a custom value, instead of a raw bitrate field.
- Enhance the audio. Off, stereo enhance, or 5.1 surround encoded as Dolby Digital Plus.
How it works
The stack is Python, a Flask backend, and a single index.html in vanilla HTML, CSS and JavaScript with no build step. The code is split into four files:
app.pyhandles uploads, job lifecycle, cancellation and the preview endpoints.worker.pyis the per-render subprocess that colorizes frames and runs a two-pass bitrate-targeted ffmpeg encode.colorize_lib.pyholds the DDColor inference and grade-filter helpers shared by the other two.static/index.htmlis the UI.
Why previews are fast
The key trick is separating the expensive step from the cheap one. DDColor produces the colorized frames once. The colour grade, meaning brightness, contrast, temperature and similar adjustments, is applied afterwards with an ffmpeg filter chain. So when I move a slider, the app does not run the neural network again. It re-applies the ffmpeg grade to frames that are already colorized, which is why the grid refreshes in about a second. If your pipeline has a slow model step followed by a tunable post-process, keeping them separate makes the tuning loop dramatically shorter.
Why each render is its own process
Each full render runs as a separate worker.py subprocess rather than inside the Flask process. I found that a fresh process measurably avoids the memory slowdown I saw on MPS during long sustained runs. The preview endpoint is different: it only handles a handful of frames, so it keeps one model warm inside Flask to avoid reloading it on every request.
Stopping a render properly
The Stop button kills the render's whole process group, not just the parent. That matters because the worker spawns ffmpeg passes as children. Killing only the parent can leave an encoder running in the background. Using a process group means the worker and any ffmpeg pass it started are terminated together.
Size caps and the weighted progress bar
For the Max File Size option, the worker computes the video bitrate from the exact colorized frame count and duration, and from the audio bitrate actually in use. It then runs a two-pass average-bitrate encode. For example, a 2 GB cap on a 2 hour 5 minute film works out to about 1838 kbps video, rather than a figure that assumes some other runtime. This is a target, not a guarantee: two-pass ABR gets close, and the status bar reports whether the finished file landed within the cap or slightly over.
The timeline progress is weighted by where time really goes: colorize is 80 percent, encode pass 1 is 10 percent and encode pass 2 is 10 percent. A bar that moved evenly across the three stages would be misleading, since colorizing dominates.
Audio modes
Off is a plain AAC re-encode. Stereo enhance applies EBU R128 loudness normalization and an FFT denoise, which helps thin or noisy old dialogue tracks without changing the channel count. The 5.1 mode does the same cleanup, upmixes with ffmpeg's surround filter and encodes E-AC3. I checked that the result is a proper six-channel 5.1(side) stream and that it muxes into MP4.
It is not Dolby Atmos. Atmos is object-based and needs Dolby's licensed encoder, which ffmpeg and open-source tools do not have. Dolby Vision is not offered for the same licensing reason, and a colorized black and white source has no real HDR luminance data to justify HDR metadata. Labelling an SDR file as HDR would mislabel it rather than improve it, so I left it out.
The CLI scripts
The web app wraps the scripts at the repo root, which remain useful for batch work. colorize_full_movie.py is the reference pipeline with a single-pass CRF encode. colorize_great_dictator_1080p.py upscales to 1080p while preserving aspect ratio and uses a two-pass bitrate-targeted encode so output size is predictable. grade_clip.py regrades an already-colorized clip with the same ffmpeg filter chain, without running DDColor again. There are also variants with watermark removal, and legacy ECCV16 and SIGGRAPH17 colorization nets in colorizers/ from before the DDColor pipeline.
What I learned
- Separate the slow step from the tunable step. Letting the neural network run once and doing the grading in ffmpeg turned a minutes-long feedback loop into about a second.
- Preview before you commit. With inference this slow, a sample-frame preview is worth more than any amount of render optimisation.
- Cancellation has to cover child processes. Killing the process group is the difference between a Stop button that works and one that leaves ffmpeg running.
- Target size, not bitrate. People think in gigabytes. Computing the bitrate from the real duration and audio bitrate is more accurate than asking someone to guess.
- Be honest about limits. A size cap is a target, and Atmos and Dolby Vision are not available. Saying so in the interface and the docs beats implying more than the tool delivers.
Conclusion
Colorise is a local tool built around a slow model, and most of its design follows from that: preview cheaply, render once, and keep the render controllable. To run it, start python3 app.py from the WebUI folder and open it on port 5151 locally. It needs flask, opencv-python, torch, huggingface_hub, ffmpeg and a local DDColor checkout. Source movies and rendered outputs are excluded from the repository. If you have questions about the approach, you can reach me at hello@iramesh.com.