Missing library from test link list.
[dcpomatic.git] / hacks / stress.py
1 #!/usr/bin/python3
2
3 import random
4 import subprocess
5
6 def make_seeks(dcp, output, seeks):
7     with open(output, 'w') as f:
8         # Open the DCP and start it playing
9         print("O %s" % dcp, file=f)
10         print("P", file=f)
11         for i in range(seeks):
12             # Wait a bit
13             print("W %d" % random.randint(500, 60000), file=f)
14             # Seek
15             print("K %d" % random.randint(0, 4095), file=f)
16             # Make sure we're still playing
17             print("P", file=f)
18         print("S", file=f)
19
20 def make_repeated_play(dcp, output, plays):
21     length_parts = subprocess.check_output(['dcpinfo', '-o', 'total-time', dcp]).decode('utf-8').split(' ')[1].split(':')
22     # Hackily ignore frames here
23     length = int(length_parts[0]) * 3600 + int(length_parts[1]) * 60 + int(length_parts[2])
24     with open(output, 'w') as f:
25         for i in range(0, plays):
26             print("O %s" % dcp, file=f)
27             print("P", file=f)
28             print("W %d" % (length * 1000), file=f)
29             print("S", file=f)
30
31 make_seeks("/home/carl/DCP/Examples/BohemianRhapsody_TLR-7_S_DE-XX_DE_51_2K_TCFG_20180514_TM_IOP_OV/", "boho_seek", 64)
32 make_repeated_play("/home/carl/DCP/Examples/BohemianRhapsody_TLR-7_S_DE-XX_DE_51_2K_TCFG_20180514_TM_IOP_OV/", "boho_long", 1000)
33
34
35