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


Python Video.reEncode方法代码示例

本文整理汇总了Python中video.Video.reEncode方法的典型用法代码示例。如果您正苦于以下问题:Python Video.reEncode方法的具体用法?Python Video.reEncode怎么用?Python Video.reEncode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在video.Video的用法示例。


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

示例1: VideoGUI

# 需要导入模块: from video import Video [as 别名]
# 或者: from video.Video import reEncode [as 别名]
class VideoGUI(object):
    """
    class interface that manages the GUI using Glade-2

    #This should be a view in the MVC design pattern
    """
    def __init__(self, inFile):
        self.filename = inFile
        self.rotation = 0
        self.title = u""
        self.keywords = u""
        logger.info("Initialization of the windowed graphical interface ...")
        self.xml = GTKglade.XML(unifiedglade, root="videoWindow")
        self.xml.get_widget("logo").set_from_pixbuf(gtk.gdk.pixbuf_new_from_file(os.path.join(installdir, "gnome_mplayer_logo.png")))
        self.xml.get_widget("videoWindow").show_now()
        hbox1 = self.xml.get_widget("hbox1")
        self.mplayer = PyGtkMplayer()
        hbox1.pack2(self.mplayer)
#        hbox1.pack_end(self.mplayer)
        hbox1.show_all()
        self.videoWid = long(self.mplayer.get_id())
        self.mplayer.setwid(self.videoWid)
        self.xml.get_widget("videoWindow").resize(800, 400)
        self.mplayer.set_size_request(640, 480)
        self.mplayer.loadfile(self.filename)
        self.flush_event_queue()
        dictHandlers = {
        'on_videoWindow_destroy': self.destroy,
        'on_play_clicked': self.play,
        "on_pause_clicked":self.mplayer.pause,
        "on_rewind_clicked":self.mplayer.backward,
        "on_forward_clicked":self.mplayer.forward,
        "on_reEncode_clicked":self.reEncode,
        }

        self.xml.signal_autoconnect(dictHandlers)
        self.video = None


    def flush_event_queue(self):
        """Updates the GTK GUI before coming back to the gtk.main()"""
#        self.xml.show_all()
        while gtk.events_pending():
            gtk.main_iteration()


    def destroy(self, *args):
        """destroy clicked by user"""
        self.mplayer.quit()
        gtk.main_quit()


    def loadVideo(self):
        """Load the video information and setup the GUI"""
        logger.debug("VideoInterface.loadVideo")
        self.video = Video(self.filename)
        self.xml.get_widget("filename").set_text(self.video.videoFile)
        self.xml.get_widget("model").set_text(self.video.camera.encode("UTF-8"))
        self.xml.get_widget("resolution").set_text("%ix%i" % (self.video.width, self.video.height))
        self.xml.get_widget("size").set_text("%.2f %s" % smartSize(os.path.getsize(self.filename)))
        self.xml.get_widget("dateTime").set_text(self.video.timeStamp.strftime("%Y:%m:%d %Hh%Mm%Ss"))
        self.xml.get_widget("duration").set_text("%s s" % self.video.duration)
        self.xml.get_widget("video").set_text("%.1f fps\t%s\t%s" % (self.video.frameRate, self.video.videoCodec, self.video.videoBitRate))
        self.xml.get_widget("audio").set_text("%i ch\t%.1fHz\t%s\t%s" % (self.video.audioChannel, self.video.audioSampleRate, self.video.audioCodec, self.video.audioBitRate))
        if "INAM" in self.video.data:
            self.xml.get_widget("title").set_text(self.video.data["INAM"])
        if "IKEY" in self.video.data:
            self.xml.get_widget("keyword").set_text(" ".join(self.video.data["IKEY"].split(";")))

    def getRotation(self):
        if self.xml.get_widget("ccwRot").get_active() is True:
            rotation = 270
        elif self.xml.get_widget("noRot").get_active() is True:
            rotation = 0
        elif self.xml.get_widget("cwRot").get_active() is True:
            rotation = 90
        return rotation


    def play(self, *args):
        """play the video"""
        logger.debug("ccwRot: %s, noRot: %s, cwRot: %s" % (self.xml.get_widget("ccwRot").get_active(), self.xml.get_widget("noRot").get_active(), self.xml.get_widget("cwRot").get_active()))
        rotation = self.getRotation()
        if rotation != self.rotation:
            self.rotation = rotation
            self.mplayer.quit()
            if rotation == 90:
                self.mplayer.videoFilter = "rotate=1"
            elif rotation == 270:
                self.mplayer.videoFilter = "rotate=2"
            else:
                self.mplayer.videoFilter = None
            self.mplayer.setwid(self.videoWid)
            self.mplayer.loadfile(self.filename)
        else:
            self.mplayer.play(*args)


    def reEncode(self, *args):
        """Re-Encode the video"""
#.........这里部分代码省略.........
开发者ID:kif,项目名称:imagizer,代码行数:103,代码来源:video_gui.py


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