Codync
무료 오픈소스 1:1 대안, Grok Bot과 Muse 대신
비디오 디코더가 프로그램을 실행할 수 있나요?
Can a video decoder execute a program? This page compiles Game of Life or a small CPU into a standard H.264 stream; after start-up the same 16 instruction frames repeat, and your browser's decoder com
개발 도구Python · HTMLGitHub @fMindstormer온라인운영자 미확인
써 보셨어요? 한 번만 눌러 주세요. 로그인은 필요 없어요.
개인 계정의 공개 저장소 소유자는 GitHub로 로그인해 운영자를 확인하고 소개를 직접 관리할 수 있습니다. 관리자 승인은 필요하지 않습니다.
로그인한 뒤 확인 파일을 만들어 이 저장소의 기본 브랜치에 30분 안에 커밋해 주세요. 다른 브랜치나 포크의 파일은 인정하지 않습니다. 파일을 올린 뒤 아래에서 확인하면 관리자 승인 없이 관리할 수 있습니다. 자격을 유지하려면 파일을 남겨 두세요.
로그인이 필요하면 로그인 화면으로 이동합니다. 로그인 후 이곳으로 돌아와 원하는 확인 버튼을 다시 눌러 주세요.
프로젝트 폴더에서 /nomorevibe verify를 실행하면 소유권을 확인하고 소개를 직접 관리할 수 있습니다.
1분 만에 확인하기Standard H.264 videos whose decoder computes: a stored-program CPU that finds primes, Game of Life and more, built from weighted prediction
저장소 README에서 가져옴
README 전체를 불러오는 중입니다.
README 전문 보기 ↗Can a video decoder execute a program?
h264cpu compiles small computations into standard H.264 video streams. After a few start-up frames that carry the starting state, the stream repeats the same 16 instruction frames, which differ only in a cycling 4-bit frame counter. Each decoded picture supplies the state for the next step.
The examples run Conway's Game of Life and a small stored-program computer that finds primes. Their evolving states are computed during decoding; they are not stored in the file.
Draw a starting pattern, watch your browser's decoder run it, then download the same experiment as an MP4.
Try it in your browser · Download a video · How it works
What is in a file, and what computes. MP4 is only the container. Inside is an ordinary H.264 stream: a few frames of raw samples that hold the starting state, then 16 small program frames, repeated for as long as the video lasts. The computation is H.264's explicit weighted prediction, a feature meant for fades:1 each block of a program frame copies blocks of earlier decoded pictures, scales them by constant weights and adds them. The program frames never change, apart from that counter, so they cannot hold the evolving state. It lives in the decoded pictures, which the decoder keeps as references for the next frame.
The page, recorded in real time in Chromium (29 s). The instructions repeat while the state changes: the highlighted square cycles through the same 16 program frames as the board evolves. The same idea as one still image: the starting state is written once, the 16 program frames repeat, and the only path from one generation to the next is through the decoder's own reference pictures.
In the browser. The page writes the stream in JavaScript and hands it to your browser's H.264 decoder through WebCodecs, frame by frame, for as long as the tab is open. JavaScript builds the starting frames and feeds the stream; the decoder computes every state after that. Where WebCodecs can't decode H.264, the page plays a finite 60-second MP4 instead, and says so. Each run can be downloaded as an MP4 and opened in a standalone player.
Files. Five 30-second videos at 60 fps, in the v1.0 release with their SHA-256 checksums:
| Video | What the decoder computes | Picture | In 30 s | Size |
|---|---|---|---|---|
life.mp4 | Conway's Game of Life (B3/S23) on a 200×200 torus, with a glow | 400×400 | 298 generations | 10.0 MB |
primes.mp4 | The Wireworld computer's instruction set, running Michael Fryers' prime program; a seven-segment display shows each prime | 592×208 | 104 instructions: 2, 3, 5, 7 | 66.9 MB |
tunnel.mp4 | Life on a 128×128 torus, inside a 1920×1080 picture the decoder zooms and turns from its own previous frame | 1920×1080 | 299 generations | 46.4 MB |
spiral.mp4 | A 14-state cyclic cellular automaton on a 64×64 torus | 128×128 | 199 generations | 7.2 MB |
turing.mp4 | Multi-scale Turing patterns (reaction–diffusion patterns, not Turing machines) on a 104×104 torus | 208×208 | 1,793 steps | 21.6 MB |
tunnel.mp4: each streak is the history of one cell on the board's edge, one notch per generation.
primes.mp4, played at four times speed: the decoder executes the program and shows 2, 3, 5 and 7.
One macroblock is one instruction. In a B frame, each 16×16 macroblock is predicted from up to two earlier pictures: a motion vector says where to copy from, and explicit weighted prediction mixes the two copies, for every sample, as
clip(((w0·a + w1·b + 2^L) >> (L+1)) + o)
with constant integer weights and offsets.2 These files send no residual and switch the deblocking filter off, so every decoded sample is exactly that prediction. One op is two loads from earlier frames, a multiply-add with constant weights and a saturating 8-bit store, for every sample of a region at once.
Fields, a clock and memory. A program is a set of fields, boards of cells in their own regions of one large frame. In every program frame, one op rewrites each field from other fields, read up to 15 frames back at fixed offsets. A frame is a clock tick, and the decoder's reference pictures are the memory. Ops with constant weights give saturating add and subtract, thresholds, min, max and every logic gate, so a program is a circuit. Life's rule is 18 fields, at most 6 ops deep, so one generation takes 6 frames.
The same 16 frames, forever. A program frame's slice headers count frames in a 4-bit frame_num,
and nothing else in the frame changes from one frame to the next. So the file is 16 distinct program frames,
repeated. Whatever changes from one generation to the next must come from the decoded pictures.
The CPU addresses registers through circuitry. Motion vectors are part of the program frame, so no op can read a register chosen at run time. The CPU stores its 64 registers as rows of one field, reads all of them in every instruction, and keeps the row the instruction names, using masks and ORs. Its circuit is 334 fields, and one instruction takes 17 frames.
More: how it works, in detail (the computation model, the bitstream, fitting level 5.1, players, the browser) and the programs, field by field.
Every program has an exact NumPy model of what a decoder must output, and real decoders must agree with it in every sample of every frame.
| Claim | Evidence | Test or command |
|---|---|---|
| The instructions repeat, and do not hold the state | after start-up, every frame is one of the same 16; Life from two different patterns gives identical program frames | tests/test_web.py::test_program_frames_do_not_depend_on_the_start |
| The decoder computes exactly what the model says | ffmpeg's decode equals the simulation in every sample of every frame | tests/test_programs.py (3 s of each program); python -m h264cpu <program> (the 30 s release files) |
| Life follows the intended rule | the decoded board equals an independent NumPy Life after every generation | the same |
| The CPU executes its instruction set | registers, program counter, instruction register, display and carry, read from decoded frames, equal a reference CPU after every instruction | the same, for primes |
| Browser downloads match the compiler | the page's JavaScript writes the same .264 and .mp4 bytes as the Python writer | tests/test_web.py |
| A browser's decoder agrees | frames Chromium's decoder hands the page, sampled, equal the simulation | tests/test_browser.py |
| The release files decode exactly on two decoders | all 1800 frames of all five files, on ffmpeg and on Apple's VideoToolbox | release record |
Quick check, about three minutes on an M4 Mac (needs ffmpeg and Node.js):
pip install -r requirements.txt pytest
pytest -q tests/test_writer.py tests/test_programs.py tests/test_web.py
# 12 passed
The whole suite adds the browser tests (npm install --prefix tests/browser first; on Linux, xvfb-run)
and runs in CI on every push. Rebuilding and fully checking a release file:
python -m h264cpu life # ends: checked: 1800 of 1800 frames ... identical ...; 298 generations equal the reference
python -m h264cpu primes --hwaccel videotoolbox # the same on Apple's hardware decoder
These are four different kinds of evidence (short automated runs, full release verification, sampled browser frames, and playback by eye), and the verification notes keep them apart.
One earlier work computes in a video decoder: Video2NAND (2026), which draws combinational logic gates in a single VP8 frame.6 Its circuits settle within one frame; here inter frames carry state from one frame to the next. I found no earlier video file whose decoder carries state across frames, in a search in October 2026; that is not proof that none exists. Related work on computing image decoders, glitch art and programmable media, with citations: prior art.
| How it works | one macroblock as one instruction; the computation model; from a program to frames; level 5.1; players; running forever in a browser |
| The programs | Life in 18 fields, spiral waves, Turing patterns, the tunnel's fractional motion, the CPU |
| How it is checked | every check, the four kinds of evidence, the release verification record, clock speed |
| Prior art | Video2NAND, JPEG XL art, FORCEDENTRY, datamoshing, programmable media |
| Notes from the work | the ffmpeg NEON bug, frame_num's limit, the Wireworld detour, and other findings |
Run it
pip install -r requirements.txt # numpy and Pillow; the checks also need ffmpeg on PATH
python -m h264cpu life # writes out/life.264 and out/life.mp4 and checks every frame
python -m h264cpu tunnel # 1920x1080; checking all 1800 frames takes a few minutes
python -m h264cpu primes # the CPU; checks the machine's state after every instruction
python -m h264cpu spiral --seconds 10
python -m h264cpu turing --no-check
python -m h264cpu glassbox life # the whole frame, labelled (needs ffmpeg with libx264)
python -m h264cpu web # rebuilds the page in docs/ from web/
To write a new program, start from h264cpu/programs/life.py, about 100 lines: the ops, a placement of
the fields, and a starting state. For a picture field and its warp, see tunnel.py; for a circuit of
gates scheduled for you, circuit.py and primes.py.
Files
| Path | What it is |
|---|---|
h264cpu/vsim.py, interp.py | Exact integer models of weighted prediction and of quarter-pixel interpolation. |
h264cpu/writer.py, mp4.py | The bitstream writer and a minimal MP4 muxer. |
h264cpu/machine.py, layout.py, circuit.py | Fields and ops to slices, reference lists, motion vectors and frames; the simulator and level checks; placement; circuits of gates. |
h264cpu/programs/ | life.py, spiral.py, turing.py, tunnel.py, primes.py. |
h264cpu/verify.py, glassbox.py | Decoding with ffmpeg and comparing every frame; labelled views of the whole frame. |
web/, h264cpu/web.py | The page's source: page.html and h264cpu.js, the stream writer and WebCodecs player. |
docs/ | The built page, for GitHub Pages; generated, and CI checks that it is up to date. |
notes/ | The detailed write-up. |
tools/ | The scripts that make the README's recording and still image from the real page and decoder. |
tests/ | Writer, program, browser-parity and page tests. |
The page's source is in web/; python -m h264cpu web regenerates docs/ from it.
MIT. See LICENSE. Michael Fryers' prime program and the Wireworld computer's design are the work of their authors, credited above;7 the program's 37 register words are reproduced from Mark Owen's description to run it.
J. M. Boyce, "Weighted prediction in the H.264/MPEG AVC video coding standard", Proc. IEEE ISCAS 2004, vol. 3, pp. 789–792. ↩
ITU-T, Rec. H.264, Advanced video coding for generic audiovisual services: weighted sample prediction in 8.4.2.3 (equations 8-274 to 8-276) and the constraint on w0 + w1 in 8.4.3 (8-298); fractional sample interpolation in 8.4.2.2; level limits in A.3.1, A.3.3 and Tables A-1 and A-4. ↩
E. R. Berlekamp, J. H. Conway and R. K. Guy, Winning Ways for Your Mathematical Plays, vol. 2, ch. 25, "What Is Life?", Academic Press, 1982; 2nd ed., vol. 4, A K Peters, 2004. ↩
P. Rendell, "A Turing Machine in Conway's Game of Life" (2000) and "A Universal Turing Machine in Conway's Game of Life" (2010); see also his book Turing Machine Universality of the Game of Life, Springer, 2016. ↩
MDN, VideoDecoder browser compatibility: Chrome and Edge 94, Safari 16.4, Firefox 130 (not Firefox for Android).
firer, "Video2NAND", Shared Object, 11 July 2026. ↩
M. Owen, "The Wireworld computer", Quinapalus, 2004: the design by David Moore and Mark Owen (1990–92), its instruction set, and Michael Fryers' prime program with its disassembly (the final design). ↩