31 import xml.dom.minidom
as xml
38 from classes
import info, ui_util, settings
39 from classes.app
import get_app
40 from classes.logger
import log
46 import simplejson
as json
54 ui_path = os.path.join(info.PATH,
'windows',
'ui',
'file-properties.ui')
60 QDialog.__init__(self)
80 self.buttonBox.addButton(self.
update_button, QDialogButtonBox.AcceptRole)
81 self.buttonBox.addButton(QPushButton(_(
'Cancel')), QDialogButtonBox.RejectRole)
87 path, filename = os.path.split(self.
file.data[
"path"])
88 baseFilename, ext = os.path.splitext(filename)
89 fps_float = float(self.
file.data[
"fps"][
"num"]) / float(self.
file.data[
"fps"][
"den"])
92 if "tags" in self.
file.data.keys():
93 tags = self.
file.data[
"tags"]
95 if "name" in self.
file.data.keys():
96 name = self.
file.data[
"name"]
99 self.txtFileName.setText(name)
100 self.txtTags.setText(tags)
101 self.txtFilePath.setText(os.path.join(path, filename))
104 self.txtWidth.setValue(self.
file.data[
"width"])
105 self.txtHeight.setValue(self.
file.data[
"height"])
106 self.txtFrameRateNum.setValue(self.
file.data[
"fps"][
"num"])
107 self.txtFrameRateDen.setValue(self.
file.data[
"fps"][
"den"])
108 self.txtAspectRatioNum.setValue(self.
file.data[
"display_ratio"][
"num"])
109 self.txtAspectRatioDen.setValue(self.
file.data[
"display_ratio"][
"den"])
110 self.txtPixelRatioNum.setValue(self.
file.data[
"pixel_ratio"][
"num"])
111 self.txtPixelRatioDen.setValue(self.
file.data[
"pixel_ratio"][
"den"])
114 if self.
file.data[
"has_audio"]:
115 self.txtFrameRateNum.setEnabled(
False)
116 self.txtFrameRateDen.setEnabled(
False)
118 self.txtStartFrame.setMaximum(int(self.
file.data[
"video_length"]))
119 if 'start' not in file.data.keys():
120 self.txtStartFrame.setValue(1)
122 self.txtStartFrame.setValue(round(float(file.data[
"start"]) * fps_float) + 1)
124 self.txtEndFrame.setMaximum(int(self.
file.data[
"video_length"]))
125 if 'end' not in file.data.keys():
126 self.txtEndFrame.setValue(int(self.
file.data[
"video_length"]))
128 self.txtEndFrame.setValue(round(float(file.data[
"end"]) * fps_float) + 1)
131 self.txtVideoFormat.setText(ext.replace(
".",
""))
132 self.txtVideoCodec.setText(self.
file.data[
"vcodec"])
133 self.txtAudioCodec.setText(self.
file.data[
"acodec"])
134 self.txtSampleRate.setValue(int(self.
file.data[
"sample_rate"]))
135 self.txtChannels.setValue(int(self.
file.data[
"channels"]))
136 self.txtVideoBitRate.setValue(int(self.
file.data[
"video_bit_rate"]))
137 self.txtAudioBitRate.setValue(int(self.
file.data[
"audio_bit_rate"]))
140 self.txtOutput.setText(json.dumps(file.data, sort_keys=
True, indent=4, separators=(
',',
': ')))
143 channel_layout_index = 0
144 selected_channel_layout_index = 0
145 current_channel_layout = 0
146 if self.
file.data[
"has_audio"]:
147 current_channel_layout = int(self.
file.data[
"channel_layout"])
149 for layout
in [(0, _(
"Unknown")),
150 (openshot.LAYOUT_MONO, _(
"Mono (1 Channel)")),
151 (openshot.LAYOUT_STEREO, _(
"Stereo (2 Channel)")),
152 (openshot.LAYOUT_SURROUND, _(
"Surround (3 Channel)")),
153 (openshot.LAYOUT_5POINT1, _(
"Surround (5.1 Channel)")),
154 (openshot.LAYOUT_7POINT1, _(
"Surround (7.1 Channel)"))]:
157 self.cboChannelLayout.addItem(layout[1], layout[0])
158 if current_channel_layout == layout[0]:
159 selected_channel_layout_index = channel_layout_index
160 channel_layout_index += 1
163 self.cboChannelLayout.setCurrentIndex(selected_channel_layout_index)
166 self.cboInterlaced.clear()
167 self.cboInterlaced.addItem(_(
"Yes"),
"Yes")
168 self.cboInterlaced.addItem(_(
"No"),
"No")
169 if self.
file.data[
"interlaced_frame"]:
170 self.cboInterlaced.setCurrentIndex(0)
172 self.cboInterlaced.setCurrentIndex(1)
175 self.toolBox.setCurrentIndex(0)
179 self.
file.data[
"name"] = self.txtFileName.text()
180 self.
file.data[
"tags"] = self.txtTags.text()
183 self.
file.data[
"fps"][
"num"] = self.txtFrameRateNum.value()
184 self.
file.data[
"fps"][
"den"] = self.txtFrameRateDen.value()
187 fps_float = float(self.
file.data[
"fps"][
"num"]) / float(self.
file.data[
"fps"][
"den"])
188 if self.txtStartFrame.value() != 1
or self.txtEndFrame.value() != self.
file.data[
"video_length"]:
189 self.
file.data[
"start"] = (self.txtStartFrame.value() - 1) / fps_float
190 self.
file.data[
"end"] = (self.txtEndFrame.value() - 1) / fps_float
196 super(FileProperties, self).
accept()
201 super(FileProperties, self).
reject()
def get_app()
Returns the current QApplication instance of OpenShot.
def get_settings()
Get the current QApplication's settings instance.
def init_ui(window)
Initialize all child widgets and action of a window or dialog.
def track_metric_screen(screen_name)
Track a GUI screen being shown.
def load_ui(window, path)
Load a Qt *.ui file, and also load an XML parsed version.