Esempio n. 1
0
    def populate_stream_lang_gui(self, event):
        # Grab the current selection in the playlisbox (changes based on click/arrow events).
        sel_playlist_item = self.playlistbox.selection()

        # Get the targeted playlist filename
        target = self.playlistbox.item(sel_playlist_item, 'values')[0]

        # clear the lower (streambox and langbox) of the GUI for "redrawing"
        self.clear_stream_lang_gui()

        # fill streambox with streamclip data
        for _, clip in enumerate(
                self.bdrom.playlistsresults[target].streamclips):
            self.streambox.insert("",
                                  END,
                                  text="StreamFiles",
                                  values=[
                                      clip.name,
                                      BDROM.convertchaptersecs(
                                          timedelta(seconds=clip.length)),
                                      "{:,}".format(clip.bytesize)
                                  ])

        # fill langbox with langbox data
        for _, stream in self.bdrom.playlistsresults[
                target].playliststreams.items():
            self.langbox.insert("",
                                END,
                                text="lang",
                                values=[
                                    stream.PID,
                                    codecnamefunc(stream.streamtype),
                                    isolangfunc(stream.languagecode),
                                    stream.__str__()
                                ])
Esempio n. 2
0
 def __repr__(self):        
    return "GraphicsSubtitleStream | PID: {}, Language Code: {}, Language Name: {}, Codec Type {}".format(self.PID, self.languagecode, isolangfunc(self.languagecode), altcodecfunc(self.streamtype))
Esempio n. 3
0
 def __str__(self):        
    return "PID: {}, Language Code: {}, Language Name: {}, Codec Type {}".format(self.PID, self.languagecode, isolangfunc(self.languagecode), altcodecfunc(self.streamtype))
Esempio n. 4
0
 def __repr__(self):
     return "AudioStream | PID: {}, Language Code: {}, Language Name: {}, Alt Codec: {}, Description {} ".format(self.PID, self.languagecode, isolangfunc(self.languagecode), altcodecfunc(self.streamtype), self.desc)
Esempio n. 5
0
 def __str__(self):
     return "PID: {}, Language Code: {}, Language Name: {}, Alt Codec: {}, Channels: {}, Description {} ".format(self.PID, self.languagecode, isolangfunc(self.languagecode), altcodecfunc(self.streamtype), self.channeldesc(), self.desc)
Esempio n. 6
0
def clipfilescan(cpath, cliplists):
    clipfilescanresults = {}
    for target in cliplists:
        fullpath = os.path.join(cpath, target)
        try:
            f = open(fullpath, 'rb')
            binreadfile = bytes(f.read())
            if (binreadfile[:8] != b"HDMV0100") and (
                    binreadfile[:8] != b"HDMV0200") and (binreadfile[:8] !=
                                                         b"HDMV0300"):
                raise Exception(
                    "Exception: CPLI file {} has an unknown filetype {}!".
                    format(fullpath, binreadfile[:8]))

            allstreams = {}
            allstreams["FILE"] = fullpath

            clipIndex = (binreadfile[12] << 24) + (binreadfile[13] << 16) + (
                binreadfile[14] << 8) + (binreadfile[15])
            cliplength = (binreadfile[clipIndex] << 24) + (
                binreadfile[clipIndex + 1] << 16) + (
                    binreadfile[clipIndex + 2] << 8) + (binreadfile[clipIndex +
                                                                    3])

            # Copy only relevant streams data from CLPI and delete bindata
            clipdata = binreadfile[(clipIndex + 4):]
            del binreadfile

            # Get num of streams and their offset
            streamscount = clipdata[8]
            streamoffset = 10
            streamindex = 0

            while streamindex < streamscount:

                streamPID = ((clipdata[streamoffset] << 8) +
                             clipdata[streamoffset + 1])

                # Moves offset marker to sit on the length of the StreamCodingInfo section
                streamoffset += 2

                streamtype = clipdata[streamoffset + 1]

                if (streamtype == StreamType.MVC_VIDEO):
                    stream = ts_streamtypeclass.Stream()

                elif (streamtype == StreamType.AVC_VIDEO
                      or streamtype == StreamType.MPEG1_VIDEO
                      or streamtype == StreamType.MPEG2_VIDEO
                      or streamtype == StreamType.VC1_VIDEO):

                    # Considering the next section this may be redundant but does make it easier to read
                    videoFormat = (clipdata[streamoffset + 2] >> 4)
                    frameRate = (clipdata[streamoffset + 2] & 0xF)
                    aspectRatio = (clipdata[streamoffset + 3] >> 4)

                    # Setting the values for the instance of Stream class for this loop iteration
                    stream = ts_streamtypeclass.TSVideoStream()
                    stream.videoformat = videoFormat
                    stream.aspectratio = aspectRatio
                    stream.framerate = frameRate

                    # Run this streamtype's specific methods to internally modify some data
                    stream.convertvidformat()
                    stream.convertframerate()

                elif (streamtype == StreamType.AC3_AUDIO
                      or streamtype == StreamType.AC3_PLUS_AUDIO
                      or streamtype == StreamType.AC3_PLUS_SECONDARY_AUDIO
                      or streamtype == StreamType.AC3_TRUE_HD_AUDIO
                      or streamtype == StreamType.DTS_AUDIO
                      or streamtype == StreamType.DTS_HD_AUDIO
                      or streamtype == StreamType.DTS_HD_MASTER_AUDIO
                      or streamtype == StreamType.DTS_HD_SECONDARY_AUDIO
                      or streamtype == StreamType.LPCM_AUDIO
                      or streamtype == StreamType.MPEG1_AUDIO
                      or streamtype == StreamType.MPEG2_AUDIO):

                    # Pull the data into variables
                    languagebytes = clipdata[(streamoffset + 3):(streamoffset +
                                                                 6)]
                    languagecode = languagebytes.decode("ascii")
                    channellayout = (clipdata[streamoffset + 2] >> 4)
                    samplerate = (clipdata[streamoffset + 2] & 0xF)

                    # Saving data into Audiostream.
                    stream = ts_streamtypeclass.TSAudioStream()
                    stream.languagecode = languagecode
                    stream.channellayout = channellayout
                    stream.samplerate = stream.convertsamplerate(samplerate)
                    stream.streamtype = streamtype
                    stream.languagename = isolangfunc(stream.languagecode)

                elif (streamtype == StreamType.INTERACTIVE_GRAPHICS
                      or streamtype == StreamType.PRESENTATION_GRAPHICS):
                    stream = ts_streamtypeclass.TSGraphicsStream()
                    languagebytes = clipdata[(streamoffset + 2):(streamoffset +
                                                                 5)]
                    languagecode = languagebytes.decode("ascii")
                    stream.languagecode = languagecode
                    stream.languagename = isolangfunc(stream.languagecode)

                elif (streamtype == StreamType.SUBTITLE):

                    stream = ts_streamtypeclass.TSTextStream()
                    languagebytes = clipdata[(streamoffset + 3):(streamoffset +
                                                                 6)]
                    languagecode = languagebytes.decode("ascii")
                    stream.languagecode = languagecode
                    stream.languagename = isolangfunc(stream.languagecode)

                if stream != None:
                    stream.PID = streamPID
                    stream.streamtype = streamtype
                    allstreams[streamindex] = stream

                streamindex += 1
                streamoffset += clipdata[streamoffset] + 1
            clipfilescanresults[target] = allstreams

        except (IOError, FileNotFoundError):
            print("Exception: Error Opening File for Reading: ", fullpath)
        finally:
            f.close()
    return clipfilescanresults