9 for l in sys.stdin.readlines():
10 if l.startswith('<Metadata>'):
12 elif l.startswith('</Metadata'):
17 def note(k, v, highlight=None):
18 if highlight is not None and highlight(v):
19 print('%20s: %s' % (k, termcolor.colored(v, 'white', 'on_red')));
21 print('%20s: %s' % (k, v))
23 def bool_note(k, v, highlight=None):
24 v = 'yes' if (v is not None and v.text == "1") else 'no'
30 f = raw * dcp_rate / 96000.0
37 return '%s DCP_%02d:%02d:%02d.%02d' % (str(raw).ljust(8), h, m, s, f)
40 def content_time_from_frames(s, r):
49 return '%s Con_%02d:%02d:%02d.%02d' % (str(raw).ljust(8), h, m, s, f)
51 soup = bs4.BeautifulSoup(xml, 'xml')
52 note('Name', soup.Metadata.Name.text)
53 note('Container', soup.Metadata.Container.text)
54 note('J2K bandwidth', soup.Metadata.J2KBandwidth.text, lambda x: int(x) < 20000000 or int(x) > 235000000)
55 note('Video frame rate', soup.Metadata.VideoFrameRate.text, lambda x: int(x) not in [24, 25, 30])
56 dcp_rate = int(soup.Metadata.VideoFrameRate.text)
57 note('Audio channels', soup.Metadata.AudioChannels.text)
58 bool_note('3D', soup.Metadata.ThreeD, lambda x: not x)
59 bool_note('Encrypted', soup.Metadata.ThreeD, lambda x: not x)
60 reel_types = ['single', 'by-video', 'by-length']
61 note('Reel type', reel_types[int(soup.ReelType.text)])
62 for c in soup.Metadata.Playlist.children:
63 if isinstance(c, bs4.element.Tag):
65 note(' Type', c.Type.text)
66 note(' Position', dcp_time(c.Position))
67 note(' Trim start', c.TrimStart.text)
68 note(' Trim end', c.TrimEnd.text)
70 note(' Video rate', c.VideoFrameRate.text)
71 note(' Video length', content_time_from_frames(c.VideoLength, float(c.VideoFrameRate.text)))
73 note(' Audio rate', c.AudioFrameRate.text)
74 bool_note(' Reference video', c.ReferenceVideo, lambda x: not x)
75 bool_note(' Reference audio', c.ReferenceAudio, lambda x: not x)
76 bool_note(' Reference subtitle', c.ReferenceSubtitle, lambda x: not x)