~ubuntu-branches/ubuntu/trusty/pitivi/trusty

« back to all changes in this revision

Viewing changes to pitivi/settings.py

  • Committer: Bazaar Package Importer
  • Author(s): Loic Minier
  • Date: 2007-01-31 15:32:37 UTC
  • mto: (3.2.1 hardy) (1.2.1 upstream) (6.1.1 sid)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20070131153237-de4p8lipjv8x5x3b
Tags: upstream-0.10.2
ImportĀ upstreamĀ versionĀ 0.10.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
import gobject
28
28
import gst
29
29
 
 
30
from gettext import gettext as _
30
31
 
31
32
class ExportSettings(gobject.GObject):
32
33
    """
48
49
 
49
50
    # Audio/Video settings for processing/export
50
51
 
 
52
    # TODO : Add PAR/DAR for video
 
53
    # TODO : switch to using GstFraction internally where appliable
 
54
 
51
55
    def __init__(self):
52
56
        gobject.GObject.__init__(self)
53
57
        self.videowidth = 720
54
58
        self.videoheight = 576
55
 
        self.videorate = 25.0
 
59
        self.videorate = gst.Fraction(25,1)
 
60
        self.videopar = gst.Fraction(1,1)
56
61
        self.audiochannels = 2
57
62
        self.audiorate = 44100
58
63
        self.audiodepth = 16
67
72
        self.aencoders = available_audio_encoders()
68
73
 
69
74
    def __str__(self):
70
 
        msg = "Export Settings\n"
71
 
        msg += "Video :" + str(self.videowidth) + " " + str(self.videoheight) + " " + str(self.videorate)
 
75
        msg = _("Export Settings\n")
 
76
        msg += _("Video :") + str(self.videowidth) + " " + str(self.videoheight) + " " + str(self.videorate) + " " + str (self.videopar)
72
77
        msg += "\n\t" + str(self.vencoder) + " " +str(self.vcodecsettings)
73
 
        msg += "\nAudio :" + str(self.audiochannels) + " " + str(self.audiorate) + " " + str(self.audiodepth)
 
78
        msg += _("\nAudio :") + str(self.audiochannels) + " " + str(self.audiorate) + " " + str(self.audiodepth)
74
79
        msg += "\n\t" + str(self.aencoder) + " " + str(self.acodecsettings)
75
 
        msg += "\nMuxer :" + str(self.muxer) + " " + str(self.containersettings)
 
80
        msg += _("\nMuxer :") + str(self.muxer) + " " + str(self.containersettings)
76
81
        return msg
77
82
 
78
 
    def setVideoProperties(self, width=-1, height=-1, framerate=-1):
 
83
    def getVideoCaps(self):
 
84
        """ Returns the GstCaps corresponding to the video settings """
 
85
        astr = "width=%d,height=%d,pixel-aspect-ratio=%d/%d,framerate=%d/%d" % (self.videowidth, self.videoheight,
 
86
                                                                                self.videopar.num, self.videopar.denom,
 
87
                                                                                self.videorate.num, self.videorate.denom)
 
88
        return gst.caps_from_string("video/x-raw-yuv,%s;video/x-raw-rgb,%s" % (astr, astr))
 
89
 
 
90
    def getVideoDescription(self):
 
91
        """ Returns a human-readable markup-ed string describing the video properties """
 
92
        res = "%d x %d <i>pixels</i> at %.2f <i>fps</i> <i>(%s)</i>"
 
93
        return res % (self.videowidth, self.videoheight,
 
94
                      float(self.videorate), self.vencoder)
 
95
 
 
96
    def getAudioDescription(self):
 
97
        """ Returns a human-readable markup-ed string describing the audio properties """
 
98
        res = "%d channels at %d <i>Hz</i> (%d <i>bits</i>) <i>(%s)</i>"
 
99
        return res % (self.audiochannels, self.audiorate, self.audiodepth, self.aencoder)
 
100
 
 
101
    def getAudioCaps(self):
 
102
        """ Returns the GstCaps corresponding to the audio settings """
 
103
        astr = "rate=%d,depth=%d,channels=%d" % (self.audiorate, self.audiodepth, self.audiochannels)
 
104
        return gst.caps_from_string("audio/x-raw-int,%s;audio/x-raw-float,%s" % (astr, astr))
 
105
 
 
106
    def setVideoProperties(self, width=-1, height=-1, framerate=-1, par=-1):
79
107
        """ Set the video width, height and framerate """
80
 
        gst.info("set_video_props %d x %d @ %f fps" % (width, height, framerate))
 
108
        gst.info("set_video_props %d x %d @ %r fps" % (width, height, framerate))
81
109
        changed = False
82
110
        if not width == -1 and not width == self.videowidth:
83
111
            self.videowidth = width
88
116
        if not framerate == -1 and not framerate == self.videorate:
89
117
            self.videorate = framerate
90
118
            changed = True
 
119
        if not par == -1 and not par == self.videopar:
 
120
            self.videopar = par
 
121
            changed = True
91
122
        if changed:
92
123
            self.emit("settings-changed")
93
124