当前位置: 首页>>代码示例>>Python>>正文


Python pymediainfo.MediaInfo类代码示例

本文整理汇总了Python中pymediainfo.MediaInfo的典型用法代码示例。如果您正苦于以下问题:Python MediaInfo类的具体用法?Python MediaInfo怎么用?Python MediaInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MediaInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: reset

	def reset(self):

		"""
		desc:
			Initialize/ reset the plug-in.
		"""

		self.file_loaded = False
		self.resizeVideo = u"yes"
		self.duration = u"keypress"
		self.playaudio = u"yes"
		self.sendInfoToEyelink = u"no"
		self.event_handler = u""
		self.event_handler_trigger = u"on keypress"
		self.vlc_event_handler = None

		self.media = None
		self.framerate = 0
		self.frame_duration = 0
		self.startPlaybackTime = 0
		self.playbackStarted = False
		self.hasMediaInfo = False

		#See if MediaInfo functions are available
		try:
			MediaInfo.parse(u"")
			self.hasMediaInfo = True
		except:
			debug.msg( \
				u"MediaInfo CLI not found. Frame info might be unavailable.",
				reason=u"warning")
			self.hasMediaInfo = False
开发者ID:donal-s,项目名称:media_player_vlc,代码行数:32,代码来源:media_player_vlc.py

示例2: reset

    def reset(self):

        """
		desc:
			Initialize/ reset the plug-in.
		"""

        # Experimental variables
        self.var.resizeVideo = u"yes"
        self.var.duration = u"keypress"
        self.var.event_handler = u""
        self.var.event_handler_trigger = u"on keypress"
        self.var.video_src = u""
        self.var.playaudio = u"yes"

        # Internal variables
        self.file_loaded = False
        self.vlc_event_handler = None
        self.media = None
        self.hasMediaInfo = False
        self.process_feedback = True
        # See if MediaInfo functions are available
        try:
            MediaInfo.parse(u"")
            self.hasMediaInfo = True
        except:
            debug.msg(u"MediaInfo CLI not found. Frame info might be unavailable.", reason=u"warning")
            self.hasMediaInfo = False
开发者ID:dschreij,项目名称:media_player_vlc,代码行数:28,代码来源:media_player_vlc.py

示例3: __init__

	def __init__(self, name, experiment, string=None):

		"""
		Constructor. Link to the video can already be specified but this is
		optional

		Arguments:
		name -- the name of the item
		experiment -- the opensesame experiment

		Keyword arguments:
		string -- a definition string for the item (Default=None)
		"""

		# The version of the plug-in
		self.version = 0.10

		self.file_loaded = False
		self.paused = False

		self.item_type = "media_player_vlc"
		self.description = "Plays a video from file"
		self.duration = "keypress"
		self.playaudio = "yes"
		self.sendInfoToEyelink = "no"
		self.event_handler = ""
		self.event_handler_trigger = "on keypress"
		self.vlc_event_handler = None

		self.vlcInstance = vlc.Instance()
		self.player = self.vlcInstance.media_player_new()
		self.media = None
		self.framerate = 0
		self.frame_duration = 0
		self.startPlaybackTime = 0
		self.playbackStarted = False
		self.hasMediaInfo = False
		
		#See if MediaInfo functions are available
		try:
			MediaInfo.parse("")
			self.hasMediaInfo = True
		except:
			debug.msg( \
				"MediaInfo CLI not found. Frame info might be unavailable.",
				reason="warning")
			self.hasMediaInfo = False
			
		# The parent handles the rest of the construction
		item.item.__init__(self, name, experiment, string)
开发者ID:esdalmaijer,项目名称:media_player_vlc,代码行数:50,代码来源:media_player_vlc.py

示例4: get_duration

 def get_duration(self):
     if MediaInfo is not None:
         for track in MediaInfo.parse(self.path).tracks:
             if track.track_type == 'Video':
                 log.debug("Found video track with duration %d" % track.duration)
                 self.duration = track.duration
     return self.duration
开发者ID:pleo1,项目名称:nzbstream,代码行数:7,代码来源:rarfile.py

