-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
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)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels