vidformer 0.1.0__tar.gz → 0.2.0__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: vidformer
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.2.0
|
4
4
|
Summary: A Python library for creating and viewing videos with vidformer.
|
5
5
|
Author-email: Dominik Winecki <dominikwinecki@gmail.com>
|
6
6
|
Requires-Python: >=3.8
|
@@ -13,3 +13,10 @@ Requires-Dist: numpy
|
|
13
13
|
|
14
14
|
# vidformer-py
|
15
15
|
|
16
|
+
## Publish
|
17
|
+
|
18
|
+
```bash
|
19
|
+
export FLIT_USERNAME='__token__' FLIT_PASSWORD='<token>'
|
20
|
+
flit publish
|
21
|
+
```
|
22
|
+
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"""A Python library for creating and viewing videos with vidformer."""
|
2
2
|
|
3
|
-
__version__ = "0.
|
3
|
+
__version__ = "0.2.0"
|
4
4
|
|
5
5
|
import subprocess
|
6
6
|
from fractions import Fraction
|
@@ -13,6 +13,8 @@ import sys
|
|
13
13
|
import multiprocessing
|
14
14
|
import uuid
|
15
15
|
import threading
|
16
|
+
import gzip
|
17
|
+
import base64
|
16
18
|
|
17
19
|
import requests
|
18
20
|
import msgpack
|
@@ -80,10 +82,10 @@ class Spec:
|
|
80
82
|
|
81
83
|
from IPython.display import HTML
|
82
84
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
85
|
+
spec, sources, filters = self._to_json_spec()
|
86
|
+
spec_json_bytes = json.dumps(spec).encode("utf-8")
|
87
|
+
spec_obj_json_gzip = gzip.compress(spec_json_bytes, compresslevel=1)
|
88
|
+
spec_obj_json_gzip_b64 = base64.b64encode(spec_obj_json_gzip).decode("utf-8")
|
87
89
|
|
88
90
|
sources = [
|
89
91
|
{
|
@@ -103,14 +105,11 @@ class Spec:
|
|
103
105
|
}
|
104
106
|
arrays = []
|
105
107
|
|
106
|
-
print("Sending to server")
|
107
|
-
resp = server._new(
|
108
|
+
print(f"Sending to server. Spec is {len(spec_obj_json_gzip_b64)} bytes")
|
109
|
+
resp = server._new(spec_obj_json_gzip_b64, sources, filters, arrays, self._fmt)
|
108
110
|
hls_video_url = resp["stream_url"]
|
109
111
|
namespace = resp["namespace"]
|
110
112
|
|
111
|
-
if not keep_spec:
|
112
|
-
os.remove(spec_pth)
|
113
|
-
|
114
113
|
hls_js_url = server.hls_js_url()
|
115
114
|
|
116
115
|
# We add a namespace to the video element to avoid conflicts with other videos
|
@@ -140,13 +139,19 @@ class Spec:
|
|
140
139
|
"""
|
141
140
|
return HTML(data=html_code)
|
142
141
|
|
143
|
-
def save(self, server, pth, keep_spec=False):
|
142
|
+
def save(self, server, pth, keep_spec=False, encoder=None, encoder_opts=None):
|
144
143
|
"""Save the video to a file."""
|
145
144
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
145
|
+
assert encoder is None or type(encoder) == str
|
146
|
+
assert encoder_opts is None or type(encoder_opts) == dict
|
147
|
+
if encoder_opts is not None:
|
148
|
+
for k, v in encoder_opts:
|
149
|
+
assert type(k) == str and type(v) == str
|
150
|
+
|
151
|
+
spec, sources, filters = self._to_json_spec()
|
152
|
+
spec_json_bytes = json.dumps(spec).encode("utf-8")
|
153
|
+
spec_obj_json_gzip = gzip.compress(spec_json_bytes, compresslevel=1)
|
154
|
+
spec_obj_json_gzip_b64 = base64.b64encode(spec_obj_json_gzip).decode("utf-8")
|
150
155
|
|
151
156
|
sources = [
|
152
157
|
{
|
@@ -166,10 +171,16 @@ class Spec:
|
|
166
171
|
}
|
167
172
|
arrays = []
|
168
173
|
|
169
|
-
resp = server._export(
|
170
|
-
|
171
|
-
|
172
|
-
|
174
|
+
resp = server._export(
|
175
|
+
pth,
|
176
|
+
spec_obj_json_gzip_b64,
|
177
|
+
sources,
|
178
|
+
filters,
|
179
|
+
arrays,
|
180
|
+
self._fmt,
|
181
|
+
encoder,
|
182
|
+
encoder_opts,
|
183
|
+
)
|
173
184
|
|
174
185
|
return resp
|
175
186
|
|
@@ -245,7 +256,7 @@ class Spec:
|
|
245
256
|
out["dve2_create_spec"] = end_t - start_t
|
246
257
|
|
247
258
|
start = time.time()
|
248
|
-
resp = server._export(pth, sources, filters, arrays, self._fmt)
|
259
|
+
resp = server._export(pth, sources, filters, arrays, self._fmt, None, None)
|
249
260
|
end = time.time()
|
250
261
|
out["dve2_exec"] = end - start
|
251
262
|
return out
|
@@ -310,9 +321,9 @@ class YrdenServer:
|
|
310
321
|
|
311
322
|
return r.json()
|
312
323
|
|
313
|
-
def _export(self, pth,
|
324
|
+
def _export(self, pth, spec, sources, filters, arrays, fmt, encoder, encoder_opts):
|
314
325
|
req = {
|
315
|
-
"spec":
|
326
|
+
"spec": spec,
|
316
327
|
"sources": sources,
|
317
328
|
"filters": filters,
|
318
329
|
"arrays": arrays,
|
@@ -320,6 +331,8 @@ class YrdenServer:
|
|
320
331
|
"height": fmt["height"],
|
321
332
|
"pix_fmt": fmt["pix_fmt"],
|
322
333
|
"output_path": pth,
|
334
|
+
"encoder": encoder,
|
335
|
+
"encoder_opts": encoder_opts,
|
323
336
|
}
|
324
337
|
|
325
338
|
r = requests.post(f"http://{self._domain}:{self._port}/export", json=req)
|
vidformer-0.1.0/README.md
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
# vidformer-py
|
File without changes
|