QVid - File to Video Encoder & Decoder - View Demo
- Read the file as binary.
- Convert the binary to 2-bit binary.
- There will be 4 possible values.
- Assign a corresponding color to each value.
- Paint into a 20x20 block on a canvas.
- Create some frames.
- Use client-side FFmpeg to convert the frames into a video.
- Done.
- Use client-side FFmpeg to convert the video into frames.
- Read the frames.
- Map each corresponding color to its value.
- Convert 2-bit binary back to binary.
- Done.
Each frame contains the 4 colors used in the frame in sequence in first position. This way, theoretically, even if the video gets color-graded, the file can still be decoded by comparing the initial colors of each frame.
A black color is used to separate metadata and data. It is also automatically inserted at the end of a frame if that frame is not full.
export const BIT_MAP_LETTERTOBIT = {
a: "00",
b: "01",
c: "10",
d: "11",
};
export const SPLITTER_LETTER = "e";
// 5 unique contrast colors except white and black
export const COLOR_MAP = {
a: "#FF0000", // Red
b: "#00FF00", // Green
c: "#0000FF", // Blue
d: "#FFFFFF", // White
e: "#000000", // Black
};