Summary
QR codes, originally invented by Denso Wave in 1994, pack up to 3 KB of data per code—equivalent to 7089 numeric or 4296 alphanumeric characters—by varying version, mode, and error-correction settings. By slicing larger data (for example, a ZIP archive) into XML-wrapped chunks of 2048 characters and encoding each chunk as a sequential QR image, the qrvid tool assembles these into an MP4, creating a high-throughput, self-documenting video stream of machine-readable frames. This article explores QR fundamentals, capacity trade-offs, animated and streaming QR techniques, and the workflow behind qrvid’s encode–decode pipeline.
Fundamentals of QR Codes
Origin and Structure
A QR code is a two-dimensional matrix barcode invented in 1994 by Masahiro Hara at Denso Wave to track automotive parts. It features black modules on a white grid with three position-detection markers and uses Reed–Solomon error correction to recover from damage.
Encoding Modes and Versions
Data is encoded in one of four modes—numeric, alphanumeric, byte (binary), or Kanji—with each mode optimizing storage for different character sets. QR codes come in 40 versions; Version 1 is 21×21 modules, increasing by 4 modules per side up to Version 40 at 177×177 modules.
Data Capacity and Error Correction
Maximum Storage
A single static QR code can hold up to 3 KB of raw data, translating to 7 089 numeric, 4 296 alphanumeric, or 1 817 Kanji characters. The absolute maximum occurs at Version 40 with error-correction level L (low).
You can do a lot with 3KB, you know?
Error-Correction Levels
Four error-correction tiers—L (7 %), M (15 %), Q (25 %), and H (30 %)—trade capacity for resilience. Level H recovers up to 30 % of damaged data, ideal for harsh environments at the cost of larger symbols. Choosing the right level balances scannability against robustness.
Pushing Boundaries: Animated and Streaming QR Codes
Let's push it further...
QR Codes in Motion
By displaying QR images in rapid succession, video frames can convey arbitrary data to smartphones capable of frame-by-frame decoding. Early experiments demonstrate exchanging data across devices without network pairing by scanning animated QR sequences. On iOS, users can screenshot a playing QR sequence and have the Photos app decode the embedded link.
Streaming with QRAM
The QRAM project encodes streams of arbitrary data into sequences of QR codes, playable as video and decodable in real time. This pattern underpins qrvid’s approach: chunk data, wrap in XML, generate QR frames, and multiplex into an MP4.
Video-Linked QR Codes
Separate from animated streams, “video QR codes” link to hosted videos. Services generate a static code that resolves to a landing page or file player when scanned. While convenient for marketing, they differ from qrvid’s offline, frame-by-frame data-dump approach.
Inside qrvid: A ZIP-to-Video QR Pipeline
Overview
qrvid extracts a ZIP archive, splits its files into 2 048-character chunks, wraps each chunk in an XML <doc>
element, and renders sequential QR images (e.g., 1.png
, 2.png
) before assembling them into an MP4.
Workflow
- Extraction: Unzip the archive to a temporary directory.
- Chunking: Read each file, Base64-encode its content, and split into 2 048-character pieces.
- XML Wrapping: Embed payloads as
<doc page="n" file="…">…</doc>
. - QR Generation: Use a QR library (e.g.,
qrcode[pil]
) to produce PNG frames with the chosen error-correction level. - Video Assembly: Concatenate frames into an MP4 via
ffmpeg
or a similar tool. - Reconstruction: Decode the MP4 back to images, scan with
pyzbar
or OpenCV, and reassemble files using checksums for integrity.
Use Cases and Applications
- Offline Distribution: Ship software or datasets on DVD/Blu-ray as video; scan to retrieve contents.
- Artistic Installations: Project data-encoded visuals that viewers scan for hidden content in galleries.
- Interactive Memorials: QR codes on monuments linking to multimedia biographies; QR videos offer richer archives without internet.
- Secure Data Bursts: In air-gapped environments, display a short QR video to transfer audit logs or cryptographic keys.
What worked for me
- Chunk Size: Keep under 2 048 characters per QR to ensure legibility and speed.
- Error-Correction: For high-risk scanning contexts, use Level H but test symbol size against scan distance.
- Frame Rate: Allow 5–10 fps for reliable smartphone decoding; faster rates risk motion blur.
- Module Dimensions: Balance
box_size
andborder
to fit device cameras and projection surfaces.
Future Directions?
- Micro and iQR Codes: I saw something about an ISO 18004:2024 to pack even more?
- Mapped character packing-packing Kanji 4,000 characters is not the same as 4,000 english characters-concept compression
- Application storage? What if this stored an entire application?
I asked ChatGPT for an Opinion:
qrvid exemplifies how foundational barcode technology can be reimagined for modern data-packing challenges, transforming a simple QR sequence into a resilient, self-documenting video pipeline. Whether for offline software delivery or creative data art, it underscores the untapped potential at the intersection of low-tech scanning and high-tech workflows.