示例5: set_techmd_values

  def set_techmd_values(self):
    techmd = MediaInfo.parse(self.filepath)

    md_track = None
    for track in techmd.tracks:
      if track.track_type == "General":
        md_track = track

    if not md_track:
      self.raise_AMIFileError('Could not find General track')

    self.base_filename = md_track.file_name
    self.extension = md_track.file_extension
    self.format = md_track.format
    self.size = md_track.file_size

    if md_track.encoded_date:
      self.date_created = parse_date(md_track.encoded_date)
    elif md_track.recorded_date:
      self.date_created = parse_date(md_track.recorded_date)
    elif md_track.file_last_modification_date:
      self.date_created = parse_date(md_track.file_last_modification_date)

    self.duration_milli = md_track.duration
    self.duration_human = parse_duration(self.duration_milli)

    self.audio_codec = md_track.audio_codecs
    if md_track.codecs_video:
      self.video_codec = md_track.codecs_video
开发者ID:NYPL,项目名称:ami-tools,代码行数:29,代码来源:ami_file.py

示例6: get_video_size

def get_video_size(input_file):
    media_info = MediaInfo.parse(input_file)
    for track in media_info.tracks:
        if track.track_type == 'Video':
            #print(str(track.width)+"x"+str(track.height))
            return str(track.width)+":"+str(track.height)
    raise AssertionError("failed to read video info from " + input_file)
开发者ID:dngroup,项目名称:ContentSupplying,代码行数:7,代码来源:msstream_worker.py

示例7: find_file_extension

def find_file_extension(root, file_name):
    ext = ""
    codec = ""
    container = ""
    abs_file_path = os.path.join(root, file_name)
    print "Analysing file ...", abs_file_path
    media_info = MediaInfo.parse(abs_file_path)
    for track in media_info.tracks:
        if track.track_type == 'General':
            container = track.codec_id
        if track.track_type == 'Audio':
            codec = track.codec

    if container is not None:
        container = container.strip()

    if codec is not None:
        codec = codec.strip()

    if container is None:
        if codec in ["MPA2L3", "MPA1L3"]:
            ext = ".mp3"
    elif container == 'M4A':
            ext = ".m4a"

    print "container: {}, codec: {}, ext: {}".format(container, codec, ext)
    return ext
开发者ID:abhimanyuv1,项目名称:audio_tagger,代码行数:27,代码来源:audio_tagger.py

示例8: run

    def run(self):
        uri = urlparse(self.subject[dc.identifier])
        # Resolve absolute paths for command-line system calls
        if uri.scheme == "" or uri.scheme == "file":
            # Remove leading / from /C:\folder\ URIs
            # Don't use platform.system() here, because we don't want to include Cygwin
            if os.name == "nt" and len(uri.path) >= 3  and uri.path[0] == "/" and uri.path[2] == ":":
                filename = os.path.abspath(uri.path[1:])
            else:
                filename = os.path.abspath(uri.path)
        else:
            filename = self.subject[dc.identifier]

        try:
            media_info = MediaInfo.parse(filename)
            tracks = media_info.tracks
        except:
            tracks = []

        video_streams = list()
        audio_streams = list()

        for track in tracks:
            if track.track_type == 'General' and track.duration:
                self.subject.emit("duration", track.duration / 1000.0)
            elif track.track_type == 'Video':
                v = dict()

                if track.frame_rate:
                    v["framerate"] = float(track.frame_rate)
                if track.codec:
                    v["codec"] = track.codec
                if track.height:
                    v["height"] = int(track.height)
                if track.width:
                    v["width"] = int(track.width)

                video_streams.append(v)
            elif track.track_type == "Audio":
                a = dict()

                if track.sampling_rate:
                    a["samplerate"] = int(track.sampling_rate)
                if track.codec:
                    a["codec"] = track.codec
                if track.channel_s:
                    a["channels"] = int(track.channel_s)

                audio_streams.append(a)

        for v in video_streams:
            self.subject.emit("video_stream", v)

        for a in audio_streams:
            self.subject.emit("audio_stream", a)

        if len(video_streams) > 0:
            self.subject.extendClass("item.video")
        elif len(audio_streams) > 0:
            self.subject.extendClass("item.audio")
开发者ID:topfs2,项目名称:heimdall,代码行数:60,代码来源:media_item.py

