[xiph-commits] r11691 - trunk/souffleur
daraku at svn.xiph.org
daraku at svn.xiph.org
Mon Jul 3 11:49:34 PDT 2006
Author: daraku
Date: 2006-07-03 11:49:27 -0700 (Mon, 03 Jul 2006)
New Revision: 11691
Modified:
trunk/souffleur/Souffleur.py
trunk/souffleur/Subtitles.py
trunk/souffleur/souffleur.glade
Log:
Subtitles optimize. Add some time info. Add save function for subtitle text (in memory only)
Modified: trunk/souffleur/Souffleur.py
===================================================================
--- trunk/souffleur/Souffleur.py 2006-07-03 13:22:16 UTC (rev 11690)
+++ trunk/souffleur/Souffleur.py 2006-07-03 18:49:27 UTC (rev 11691)
@@ -20,7 +20,7 @@
from GPlayer import VideoWidget
from GPlayer import GstPlayer
from Subtitles import Subtitles
-from datetime import time
+#from datetime import time
import sys
try:
@@ -87,7 +87,10 @@
"on_MEDIA_ADJUSTMENT_button_press_event": self.buttonPressAdjustment,\
"on_MEDIA_ADJUSTMENT_button_release_event": self.buttonReleaseAdjustment,\
"on_MEDIA_ADJUSTMENT_change_value": self.changeValueAdjustment,\
- "on_VIDEO_OUT_PUT_expose_event": self.exposeEventVideoOut}
+ "on_VIDEO_OUT_PUT_expose_event": self.exposeEventVideoOut,\
+ "on_TOOL_START_clicked": self.cb_setSubStartTime,\
+ "on_TOOL_END_clicked": self.cb_setSubEndTime,\
+ "on_TOOL_SAVE_clicked": self.cb_subChangeSave}
self.wTree.signal_autoconnect (dic)
self.windowFileOpen=None
@@ -106,14 +109,40 @@
self.videoWidget = self.wTree.get_widget("VIDEO_OUT_PUT")
self.adjustment = self.wTree.get_widget("MEDIA_ADJUSTMENT")
self.SubEdit = self.wTree.get_widget("VIEW_SUB")
+ self.labelHour = self.wTree.get_widget("LABEL_HOUR")
+ self.labelMin = self.wTree.get_widget("LABEL_MIN")
+ self.labelSec = self.wTree.get_widget("LABEL_SEC")
+ self.labelMSec = self.wTree.get_widget("LABEL_MSEC")
+ self.subStartTime = self.wTree.get_widget("SUB_START_TIME")
+ self.subEndTime = self.wTree.get_widget("SUB_END_TIME")
return
#==============================================================================
+ def cb_subChangeSave(self, widget):
+ if (self.curSub != -1) and (self.Subtitle != None):
+ BUF = self.SubEdit.get_buffer()
+ TEXT = BUF.get_text(BUF.get_start_iter(), BUF.get_end_iter())
+ self.Subtitle.subs[int(self.curSub)-1].text = str(TEXT)
+ self.Subtitle.subs[int(self.curSub)-1].start_time=self.subStartTime.get_value_as_int()
+ self.Subtitle.subs[int(self.curSub)-1].end_time=self.subEndTime.get_value_as_int()
+#==============================================================================
+ def cb_setSubStartTime(self, widget):
+ self.subStartTime.set_value(self.p_position/1000000)
+#==============================================================================
+ def cb_setSubEndTime(self, widget):
+ self.subEndTime.set_value(self.p_position/1000000)
+#==============================================================================
+ def setSubStartTime(self, time):
+ self.subStartTime.set_value(time)
+#==============================================================================
+ def setSubEndTime(self, time):
+ self.subEndTime.set_value(time)
+#==============================================================================
def exposeEventVideoOut(self, widget, event):
if self.videoWidgetGst:
self.videoWidgetGst.do_expose_event(event)
#==============================================================================
def changeValueAdjustment(self, widget, t1, t2):
- if (not self.scroll):
+ #if (not self.scroll):
real = long(self.adjustment.get_value() * self.p_duration / 100) # in ns
self.player.seek(real)
# allow for a preroll
@@ -221,33 +250,40 @@
def update_scale_cb(self):
had_duration = self.p_duration != gst.CLOCK_TIME_NONE
self.p_position, self.p_duration = self.player.query_position()
+ tmSec= self.p_position/1000000
+ MSec = tmSec
+ tmSec = tmSec/1000
+ Sec = tmSec%60
+ tmSec = tmSec/60
+ Min = tmSec%60
+ Hour=tmSec/60
if self.Subtitle:
- tmSec= self.p_position/1000000
- MSec = tmSec%1000
- tmSec = tmSec/1000
- Sec = tmSec%60
- tmSec = tmSec/60
- Min = tmSec%60
- Hour=tmSec/60
- ST = time( Hour, Min, Sec, MSec )
- TText = self.Subtitle.getSub(ST)
+ TText = self.Subtitle.getSub(MSec)
if TText:
if (TText.N!=self.curSub):
BUF=gtk.TextBuffer()
BUF.set_text(TText.text)
self.SubEdit.set_buffer(BUF)
self.curSub=TText.N
+ self.setSubStartTime(TText.start_time)
+ self.setSubEndTime(TText.end_time)
else:
if (self.curSub!=-1):
BUF=gtk.TextBuffer()
BUF.set_text("")
self.SubEdit.set_buffer(BUF)
self.curSub=-1
- if (self.p_position != gst.CLOCK_TIME_NONE) and (not self.scroll):
+ self.setSubStartTime(0)
+ self.setSubEndTime(0)
+ if (self.p_position != gst.CLOCK_TIME_NONE):# and (not self.scroll):
value = self.p_position * 100.0 / self.p_duration
self.adjustment.set_value(value)
#if not had_duration:
# self.cutin.set_time(0)
+ self.labelHour.set_text(str(Hour))
+ self.labelMin.set_text(str(Min))
+ self.labelSec.set_text(str(Sec))
+ self.labelMSec.set_text(str(MSec))
return True
#==============================================================================
# MAIN:
Modified: trunk/souffleur/Subtitles.py
===================================================================
--- trunk/souffleur/Subtitles.py 2006-07-03 13:22:16 UTC (rev 11690)
+++ trunk/souffleur/Subtitles.py 2006-07-03 18:49:27 UTC (rev 11691)
@@ -1,6 +1,6 @@
import os
import string
-from datetime import time
+#from datetime import time
#from array import array
SUB_NONE=0
@@ -60,9 +60,12 @@
Text=Text+DATA[i]+"\n"
i+=1
i+=1
- ST=time(int(Timing[0:2]), int(Timing[3:5]), int(Timing[6:8]), int(Timing[9:12])*1000)
- ET=time(int(Timing[17:19]), int(Timing[20:22]), int(Timing[23:25]), int(Timing[26:29])*1000)
+ #ST=time(int(Timing[0:2]), int(Timing[3:5]), int(Timing[6:8]), int(Timing[9:12])*1000)
+ #ET=time(int(Timing[17:19]), int(Timing[20:22]), int(Timing[23:25]), int(Timing[26:29])*1000)
+ ST=int(Timing[0:2])*3600000+int(Timing[3:5])*60000+int(Timing[6:8])*1000+int(Timing[9:12])
+ ET=int(Timing[17:19])*3600000+int(Timing[20:22])*60000+int(Timing[23:25])*1000+int(Timing[26:29])
+
TS=Sub()
TS.text=Text
TS.start_time=ST
@@ -77,6 +80,6 @@
if(self.subs[i].isInTime(time)==1):
return self.subs[i]
i=i+1
- if(i>(len(self.subs)+1)):
+ if(i>=len(self.subs)):
return None
return None
Modified: trunk/souffleur/souffleur.glade
===================================================================
--- trunk/souffleur/souffleur.glade 2006-07-03 13:22:16 UTC (rev 11690)
+++ trunk/souffleur/souffleur.glade 2006-07-03 18:49:27 UTC (rev 11691)
@@ -426,6 +426,7 @@
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
+ <signal name="clicked" handler="on_TOOL_START_clicked" last_modification_time="Mon, 03 Jul 2006 17:35:31 GMT"/>
</widget>
<packing>
<property name="expand">False</property>
@@ -443,6 +444,7 @@
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
+ <signal name="clicked" handler="on_TOOL_END_clicked" last_modification_time="Mon, 03 Jul 2006 17:35:36 GMT"/>
</widget>
<packing>
<property name="expand">False</property>
@@ -464,12 +466,13 @@
</child>
<child>
- <widget class="GtkToolButton" id="toolbutton18">
+ <widget class="GtkToolButton" id="TOOL_SAVE">
<property name="visible">True</property>
<property name="stock_id">gtk-save</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
+ <signal name="clicked" handler="on_TOOL_SAVE_clicked" last_modification_time="Mon, 03 Jul 2006 18:18:30 GMT"/>
</widget>
<packing>
<property name="expand">False</property>
@@ -485,6 +488,220 @@
</child>
<child>
+ <widget class="GtkHBox" id="hbox2">
+ <property name="border_width">4</property>
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">2</property>
+
+ <child>
+ <widget class="GtkLabel" id="LABEL_HOUR">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">00</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="LABEL_MIN">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">00</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label8">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="LABEL_SEC">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">00</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label10">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">(</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="LABEL_MSEC">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">0000000</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label12">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">)</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
<widget class="GtkHScrollbar" id="MEDIA_ADJUSTMENT">
<property name="visible">True</property>
<property name="update_policy">GTK_UPDATE_CONTINUOUS</property>
@@ -523,7 +740,7 @@
<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
- <property name="label" translatable="yes">Start time (s)</property>
+ <property name="label" translatable="yes">Start time (ms)</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -546,7 +763,7 @@
</child>
<child>
- <widget class="GtkSpinButton" id="spinbutton1">
+ <widget class="GtkSpinButton" id="SUB_START_TIME">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="climb_rate">1</property>
@@ -555,7 +772,7 @@
<property name="update_policy">GTK_UPDATE_ALWAYS</property>
<property name="snap_to_ticks">False</property>
<property name="wrap">False</property>
- <property name="adjustment">1 0 100 1 10 10</property>
+ <property name="adjustment">1 0 3600000000 1 10 10</property>
</widget>
<packing>
<property name="padding">0</property>
@@ -567,7 +784,7 @@
<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
- <property name="label" translatable="yes">End time (s)</property>
+ <property name="label" translatable="yes">End time (ms)</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -590,7 +807,7 @@
</child>
<child>
- <widget class="GtkSpinButton" id="spinbutton2">
+ <widget class="GtkSpinButton" id="SUB_END_TIME">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="climb_rate">1</property>
@@ -599,7 +816,7 @@
<property name="update_policy">GTK_UPDATE_ALWAYS</property>
<property name="snap_to_ticks">False</property>
<property name="wrap">False</property>
- <property name="adjustment">1 0 100 1 10 10</property>
+ <property name="adjustment">1 0 3600000000 1 10 10</property>
</widget>
<packing>
<property name="padding">0</property>
More information about the commits
mailing list