I coded a function to perform dynamic text overlay, displaying lines from a file.
def show_line(self): next_line = self.curr_line + 1 self.line = self.lines[self.curr_line] y = self.line.split(' ') z = self.lines[next_line].split(' ') d1 = datetime.datetime.fromtimestamp(float(y[0])) d2 = datetime.datetime.fromtimestamp(float(z[0])) d3 = d2-d1 d3s = str(d3) sleep_time = int(float(d3s[6::]))*1000 self.player.get_by_name("textoverlay").set_property("text", self.line) glib.timeout_add(sleep_time, self.show_line) self.curr_line += 1 return False where "line" is an array which contains the lines of the file (I used readlines() ). In each of these lines, there is the timestamp, used to display the strings on screen in according with the difference between two of them (d3). This function is called by another one. The problem is that is displayed the 1st line, 3rd one, 5th one and so on and not respecting the timestamp |
Suggestions???
Regards, K |
In reply to this post by kususe
On Fri, 2012-02-24 at 11:40 -0800, kususe wrote:
> I coded a function to perform dynamic text overlay, displaying lines from a > file. > > def show_line(self): > next_line = self.curr_line + 1 > self.line = self.lines[self.curr_line] > y = self.line.split(' ') > z = self.lines[next_line].split(' ') > d1 = datetime.datetime.fromtimestamp(float(y[0])) > d2 = datetime.datetime.fromtimestamp(float(z[0])) > d3 = d2-d1 > d3s = str(d3) > sleep_time = int(float(d3s[6::]))*1000 > self.player.get_by_name("textoverlay").set_property("text", self.line) > glib.timeout_add(sleep_time, self.show_line) > self.curr_line += 1 > return False > > where "line" is an array which contains the lines of the file (I used > readlines() ). > In each of these lines, there is the timestamp, used to display the strings > on screen in according with the difference between two of them (d3). > This function is called by another one. > > The problem is that is displayed the 1st line, 3rd one, 5th one and so on > and not respecting the timestamp If you use the "text" or "markup" property, textoverlay will show the text as you set it on the property, immediately when you set it, for as long as you don't set the property to something else. If you want to show timed text, you can either a) handle the timing yourself, or b) use the GstController interface on the "text" property, to make it automatically show certain strings at a certain time in the stream, or c) push timed text/markup on textoverlay's text_sink sink pad. The buffers should contain UTF-8 text or pango markup, and the buffers should have timestamp and duration set on them. You could use an appsrc element to feed timed-text buffers to textoverlay, for example (or read them from file, like filesrc location=foo ! subparse ! ...) Cheers -Tim _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
In reply to this post by kususe
Ok, suppose I wanna handle by myself the timed textoverlay.
What I did in my function is exactly work this problem out. I wanna call a function which show on my screen a string set up with "text" and call it again after an interval to change the "text" property and start again, until the press of Stop button to stop the playing. But it doesn't work well, cause not all of the lines are displayed e not in according to rimestamp. On Fri, 2012-02-24 at 11:40 -0800, kususe wrote: > I coded a function to perform dynamic text overlay, displaying lines from a > file. > > def show_line(self): > next_line = self.curr_line + 1 > self.line = self.lines[self.curr_line] If you use the "text" or "markup" property, textoverlay will show the text as you set it on the property, immediately when you set it, for as long as you don't set the property to something else. If you want to show timed text, you can either a) handle the timing yourself, or b) use the GstController interface on the "text" property, to make it automatically show certain strings at a certain time in the stream, or c) push timed text/markup on textoverlay's text_sink sink pad. The buffers should contain UTF-8 text or pango markup, and the buffers should have timestamp and duration set on them. You could use an appsrc element to feed timed-text buffers to textoverlay, for example (or read them from file, like filesrc location=foo ! subparse ! ...) Cheers -Tim _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gst reamer-devel ------------------------------------------------------------------------------- Valore legale alle tue mail InterfreePEC - la tua Posta Elettronica Certificata http://pec.interfree.it ------------------------------------------------------------------------------- _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Hello, is there an example of point c? thanks Rossana
_______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
In reply to this post by kususe
I cannot help you, cause I used a glib function to call a callback one to perform what I'd want.
-----Messaggio originale----- Da: Rossana Guerra <[hidden email]> Inviato il: 24 Feb 2012 - 18:51 A: [hidden email], Discussion of the development of and with GStreamer <[hidden email]> Hello, is there an example of point c? thanks Rossana
------------------------------------------------------------------------------- Valore legale alle tue mail InterfreePEC - la tua Posta Elettronica Certificata http://pec.interfree.it ------------------------------------------------------------------------------- _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
ok :)
cheers Rossana 2012/2/25 <[hidden email]> I cannot help you, cause I used a glib function to call a callback one to perform what I'd want. _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |