This is an implementation of video steganography based on DCT (Discrete Cosine Transform) coefficients, object motion analysis, and psychovisual thresholds. The implementation is inspired by the research paper "Video steganography based on DCT psychovisual and object motion" by Muhammad Fuad and Ferda Ernawan.
- DCT-based embedding: Uses middle frequency DCT coefficients (4, 5, 6, 7, 10, 11) to hide data
- Motion detection: Embeds data in regions with motion to improve imperceptibility
- Psychovisual thresholds: Uses human visual perception models to determine optimal thresholds
- Strong error correction: Implements bit repetition (5x) for robust message extraction
- Quality metrics: Calculates PSNR (Peak Signal-to-Noise Ratio) to measure video quality
- Multiple formats support: Supports optimized embedding for various codecs and formats
- MPEG-4 resistance: Optimized for resilience against video compression
opencv-python
numpy
scipy
matplotlib
tabulate
Install the requirements using:
pip install opencv-python numpy scipy matplotlib tabulate
- dct_utils.py: Utility functions for DCT operations, motion detection, and block selection
- embed.py: Script for embedding a secret message into a video
- extract.py: Script for extracting the hidden message from a steganographic video
- compare_formats.py: Script for comparing different video format results
- FORMAT_TESTS.md: Detailed analysis of our format comparison tests
python embed.py input_video.mp4 "Your secret message" output_video.mp4 locations.pkl [--repetition 5] [--format FORMAT]Arguments:
input_video.mp4: Path to the input video file"Your secret message": The secret message to embedoutput_video.mp4: Path to save the steganographic videolocations.pkl: File to save embedding locations--repetition: Optional repetition factor for error correction (default: 5)--format: Output format preset (choices: default, lossless, raw, high_quality)
- default: Standard MP4 format (most compatible but may lose data with compression)
- lossless: Uses lossless AVI codecs for best data preservation
- raw: Uses uncompressed YUV formats for maximum data integrity
- high_quality: Uses high-quality Motion JPEG for balance of quality and size
python extract.py steganographic_video.mp4 locations.pkl [--repetition 5]Arguments:
steganographic_video.mp4: Path to the steganographic videolocations.pkl: File containing embedding locations--repetition: Optional repetition factor for error correction (default: 5)
python compare_formats.py original.mp4 stego_file1.mp4 stego_file2.avi [other_stego_files...]Arguments:
original.mp4: Path to the original video filestego_file1.mp4 stego_file2.avi...: Paths to steganographic videos to compare
We conducted extensive tests with different video formats to find the optimal balance between file size, visual quality, and steganographic robustness. Our findings include:
- MP4 (default): Smallest files (5.2MB), best bit error rate (1.79%), PSNR: 38.56 dB
- High Quality AVI (MJPG): Moderate size (31MB), good bit error rate (3.24%), PSNR: 41.31 dB
- Lossless AVI (HFYU): Very large files (347MB), highest PSNR (76.62 dB), but higher bit error rate (4.35%)
For detailed test results and analysis, see FORMAT_TESTS.md.
For testing, we used the "Big Buck Bunny" sample video (SampleVideo_1280x720_2mb.mp4) which is commonly used for video processing tests. The original video can be found at: https://www.sample-videos.com/video321/mp4/720/big_buck_bunny_720p_2mb.mp4
- Motion Detection: The algorithm analyzes frame differences to detect regions with motion.
- Block Selection: 8x8 pixel blocks are selected preferentially in motion areas, as changes in these regions are less noticeable to human perception.
- DCT Transformation: Each selected block is transformed using DCT.
- Coefficient Modification: Specific middle frequency DCT coefficients are modified to embed bits from the secret message.
- Psychovisual Thresholds: The modification amounts are determined based on human visual perception models.
- Error Correction: Each bit is repeated multiple times for robustness against compression and noise.
- Quality Analysis: The algorithm calculates PSNR to measure the quality impact of embedding.
The implementation generates several analysis files:
quality_analysis/: Contains PSNR values and visual comparisons of original vs modified framesextraction_analysis/: Contains information about extracted bits and DCT coefficientsoriginal_binary.txtandextracted_binary.txt: For comparing original and extracted bit patternscomparison/: Frame-by-frame comparisons of different video formats (when using compare_formats.py)
- PSNR (Peak Signal-to-Noise Ratio): Measures the quality difference between original and steganographic video
- NC (Normalized Correlation): Measures the correlation between original and extracted message bits
- Bit Error Rate: Percentage of incorrectly extracted bits
- Processing Speed: Frames per second for embedding and extraction
- DCT Processing Time: Time spent on DCT/IDCT operations
| Format | Advantage | Disadvantage | Best Use Case |
|---|---|---|---|
| MP4 (default) | Smallest file size, Most compatible | Higher data loss due to compression | For casual use where compatibility is prioritized |
| Lossless AVI | No data loss from compression | Large file size | For maximum message integrity |
| Raw YUV | Perfect message preservation | Very large file size | For critical data where size isn't a concern |
| High Quality MJPG | Good compromise of quality and size | Less compatible than MP4 | For general purpose steganography with good quality |
For detailed performance comparison, run the performance_test.py script.
- Works best with uncompressed or lightly compressed video formats
- Performance may vary depending on video content and motion characteristics
- Large messages require videos with sufficient frames and motion
- Resistance to attacks other than compression is not guaranteed
- GPU acceleration requires NVIDIA GPU with CUDA support
- Implement more advanced error correction codes (e.g., Reed-Solomon)
- Add support for more codecs and container formats
- Integrate with deep learning models for better motion detection
- Implement adaptive block selection based on content complexity
- Add support for GPU
- Original research paper: Video Steganography Based on DCT Psychovisual Properties