summaryrefslogtreecommitdiff
path: root/hacks/stress.py
blob: 34fe17b0774c5e63c8033aeaafcffc44df79cc87 (plain)
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
#!/usr/bin/python3

import random
import subprocess

def make_seeks(dcp, output, seeks):
    with open(output, 'w') as f:
        # Open the DCP and start it playing
        print("O %s" % dcp, file=f)
        print("P", file=f)
        for i in range(seeks):
            # Wait a bit
            print("W %d" % random.randint(500, 60000), file=f)
	    # Seek
            print("K %d" % random.randint(0, 4095), file=f)
	    # Make sure we're still playing
            print("P", file=f)
        print("S", file=f)

def make_repeated_play(dcp, output, plays):
    length_parts = subprocess.check_output(['dcpinfo', '-o', 'total-time', dcp]).decode('utf-8').split(' ')[1].split(':')
    # Hackily ignore frames here
    length = int(length_parts[0]) * 3600 + int(length_parts[1]) * 60 + int(length_parts[2])
    with open(output, 'w') as f:
        for i in range(0, plays):
            print("O %s" % dcp, file=f)
            print("P", file=f)
            print("W %d" % (length * 1000), file=f)
            print("S", file=f)

make_seeks("/home/carl/DCP/Examples/BohemianRhapsody_TLR-7_S_DE-XX_DE_51_2K_TCFG_20180514_TM_IOP_OV/", "boho_seek", 64)
make_repeated_play("/home/carl/DCP/Examples/BohemianRhapsody_TLR-7_S_DE-XX_DE_51_2K_TCFG_20180514_TM_IOP_OV/", "boho_long", 1000)