[xiph-commits] r3168 - liboggplay/trunk/src/tools
shans at svn.annodex.net
shans at svn.annodex.net
Sun Jul 22 23:36:29 PDT 2007
Author: shans
Date: 2007-07-22 23:36:29 -0700 (Sun, 22 Jul 2007)
New Revision: 3168
Modified:
liboggplay/trunk/src/tools/dump_some_frames.py
Log:
dumps a bunch of frames using timevals from an input cmml file
Modified: liboggplay/trunk/src/tools/dump_some_frames.py
===================================================================
--- liboggplay/trunk/src/tools/dump_some_frames.py 2007-07-23 06:36:07 UTC (rev 3167)
+++ liboggplay/trunk/src/tools/dump_some_frames.py 2007-07-23 06:36:29 UTC (rev 3168)
@@ -1,9 +1,32 @@
import sys
+import Image
from oggplay import *
+from xml.dom.ext.reader import Sax2
+from xml import xpath
video_name = sys.argv[1]
timelist = sys.argv[2]
+outname = sys.argv[3]
+f = open(timelist)
+reader = Sax2.Reader()
+doc = reader.fromStream(f)
+times = xpath.Evaluate('descendant::clip/@start', doc.documentElement)
+times = map(lambda a: a.nodeValue, times)
+f.close()
+
+def string_to_ms(time):
+ stime = time.split(":")
+ out = 0
+ mul = 1
+ while len(stime) > 0:
+ out += mul * float(stime[-1])
+ mul *= 60
+ del stime[-1]
+ return (int(out * 1000), time)
+
+times = map(string_to_ms, times)
+
if video_name[:7] == "http://":
reader = oggplay_tcp_reader_new(video_name, None, 80)
else:
@@ -18,12 +41,24 @@
video = i
oggplay_set_track_active(player, i)
+pos = 0
+
def data_callback(player, track_info):
+ global pos
headers = oggplay_callback_info_get_headers(track_info[video])
- video_data = oggplay_callback_info_get_video_data(headers[0])
- print video_data.y
- return -1
+ time = oggplay_callback_info_get_presentation_time(headers[0])
+ if time >= times[pos][0]:
+ rgba = oggplay_generate_frame(player, video, headers[0])
+ image = Image.fromstring("RGBA", rgba[1], rgba[0])
+ fname = outname + ".png?t=" + times[pos][1]
+ pos += 1
+ print "saving", fname
+ image.save(fname, "PNG")
+ if pos == len(times):
+ return -1
+ return 0
+if len(times) == 0:
+ exit(0)
oggplay_set_data_pycallback(player, data_callback)
-print "data callback set"
oggplay_start_decoding(player)
More information about the commits
mailing list