source: trunk/src/testing/bin/fileServer/misc/mmpython/disc/vcdinfo.py @ 4

Revision 4, 3.8 KB checked in by ajaworski, 13 years ago (diff)

Added modified SAGE sources

Line 
1#if 0 /*
2# -----------------------------------------------------------------------
3# vcdinfo.py - parse vcd track informations
4# -----------------------------------------------------------------------
5# $Id: vcdinfo.py,v 1.8 2004/06/25 13:20:35 dischi Exp $
6#
7# $Log: vcdinfo.py,v $
8# Revision 1.8  2004/06/25 13:20:35  dischi
9# FreeBSD patches
10#
11# Revision 1.7  2003/06/30 13:17:19  the_krow
12# o Refactored mediainfo into factory, synchronizedobject
13# o Parsers now register directly at mmpython not at mmpython.mediainfo
14# o use mmpython.Factory() instead of mmpython.mediainfo.get_singleton()
15# o Bugfix in PNG parser
16# o Renamed disc.AudioInfo into disc.AudioDiscInfo
17# o Renamed disc.DataInfo into disc.DataDiscInfo
18#
19# Revision 1.6  2003/06/10 22:11:36  dischi
20# some fixes
21#
22# Revision 1.5  2003/06/09 12:47:53  dischi
23# more track info
24#
25#
26# -----------------------------------------------------------------------
27# Copyright (C) 2003 Thomas Schueppel, Dirk Meyer
28#
29# This program is free software; you can redistribute it and/or modify
30# it under the terms of the GNU General Public License as published by
31# the Free Software Foundation; either version 2 of the License, or
32# (at your option) any later version.
33#
34# This program is distributed in the hope that it will be useful, but
35# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
36# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
37# Public License for more details.
38#
39# You should have received a copy of the GNU General Public License along
40# with this program; if not, write to the Free Software Foundation, Inc.,
41# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
42#
43# ----------------------------------------------------------------------- */
44#endif
45
46import mmpython
47from mmpython import mediainfo
48from discinfo import DiscInfo
49import cdrom
50
51class VCDInfo(DiscInfo):
52    def __init__(self,device):
53        DiscInfo.__init__(self)
54        self.context = 'video'
55        self.offset = 0
56        self.valid = self.isDisc(device)
57        self.mime = 'video/vcd'
58        self.type = 'CD'       
59        self.subtype = 'video'
60
61    def isDisc(self, device):
62        type = None
63        if DiscInfo.isDisc(self, device) != 2:
64            return 0
65       
66        # brute force reading of the device to find out if it is a VCD
67        f = open(device,'rb')
68        f.seek(32768, 0)
69        buffer = f.read(60000)
70        f.close()
71
72        if buffer.find('SVCD') > 0 and buffer.find('TRACKS.SVD') > 0 and \
73               buffer.find('ENTRIES.SVD') > 0:
74            type = 'SVCD'
75
76        elif buffer.find('INFO.VCD') > 0 and buffer.find('ENTRIES.VCD') > 0:
77            type = 'VCD'
78
79        else:
80            return 0
81
82        # read the tracks to generate the title list
83        device = open(device)
84        (first, last) = cdrom.toc_header(device)
85
86        lmin = 0
87        lsec = 0
88
89        num = 0
90        for i in range(first, last + 2):
91            if i == last + 1:
92                min, sec, frames = cdrom.leadout(device)
93            else:
94                min, sec, frames = cdrom.toc_entry(device, i)
95            if num:
96                vi = mediainfo.VideoInfo()
97                # XXX add more static information here, it's also possible
98                # XXX to scan for more informations like fps
99                # XXX Settings to MPEG1/2 is a wild guess, maybe the track
100                # XXX isn't playable at all (e.g. the menu)
101                if type == 'VCD':
102                    vi.codec = 'MPEG1'
103                else:
104                    vi.codec = 'MPEG2'
105                vi.length = (min-lmin) * 60 + (sec-lsec)
106                self.tracks.append(vi)
107            num += 1
108            lmin, lsec = min, sec
109        device.close()
110        return 1
111
112   
113mmpython.registertype( 'video/vcd', mediainfo.EXTENSION_DEVICE, mediainfo.TYPE_AV, VCDInfo )
Note: See TracBrowser for help on using the repository browser.