示例9: parse_metadata

    def parse_metadata(self, path, id_):
        """
        Parse the MP4 header metadata for bitrate information.

        Specifically, retrieve the maximum encoded bitrate for each quality
        level.

        """
        self.player.event('start', 'parsing metadata ' + str(path))
        found = False
        try:
            media_info = MediaInfo.parse(path)
        except OSError:
            self._set_maximum_encoded_bitrate(0, id_)
            self.player.event('error', 'MediaInfo not installed')
            return
        for track in media_info.tracks:
            if track.track_type == 'Video':
                maximum_bitrate = track.maximum_bit_rate
                if maximum_bitrate:
                    self._set_maximum_encoded_bitrate(maximum_bitrate, id_)
                    found = True
                else:
                    self.player.event(
                        'error',
                        'maximum bitrate not found in metadata')
                    self._set_maximum_encoded_bitrate(0, id_)
                    return
        if not found:
            self.player.event('error', 'no video track in metadata')
            self._set_maximum_encoded_bitrate(0, id_)
        self.player.event('stop', 'parsing metadata ' + str(path))
开发者ID:broadbent,项目名称:scootplayer,代码行数:32,代码来源:representations.py

示例10: analysis

def analysis(video):
    mediainfoobject = MediaInfo.parse(str(settings.BASE_DIR) + str(os.path.normpath(video.videofile.url)))
    try:    
        for track in mediainfoobject.tracks:
            if track.track_type == 'General':
                video.format = track.format
                video.filesize = track.file_size
                video.duration = track.duration
            if track.track_type == 'Video':
                video.width = track.width
                video.height = track.height
                video.resolution = str(video.width) + 'x' + str(video.height)
                video.vcodec = track.codec
                video.aspect = track.display_aspect_ratio
                video.framerate = track.frame_rate
                video.colorspace = track.color_space
                video.bitdepth = track.bit_depth
                video.vbitrate = track.bit_rate
            if track.track_type == 'Audio':
                video.acodec = track.format
                video.abitrate = track.bit_rate
                video.asamplingrate = track.asampling_rate
                video.abitdepth = track.bit_depth
                video.channels = track.channel_s
    except:
        return video
开发者ID:MasterGowen,项目名称:moonrain,代码行数:26,代码来源:views.py

示例11: parse_media

 def parse_media(self):
     self.mtime_end = os.path.getmtime(self.file_path)
     if myutil.match_type(self.file_path, ["jpg"]):
         self.media_type = "Image"
     elif myutil.match_type(self.file_path, ["mp4", "mts", "lrv"]):
         self.media_type = "Video"
     elif myutil.match_type(self.file_path, ["wav"]):
         self.media_type = "Audio"
     media_info = MediaInfo.parse(self.file_path)
     for track in media_info.tracks:
         if StreamFile.Debug:
             pprint(track.to_data())
         if track.track_type == "Video":     # some jpg has a video track
             self.video_width = track.width
             self.video_height = track.height
             if track.duration is None:
                 self.duration = -1
             else:
                 self.duration = track.duration
             break
         elif track.track_type == "Audio":
             self.duration = track.duration
             break
         elif track.track_type == "Image":
             self.video_width = track.width
             self.video_height = track.height
             self.duration = -1
             break
     self.calc_mtime_begin()
开发者ID:citwild,项目名称:wfe_website,代码行数:29,代码来源:stream.py

示例12: get_video_info

def get_video_info(file_list, output_filename="output.csv"):
    """Get video info for a file(s)"""
    total_duration = timedelta()
    items = []

    for filename in file_list:
        media_info = MediaInfo.parse(filename)
        media_dict = OrderedDict()
        src_dir, src_file = os.path.split(filename)
        media_dict['filename'] = src_file

        for t in media_info.tracks:
            if t.track_type == 'General':
                media_dict['format'] = t.format
            elif t.track_type == 'Video':
                media_dict['duration'] = timedelta(milliseconds=t.duration)
                media_dict['dimensions'] = "%sx%s" % (t.width, t.height)
                media_dict['video_bitrate'] = t.other_bit_rate[0]
                media_dict['video_framerate'] = t.frame_rate
                total_duration += timedelta(milliseconds=t.duration)

        items.append(media_dict)

    csv_list = []
    if len(items) > 0:
        csv_list.append([key for key, _ in items[0].items()])
        for item in items:
            csv_list.append([v for k, v in item.items()])

        totals = ['TOTALS:', len(items), total_duration]
        csv_list.append(totals)

    with open(os.path.join(src_dir, output_filename), 'w', newline='') as f:
        writer = csv.writer(f)
        writer.writerows(csv_list)
开发者ID:thornomad,项目名称:dotfiles,代码行数:35,代码来源:video.py

示例13: __init__

 def __init__(self, fpath):
     try:
         self.added = now()
         self.finished = 0
         self.fullpath = fpath
         self.fileid = getNewFileID()
         tempMediainfo = MediaInfo.parse(self.fullpath)
         self.mediainfo = {}
         for track in tempMediainfo.tracks:
             if track.track_type not in self.mediainfo:
                 self.mediainfo[track.track_type] = track.to_data()
             else:
                 if track.track_type in ['Audio', 'Subtitle']:
                     if not isinstance(self.mediainfo[track.track_type], list):
                         tempTrack = self.mediainfo[track.track_type]
                         self.mediainfo[track.track_type] = []
                         self.mediainfo[track.track_type].append(tempTrack)
                     
                     self.mediainfo[track.track_type].append(track.to_data())
         
         self.outputfilename = pacvert.CONFIG.OUTPUT_DIRECTORY+'/'+generateOutputFilename(self.fullpath)
         self.createThumbs()
         self.crop = self.analyzeThumbs()
         self.deleteThumbs()
         self.updateStatus(2)
     except Exception as e:
         logger.error(e)            
开发者ID:Sonic-Y3k,项目名称:pacvert,代码行数:27,代码来源:scanner.py

示例14: handle_media

def handle_media(content):
    with tempfile.NamedTemporaryFile() as f:
        f.write(content)
        media = MediaInfo.parse(f.name)

    duration = timedelta(seconds=media.tracks[0].duration // 1000)
    num_tracks = len(media.tracks) - 1
    first_video_track = next((track for track in media.tracks if track.track_type == 'Video'), None)
    first_audio_track = next((track for track in media.tracks if track.track_type == 'Audio'), None)

    info = "\x02Media Info:\x02 {n} track{s}, {duration}, {size}".format(
        size=humanize.naturalsize(media.tracks[0].file_size),
        n=num_tracks,
        s='s' if num_tracks != 1 else '',
        duration=duration
    )

    if first_video_track:
        info += "; {w} x {h} {codec}, {bitrate}bps, {framerate}fps".format(
            codec=first_video_track.format,
            bitrate=humanize.naturalsize(first_video_track.bit_rate, gnu=True).lower(),
            framerate=first_video_track.frame_rate,
            w=first_video_track.width,
            h=first_video_track.height
        )
    if first_audio_track:
        info += "; {ch}ch {codec}, {sr}kHz".format(
            codec=first_audio_track.format,
            ch=first_audio_track.channel_s,
            sr=first_audio_track.sampling_rate // 100 / 10
        )

    return info
开发者ID:gnowxilef,项目名称:kochira,代码行数:33,代码来源:url.py

示例15: un

    def un(pathname):
        # files from the UN.

         # date is in the file name
         # time is in other: time_code_of_first_frame
         # 1672828_DMOICT Open Camps CR7 8AM-12PM 16 JULY 16.mov

        year = "2016"
        month = 'JULY' 
        day = pathname.split(month)[0].split()[-1]

        media_info = MediaInfo.parse(pathname)
        t3=media_info.tracks[3]
        time = t3.time_code_of_first_frame

        dt = "{year}-{month}-{day} {time}".format(
                year=year, month=month, day=day, time=time)

        # start = datetime.datetime.strptime("16 JULY 2016 07:50:00;00", "%d %B %Y %H:%M:%S;00")
        start = datetime.datetime.strptime(dt, "%Y-%B-%d %H:%M:%S;00")
        print( start )

        return start

        # d+_DMOICT...move stuff so it errors if it finds something else
        start_date_re = r".*/" + date_re + ".*/\d+_DMOICT.*\.mov"

        start_date_o =  re.match(start_date_re, pathname)
        dt_parts = start_date_o.groupdict()
        print("date_parts:", dt_parts)

        
        cmd = ['mediainfo', 
                '--Inform=Video;%TimeCode_FirstFrame%', 
                pathname ]
        p = subprocess.Popen(
                cmd,
                stdout = subprocess.PIPE )
        stdout = p.stdout.read()
        # '07:50:00:00\n'

        # time_code = stdout.strip().split(':')

        start_time_re = time_re + rb":\d\d\n"

        start_time_o =  re.match(start_time_re, stdout)
        start_time_d = start_time_o.groupdict()
        print("start_time_d:",start_time_d)

        dt_parts.update(start_time_d)
        pprint.pprint(dt_parts)

        dt_parts = {k:int(v) for k,v in list(dt_parts.items())}
        print(dt_parts)

        start=datetime.datetime( **dt_parts )
        print(start)

        return start
开发者ID:stefanor,项目名称:veyepar,代码行数:59,代码来源:tsraw.py


注:本文中的pymediainfo.MediaInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。