Changeset 2524

Show
Ignore:
Timestamp:
2006-10-13 13:12:44 (2 years ago)
Author:
scott
Message:

Fixed missing last thumb in pull_thumbnails.py. Changed/fixed defaults for basic2cmml.py.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • scripts/trunk/basic2cmml.py

    r2223 r2524  
    8787  print "Stream info needed:" 
    8888  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]) 
    9090  else: 
    91     stream_id = ask("ID", file_str.rsplit(".")[0]) 
     91    stream_id = ask("ID", file_str.rsplit(".",1)[0]) 
    9292  stream_type = ask("MimeType", "audio/x-vorbis") 
    9393  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") 
    9595  else: 
    96     stream_src = ask("Source", file_str.rsplit(".")[0] + ".ogg") 
     96    stream_src = ask("Source", file_str.rsplit(".",1)[0] + ".ogg") 
    9797  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) 
    9898   
     
    160160    else: 
    161161      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"
    164164    if end_time: 
    165165      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  
    2727import gst 
    2828import sys 
     29import os 
    2930 
    3031def 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)) 
    3243  return int(h)*3600*1000 + int(m)*60*1000 + int(ms) 
    3344 
    3445class pull_thumbs: 
    35   clip = 1 
     46  clip = 0 
    3647  #Function to write screenshot. 
    3748  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 
    3952    f.write(str(buffer)) 
    4053    f.close() 
    4154     
    42   def main(self,location,quality,dimensions=None): 
     55  def main(self,location,quality,subdir=True,dimensions=None): 
    4356    #Setup the pipeline. filesrc location=source ! decodebin ! ffmpegcolorspace ! pngenc ! fakesink 
    4457    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") 
     
    4861    filesrc = pipeline.get_by_name("source") 
    4962     
    50     self.location = location 
    51      
    5263    f = open(location,"r") 
    5364    doc = xml.dom.minidom.parse(f) 
     
    5667      current_file = node.getAttribute('src') 
    5768    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]    
    5879     
    5980    pipeline.set_state(gst.STATE_PAUSED); 
     
    6788        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) 
    6889        self.clip += 1 
     90    pipeline.get_state() 
    6991    f.close() 
    7092