-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest_video.py
102 lines (77 loc) · 3.02 KB
/
test_video.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# -*- coding: utf-8 -*-
import os
from pathlib import Path
from PIL import Image
import iscc_sdk as idk
meta = idk.IsccMeta(
name="Hello",
description="Wörld",
meta="somestring",
creator="The Creator",
license="https://example.com/license",
acquire="https://example.com/buy",
rights="Copyright Notice",
)
def test_video_metadata_extract_mp4(mp4_file):
assert idk.video_meta_extract(mp4_file) == {"name": "Kali by Anokato - Spiral Sessions 2019"}
def test_video_metadata_embed_mp4(mp4_file):
new_file = idk.video_meta_embed(mp4_file, meta)
assert idk.video_meta_extract(new_file) == {
"name": "Hello",
"description": "Wörld",
"meta": "somestring",
"creator": "The Creator",
"license": "https://example.com/license",
"acquire": "https://example.com/buy",
"rights": "Copyright Notice",
}
os.remove(new_file)
def test_video_metadata_extract_mov(mov_file):
assert idk.video_meta_extract(mov_file) == {"name": "Kali by Anokato - Spiral Sessions 2019"}
def test_video_metadata_embed_mov(mov_file):
new_file = idk.video_meta_embed(mov_file, meta)
assert idk.video_meta_extract(new_file) == {
"name": "Hello",
"description": "Wörld",
"meta": "somestring",
"creator": "The Creator",
"license": "https://example.com/license",
"acquire": "https://example.com/buy",
"rights": "Copyright Notice",
}
os.remove(new_file)
def test_video_metadata_escaping(mp4_file):
meta = idk.IsccMeta(
name="Some # Name",
description="Multi\nLine\n\nDescription with ; and other = crazy characters\n",
)
new_file = idk.video_meta_embed(mp4_file, meta)
assert idk.video_meta_extract(new_file) == dict(
name="Some # Name",
description="Multi\nLine\n\nDescription with ; and other = crazy characters",
)
os.remove(new_file)
def test_video_thumbnail(mp4_file):
thumb = idk.video_thumbnail(mp4_file)
assert isinstance(thumb, Image.Image)
def test_video_thumbnail_fail(docx_file):
thumb = idk.video_thumbnail(docx_file)
assert thumb is None
def test_video_mp7sig_extract(mp4_file):
sig = idk.video_mp7sig_extract(mp4_file)
assert sig[-32:].hex() == "9ef43526febb8d3e674975584ad6812ccc144cba28b3e134cd173888449cf51e"
def test_video_features_extract(mp4_file):
features = idk.video_features_extract(mp4_file)
assert features[0][:20] == (0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0)
def test_video_features_extract_store(mp4_file):
idk.sdk_opts.video_store_mp7sig = True
idk.video_features_extract(mp4_file)
assert Path(mp4_file + ".iscc.mp7sig").exists()
idk.sdk_opts.video_store_mp7sig = True
def test_code_video_nometa_nothumb(mp4_file):
idk.sdk_opts.extract_metadata = False
idk.sdk_opts.create_thumbnail = False
meta = idk.code_video(mp4_file)
assert meta.dict() == {"iscc": "ISCC:EMAV4DUD6QORW4X4"}
idk.sdk_opts.extract_metadata = True
idk.sdk_opts.create_thumbnail = True