Example #1
0
    def initMedia(self):
        "Init media by analyzing the MPD and the media files."
        for adaptation_set in self.mpdProcessor.get_adaptation_sets():
            content_type = adaptation_set.content_type
            if content_type is None:
                print "No contentType for adaptation set"
                sys.exit(1)
            if self.as_data.has_key(content_type):
                raise DashAnalyzerError(
                    "Multiple adaptation sets for contentType " + content_type)
            as_data = {'as': adaptation_set, 'reps': []}
            as_data[
                'presentationDurationInS'] = self.mpdProcessor.media_presentation_duration_in_s
            self.as_data[content_type] = as_data
            for rep in adaptation_set.representations:
                rep_data = {'representation': rep, 'id': rep.rep_id}
                as_data['reps'].append(rep_data)
                initPath = rep.initialization_path
                rep_data['relInitPath'] = initPath
                rep_data['absInitPath'] = os.path.join(self.base_path,
                                                       initPath)
                init_filter = initsegmentfilter.InitFilter(
                    rep_data['absInitPath'])
                init_filter.filter()
                rep_data['trackID'] = init_filter.track_id
                print "%s trackID = %d" % (content_type, rep_data['trackID'])
                rep_data['relMediaPath'] = rep.get_media_path()
                rep_data['absMediaPath'] = os.path.join(
                    self.base_path, rep.get_media_path())
                rep_data['default_sample_duration'] = \
                    init_filter.default_sample_duration

                self.getSegmentRange(rep_data)
                track_timescale = init_filter.track_timescale
                if not as_data.has_key('track_timescale'):
                    as_data['track_timescale'] = track_timescale
                elif track_timescale != as_data['track_timescale']:
                    raise DashAnalyzerError(
                        "Timescales not consistent between %s tracks" %
                        content_type)
                if self.verbose:
                    print "%s data: " % content_type
                    for (k, v) in rep_data.items():
                        print "  %s=%s" % (k, v)
 def setUp(self):
     fileName = join(CONTENT_ROOT, "testpic/A1/init.mp4")
     self.f = initsegmentfilter.InitFilter(fileName)
     self.f.filter()