Changeset 2524
- Timestamp:
- 2006-10-13 13:12:44 (2 years ago)
- Files:
-
- scripts/trunk/basic2cmml.py (modified) (2 diffs)
- scripts/trunk/pull_thumbnails.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
scripts/trunk/basic2cmml.py
r2223 r2524 87 87 print "Stream info needed:" 88 88 if (file_str.find('/') != -1): 89 stream_id = ask("ID", file_str.rsplit("/" )[1].rsplit(".")[0])89 stream_id = ask("ID", file_str.rsplit("/",1)[1].rsplit(".",1)[0]) 90 90 else: 91 stream_id = ask("ID", file_str.rsplit("." )[0])91 stream_id = ask("ID", file_str.rsplit(".",1)[0]) 92 92 stream_type = ask("MimeType", "audio/x-vorbis") 93 93 if (file_str.find('/') != -1): 94 stream_src = ask("Source", file_str.rsplit("/" )[1].rsplit(".")[0] + ".ogg")94 stream_src = ask("Source", file_str.rsplit("/",1)[1].rsplit(".",1)[0] + ".ogg") 95 95 else: 96 stream_src = ask("Source", file_str.rsplit("." )[0] + ".ogg")96 stream_src = ask("Source", file_str.rsplit(".",1)[0] + ".ogg") 97 97 cmml_file += '<stream id="%s" timebase="npt:0">\n\t<import contenttype="%s" src="%s" start="npt:0">\n\t</import>\n</stream>\n\n' % (stream_id,stream_type,stream_src) 98 98 … … 160 160 else: 161 161 print "\nClip %s of %s needs info:\nStart: %s\nEnd: None\nDescription: %s" % (str(x),count,start_time,desc.strip()) 162 clip_id = ask("ID" )163 clip_title = ask("Title" , desc.strip())162 clip_id = ask("ID", "basic2cmml" + str(x)) 163 clip_title = ask("Title") 164 164 if end_time: 165 165 cmml_file += '<clip id="%s" title="%s" start="%s" end="%s">\n' % (clip_id,clip_title,start_time,end_time) scripts/trunk/pull_thumbnails.py
r2523 r2524 27 27 import gst 28 28 import sys 29 import os 29 30 30 31 def to_ms(string): 31 h,m,ms = string.replace(".","").split(":") 32 time = string.split(":") 33 if len(time)==3: 34 h,m,s = time 35 if s.find(".")!=-1: 36 s,ms = s.split(".") 37 ms = ms + "0"*(3-len(ms)) 38 s += ms 39 elif len(time)==2: 40 m,s = time 41 h = "0" 42 ms = str(1000*int(s)) 32 43 return int(h)*3600*1000 + int(m)*60*1000 + int(ms) 33 44 34 45 class pull_thumbs: 35 clip = 146 clip = 0 36 47 #Function to write screenshot. 37 48 def process(self,element,buffer,pad): 38 f = open(self.location[:-5] + str(self.clip) + ".png","w") 49 filename = self.directory +"/"+ self.file_str + str(self.clip) + ".png" 50 f = open(filename,"w") 51 print "Wrote: " + filename 39 52 f.write(str(buffer)) 40 53 f.close() 41 54 42 def main(self,location,quality, dimensions=None):55 def main(self,location,quality,subdir=True,dimensions=None): 43 56 #Setup the pipeline. filesrc location=source ! decodebin ! ffmpegcolorspace ! pngenc ! fakesink 44 57 pipeline = gst.parse_launch("filesrc name=source ! decodebin ! ffmpegcolorspace ! videoscale ! video/x-raw-rgb,width=160,height=90 ! pngenc compression-level=" + str(quality) + " ! fakesink name=sink") … … 48 61 filesrc = pipeline.get_by_name("source") 49 62 50 self.location = location51 52 63 f = open(location,"r") 53 64 doc = xml.dom.minidom.parse(f) … … 56 67 current_file = node.getAttribute('src') 57 68 filesrc.props.location = current_file 69 70 self.location = location 71 self.subdir = subdir 72 if subdir: 73 self.directory = current_file.rsplit(".",1)[0] 74 os.mkdir(self.directory) 75 self.file_str = "" 76 else: 77 self.directory,self.file_str = current_file.rsplit("/",1) 78 self.file_str = self.file_str.rsplit(".",1)[0] 58 79 59 80 pipeline.set_state(gst.STATE_PAUSED); … … 67 88 pipeline.seek(1.0, gst.FORMAT_TIME, gst.SEEK_FLAG_FLUSH | gst.SEEK_FLAG_ACCURATE, gst.SEEK_TYPE_SET, gst.MSECOND*to_ms(start_time), gst.SEEK_TYPE_NONE, 0) 68 89 self.clip += 1 90 pipeline.get_state() 69 91 f.close() 70 92