forked from tuffy/python-audio-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdvdainfo
executable file
·129 lines (111 loc) · 4.79 KB
/
dvdainfo
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/usr/bin/python
#Audio Tools, a module and set of tools for manipulating audio data
#Copyright (C) 2007-2012 Brian Langenberger
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import sys
import os.path
import audiotools
import audiotools.text as _
if (__name__ == '__main__'):
parser = audiotools.OptionParser(
usage=_.USAGE_DVDAINFO,
version="Python Audio Tools %s" % (audiotools.VERSION))
parser.add_option('-A', '--audio-ts', action='store', default=None,
type='string', dest='audio_ts', metavar='DIR',
help=_.OPT_AUDIO_TS)
(options, args) = parser.parse_args()
msg = audiotools.Messenger("dvdainfo", options)
if (options.audio_ts is None):
msg.error(_.ERR_NO_AUDIO_TS)
sys.exit(1)
try:
dvda = audiotools.DVDAudio(options.audio_ts)
except audiotools.InvalidDVDA, err:
msg.error(unicode(err))
sys.exit(1)
except OSError, err:
msg.os_error(err)
sys.exit(1)
titleset = dvda[0]
for (title_num, title) in enumerate(titleset):
(sample_rate,
channels,
channel_mask,
bits_per_sample,
stream_type) = title.info()
msg.new_row()
msg.output_column(_.LAB_DVDA_TITLE % (title_num + 1), True)
msg.output_column(_.LAB_DVDA_TRACKS % (len(title.tracks)), True)
msg.output_column(u" : ")
msg.output_column(_.LAB_DVDA_TITLE_INFO %
{"minutes": title.pts_length / 90000 / 60,
"seconds": title.pts_length / 90000 % 60,
"channels": channels,
"rate": audiotools.khz(sample_rate),
"bits": bits_per_sample,
"type": {0xA0: u"PCM",
0xA1: u"MLP"}.get(stream_type,
u"UNKNOWN")})
msg.blank_row()
msg.output_rows()
msg.new_row()
msg.output_column(_.LAB_DVDAINFO_TITLE)
msg.output_column(u" ")
msg.output_column(_.LAB_DVDAINFO_TRACK)
msg.output_column(u" ")
msg.output_column(_.LAB_DVDAINFO_LENGTH)
msg.output_column(u" ")
msg.output_column(_.LAB_DVDAINFO_FILENAME)
msg.output_column(u" ")
msg.output_column(_.LAB_DVDAINFO_STARTSECTOR)
msg.output_column(u" ")
msg.output_column(_.LAB_DVDAINFO_ENDSECTOR)
msg.output_column(u" ")
msg.output_column(_.LAB_DVDAINFO_TICKS)
msg.divider_row([u"-", u" ", u"-", u" ", u"-", u" ", u"-",
u" ", u"-", u" ", u"-", u" ", u"-"])
for (title_num, title) in enumerate(titleset):
for (track_num, track) in enumerate(title.tracks):
for (i, (aob_file,
start_sector,
end_sector)) in enumerate(track.sectors()):
msg.new_row()
if (i == 0):
msg.output_column(unicode(title_num + 1), True)
msg.output_column(u" ")
msg.output_column(unicode(track_num + 1), True)
msg.output_column(u" ")
msg.output_column(_.LAB_TRACK_LENGTH %
(track.pts_length / 90000 / 60,
track.pts_length / 90000 % 60),
True)
else:
msg.output_column(u"")
msg.output_column(u" ")
msg.output_column(u"")
msg.output_column(u" ")
msg.output_column(u"")
msg.output_column(u" ")
msg.output_column(
unicode(audiotools.Filename(os.path.basename(aob_file))),
True)
msg.output_column(u" ")
msg.output_column(unicode(start_sector), True)
msg.output_column(u" ")
msg.output_column(unicode(end_sector - 1), True)
msg.output_column(u" ")
if (i == 0):
msg.output_column(unicode(track.pts_length), True)
else:
msg.output_column(u" ")
msg.output_rows()