How happy95059/video_combine works
Project Type and Purpose
• Project type: Open-source CLI tool (Python) for image/video steganography.
• Purpose: “Combine” one file (B) into another (A) to produce C (which visually resembles B), and generate a “Trans” module (key) that allows lossless back-and-forth conversion between C and C̄.
File Structure
• Top-level:
• code/ – Python scripts (example.py, img_combine.py, video_combine.py, 影片測試.py)
• data/ – sample inputs/outputs (.mp4, .avi)
• README.md, LICENSE, .gitignore
• No separate frontend/backend—this is a command-line utility.
• Key scripts:
• img_combine.py – orchestrates image bit-plane merge & extract
• video_combine.py – wraps video I/O around the same bit-plane logic
• example.py / 影片測試.py – usage examples/tests
README for Architectural Insights
• Core operations: Combine(A, B) → C ; Trans(C) → C̄
• Underlying mechanism: breakdown into bit planes, three methods of interleaving/compressing bit-planes.
• Dependencies: Uses FFV1 (via FFmpeg) for lossless AVI encoding; OpenCV or similar for reading/writing frames.
Main Components
a. Entry Point (CLI scripts)
• img_combine.py
• video_combine.py
• example.py / test script
b. File I/O Layer
• Image I/O (JPEG, PNG → NumPy arrays)
• Video I/O (MP4 → frames → AVI via FFV1)
c. Steganography Core
• Bit-Plane Extractor
• Method Selector (method1, method2, method3)
• Bit-Plane Merger (Combine logic)
• Compressor/Decompressor for X1, X2 planes
d. Trans (Converter/Key) Module
• Stores transformation rules (e.g., which bit-planes or shuffle maps)
• Used to invert C → original B or A
e. Output Layer
• Writes combined media (C) to data/
• Writes “trans” key/config file
Relationships & Data Flow
1. User invokes CLI script → passes paths for A and B.
2. File I/O layer reads A and B → delivers raw frames or pixel arrays.
3. Steganography Core:
• Extracts bit planes from A & B
• Depending on chosen method, merges them into new bit planes → forms C
• Generates Trans key (compress/shuffle maps)
4. Output Layer writes:
• C (as AVI or image)
• Trans key/config
5. For Trans operation: CLI loads C + Trans key → Steganography Core reconstructs original B (or A)
Architectural Patterns & Principles
• Separation of Concerns: I/O, Core Logic, CLI/Examples
• Plug-in–style methods: easily add new bit-plane combination methods
• Data flow is strictly linear/streaming: frame → bit-plane → merge → output
Essential Elements
• Version info or key config file format as a note off to the side
• Clearly demarcates each layer of your steganography tool
• Illustrates the three combination methods as plug-in modules
• Highlights how “Combine” and “Trans” operations share the same core logic
• Allows new contributors to quickly see where to extend or modify behavior
• Shows dependencies on external tools (FFmpeg) and libraries (OpenCV)