README
Video Watermarking with DCT
This project provides a simple way to embed and extract watermarks from video frames using the Discrete Cosine Transform (DCT). The watermark image is embedded in the luminance component (Y) of the YUV color space of each video frame.
Requirements
To install the required packages, use the following command:
pip install -r requirements.txt
Contents of requirements.txt:
opencv-python
Pillow
scipy
Usage
Embedding a Watermark in a Video
To embed a watermark in a video, use the embed_watermark_to_video function. This function takes the input video path, output video path, watermark image path, duration in seconds, and frames per second (fps) as arguments.
Example:
embed_watermark_to_video('input_video.mp4', 'output_video_with_watermark.mp4', 'watermark.png', duration=10, fps=30)
Extracting a Watermark from a Video
To extract a watermark from a video, use the extract_watermark_from_video function. This function takes the output video path, the prefix for the directory where extracted images will be saved, and the duration in seconds as arguments.
Example:
extract_watermark_from_video('output_video_with_watermark.mp4', prefix='result/post_compression', duration=10)
Functions
load_image(image_path, size=(100, 100))
Loads an image and resizes it to the specified size.
embed_watermark_to_frame(frame, img)
Embeds a watermark image into a video frame using DCT.
extract_watermark_from_frame(frame, img_size=(100, 100))
Extracts the embedded watermark image from a video frame using DCT.
video_to_frames(video_path, duration=10, fps=30)
Splits a video into frames for the specified duration and frames per second (fps).
frames_to_video(frames, output_path, fps, size)
Combines frames into a video with the specified frames per second (fps) and output size.
save_images(images, prefix='result/pre_compression')
Saves images to the specified directory with a given prefix.
embed_watermark_to_video(input_video_path, output_video_path, watermark_path, duration=10, fps=30)
Embeds a watermark into a video for the specified duration and frames per second (fps).
extract_watermark_from_video(output_video_path, prefix='compression', duration=10)
Extracts the watermark from a video for the specified duration and saves the extracted images to the specified directory.
Example Workflow
-
Embed a watermark into a video:
embed_watermark_to_video('input_video.mp4', 'output_video_with_watermark.mp4', 'watermark.png', duration=10, fps=30)
-
Extract the watermark from the video:
extract_watermark_from_video('output_video_with_watermark.mp4', prefix='result/post_compression', duration=10)
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Acknowledgments
Feel free to customize this README further based on your specific needs and usage of the project.
Release files for video-invisible-watermark 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| video_invisible_watermark-0.1.2.tar.gz | 4.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| video_invisible_watermark-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.0 kB
Release files / video_invisible_watermark-0.1.2.tar.gz
| Download URL | video_invisible_watermark-0.1.2.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f5cb594b0894538b583b741d764e758d6c53951c92d797d3ce3ddad3520e9d30
|
|
BLAKE2b-256 checksum How to use checksums |
fe455c0407894f0db54718f825d7f3667ad0b53555b23741b29befdb74952d92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.11.4
|
Release files / video_invisible_watermark-0.1.2-py3-none-any.whl
| Download URL | video_invisible_watermark-0.1.2-py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
78414fc7f83a903e5a3bed64577b97bc8e69b836978a1f13c9c61660b0d6ec5b
|
|
BLAKE2b-256 checksum How to use checksums |
93539b2412cbfbfc0eb79467a94ed3c1f1a063cf2129b3994060d9455bffd450
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.11.4
|