Missed update to private test repo version.
[dcpomatic.git] / hacks / check_packets.py
1 #!/usr/bin/python
2
3 import subprocess
4 import shlex
5 import sys
6
7 last_video_pts = None
8
9 def handle(frame):
10     global last_video_pts
11     if frame['media_type'] == 'video':
12         if last_video_pts is not None and frame['pkt_pts_time'] <= last_video_pts:
13             print 'Out of order video frame %f is ahead of %f' % (frame['pkt_pts_time'], last_video_pts)
14         else:
15             print 'OK frame %f' % frame['pkt_pts_time']
16         last_video_pts = frame['pkt_pts_time']
17
18 p = subprocess.Popen(shlex.split('ffprobe -show_frames %s' % sys.argv[1]), stdin=None, stdout=subprocess.PIPE)
19 frame = dict()
20 while True:
21     l = p.stdout.readline()
22     if l == '':
23         break
24
25     l = l.strip()
26
27     if l == '[/FRAME]':
28         handle(frame)
29         frame = dict()
30     elif l != '[FRAME]' and l != '[SIDE_DATA]' and l != '[/SIDE_DATA]':
31         s = l.split('=')
32         if s[0] == 'pkt_pts_time':
33             frame[s[0]] = float(s[1])
34         else:
35             frame[s[0]] = s[1]