QRVideoSlicer is a Python-based tool that allows users to split large video files into QR code images, making it possible to store and share videos within size-limited platforms (e.g., GitHubβs 25MB file limit). Each QR code contains a chunk of the encoded video, and a header file maps the order and metadata.
The same tool can then be used to reconstruct the original video from these QR codes. This makes the system ideal for scenarios where videos need to be archived or transferred in limited environments.
- π§© Split large videos into compressed QR code chunks.
- π Folder-wise organization of QR images for each video.
- π Header file ensures correct reassembly of videos.
- β‘ Interactive script with options: Convert or Reassemble.
- ποΈ Prompts to delete original video or uninstall dependencies after use.
- π§ͺ Auto-check and install dependencies.
project_root/
βββ Video to QR.py # Main interactive script
βββ output/ # Reconstructed videos
βββ MyVideo.mp4 # Input video file
βββ MyVideo/ # Folder with QR images and header
β βββ chunk_00000.png
β βββ chunk_00001.png
β βββ ...
β βββ header.json
β βββ export_here.py # Auto-reassemble script
+------------------+
| Input Video |
+--------+---------+
|
v
+---------------------+
| QRVideoSlicer Tool |
| [1] Convert Video |
| [2] Export Video |
+---+-----------+----+
| |
+---------+ +---------+
| |
+--v--+ +----v-----+
| QR | | Rebuild |
| Img | | Video |
| Set | +----+-----+
+-----+ |
+-----v------+
| output.mp4 |
+------------+
with open("MyVideo.mp4", 'rb') as f:
video_data = f.read()
# Encode video to base64
b64_data = base64.b64encode(video_data).decode('utf-8')
# Split into smaller chunks
chunks = [b64_data[i:i+CHUNK_SIZE] for i in range(0, len(b64_data), CHUNK_SIZE)]What it does: Reads the video file and splits it into chunks small enough to fit into individual QR codes.
for i, chunk in enumerate(chunks):
qr = qrcode.QRCode(version=40, box_size=10, border=2)
qr.add_data(chunk)
img = qr.make_image()
img.save(f"chunk_{i:05d}.png")What it does: Each base64 chunk is converted into a high-capacity QR code image and saved.
header = {
"video_name": "MyVideo.mp4",
"num_chunks": len(chunks),
"chunk_size": 2000,
"encoding": "base64"
}
with open("header.json", 'w') as f:
json.dump(header, f)What it does: Stores necessary info for reconstructing the video later, including number of QR codes and original filename.
# Load header metadata
with open("header.json") as f:
meta = json.load(f)
# Read and decode all QR images
video_data = ''
for i in range(meta['num_chunks']):
image = Image.open(f"chunk_{i:05d}.png")
decoded = decode(image)[0].data.decode('utf-8')
video_data += decoded
# Convert back to binary video
with open(f"output_{meta['video_name']}", 'wb') as f:
f.write(base64.b64decode(video_data))What it does: Sequentially decodes all QR codes, concatenates their data, and writes the result as the reconstructed video.
-
Place video file in script directory
-
Run the script:
python "Video to QR.py" -
Choose:
[1]Convert to QR codes[2]Export video from QR codes
-
Follow prompts to delete original video or clean up environment.
QR.to.Video.mp4
The warnings you're seeing β like:
WARNING: zbar\decoder\databar.c:1250: <unknown>: Assertion "seg->finder >= 0" failed.β are coming from the pyzbar library, which uses ZBar, a C-based QR/barcode scanner. These warnings typically occur when ZBar fails to recognize a QR code or interprets image data as an invalid code.
These warnings don't immediately crash the script, but they likely indicate that:
- Some QR code images aren't being decoded properly.
- May end up with a corrupted output video, or the script may fail later due to a missing or unreadable chunk.
-
You are using:
QR_VERSION = 40 QR_BOX_SIZE = 10
QR version 40 holds a lot of data β nearly 3KB per code β and becomes visually complex, especially for
pyzbarto decode correctly.β Fix: Reduce
QR_VERSIONto something like 20β30, and increaseQR_BOX_SIZEto 12β15 for better clarity.
-
Saving in PNG is fine, but any post-processing or compression (e.g., if opened and resaved) may affect readability.
β Fix: Ensure the images remain untouched between encode and decode.
pyzbaris sometimes less accurate with large, complex QR codes.- Alternative: Use
opencv-pythonandcv2.QRCodeDetector, which can decode with more robustness.
Hereβs how can improve decoding: (open source contributors)
def decode_qr_image(image):
import cv2
import numpy as np
from pyzbar.pyzbar import decode as pyzbar_decode
try:
# Try pyzbar first
result = pyzbar_decode(image)
if result:
return result[0].data.decode('utf-8')
except Exception:
pass
# Fallback to OpenCV QR detection
img_array = np.array(image.convert('RGB'))
detector = cv2.QRCodeDetector()
data, _, _ = detector.detectAndDecode(img_array)
if data:
return data
raise ValueError("QR decoding failed with both pyzbar and OpenCV.")In your encode_video_to_qr():
# Try reducing version and increasing box size for easier scanning
QR_VERSION = 30 # instead of 40
QR_BOX_SIZE = 12 # bigger boxes = easier decodeQRVideoSlicer is a unique, practical tool built for modern-day versioning and distribution challenges involving large video files. Its focus on interactivity, automation, and data preservation makes it ideal for learning purposes and real-world utility.
- If user want - add passward when Increft & pass must requird to Export.
- add a Output folder for Output videos.
- Fix error handaling.



