Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Result is not expected #7

Open
zhlongfj opened this issue Oct 21, 2024 · 0 comments
Open

Result is not expected #7

zhlongfj opened this issue Oct 21, 2024 · 0 comments

Comments

@zhlongfj
Copy link

zhlongfj commented Oct 21, 2024

import blind_video_watermark as bvw
from datetime import datetime

import cv2

def get_frame_count(video_path):
cap = cv2.VideoCapture(video_path)
if not cap.isOpened():
print("Error: Could not open video.")
return 0

frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
cap.release()
return frame_count

if name == "main":
# 获取当前日期
current_date = datetime.now().strftime("%Y%m%d") # 格式化为"YYYYMMDD"

# Parameters
keys = [10, 11, 12, 13]
seq = current_date  # 使用当前日期作为水印
frag_length = 1
video_path = "videos/bbb-short.mp4"
output_path = "output/output.mp4"

# Example: Generate watermarks for each frame
num_frames = get_frame_count(video_path)
print(f"Total frames: {num_frames}")

seq = "20231005"  # 当前日期

# Extend the sequence to match the number of frames
wms = [seq[i % len(seq)] for i in range(num_frames)]  # 简单循环生成

print("wms: ", wms)
# Pass `wms` to the embed function
bvw.DtcwtKeyEncoder().embed_video_async(keys, wms, frag_length, video_path, output_path, threads=8)

The result is "2023" not "20231005" When I decode with the codes below:

import blind_video_watermark as bvw

if name == "main":
# Parameters for decoding
keys = [10, 11, 12, 13]
video_path = "output/output.mp4"
frag_length = 1

# Create a decoder instance
decoder = bvw.DtcwtKeyDecoder()

# Detect the watermark sequence
detected_seq = decoder.detect_video_async(keys, frag_length, video_path, threads=12)

# 输出检测到的水印信息
print("Detected watermark:", detected_seq)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant