-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest_threading.py
More file actions
61 lines (51 loc) · 1.64 KB
/
test_threading.py
File metadata and controls
61 lines (51 loc) · 1.64 KB
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
from ffmpegio import threading
from ffmpegio import ffmpegprocess
from ffmpegio.ffmpegprocess import Popen, run
from tempfile import TemporaryDirectory
from os import path
import re
from pprint import pprint
def test_log_popen():
# with exec({"inputs": [(url, None)], "outputs": [("-", None)], "global_options": None},sp_run=sp.Popen,capture_log=True) as f:
url = "tests/assets/testmulti-1m.mp4"
with TemporaryDirectory() as tmpdir, Popen(
{
"inputs": [(url, {"t": 0.1})],
"outputs": [(path.join(tmpdir, "test.mp4"), None)],
"global_options": None,
},
capture_log=True,
) as proc, threading.LoggerThread(proc.stderr, True) as logger:
logger.index("Output")
pprint(logger.output_stream(0, 0))
if __name__ == "__main__":
url = "tests/assets/testmulti-1m.mp4"
url1 = "tests/assets/testvideo-1m.mp4"
url2 = "tests/assets/testaudio-1m.mp3"
from pprint import pprint
from ffmpegio import ffmpeg, configure
import io
args = {
"inputs": [(url1, None), (url2, None)],
"outputs": [
(
"-",
{
"vframes": 16,
},
)
],
}
use_ya = configure.finalize_media_read_opts(args)
pprint(args)
# create a short example with both audio & video
f = io.BytesIO(ffmpegprocess.run(args).stdout)
reader = threading.AviReaderThread()
reader.start(f, use_ya)
try:
reader.wait()
print(f"thread is running {reader.is_alive()}")
pprint(reader.streams)
pprint(reader.rates)
except:
reader.join()