Exemplo n.º 1
0
def main(argv):
    import getopt, re

    def usage():
        print "usage: %s [-d] [-r framerate] [-C WxH+X+Y] [-s scaling] file1 file2 ..." % argv[0]
        return 100

    try:
        (opts, args) = getopt.getopt(argv[1:], "dr:C:s:")
    except getopt.GetoptError:
        return usage()
    #
    debug = 0
    info = SWFInfo()
    for (k, v) in opts:
        if k == "-d":
            debug += 1
        elif k == "-r":
            info.set_framerate(float(v))
        elif k == "-C":
            m = re.match(r"^(\d+)x(\d+)\+(\d+)\+(\d+)$", v)
            if not m:
                print >> stderr, "Invalid clipping specification:", v
                return usage()
            x = map(int, m.groups())
            info.clipping = (x[2], x[3], x[0], x[1])
        elif k == "-s":
            info.scaling = float(v)
    if not args:
        print >> stderr, "Specify at least one input movie."
        return usage()
    return play(args, info, debug=debug)
Exemplo n.º 2
0
def main(argv):
  import getopt, re
  def usage():
    print 'usage: %s [-d] [-r framerate] [-C WxH+X+Y] [-s scaling] file1 file2 ...' % argv[0]
    return 100
  try:
    (opts, args) = getopt.getopt(argv[1:], 'dr:C:s:')
  except getopt.GetoptError:
    return usage()
  #
  debug = 0
  info = SWFInfo()
  for (k, v) in opts:
    if k == '-d':
      debug += 1
    elif k == '-r':
      info.set_framerate(float(v))
    elif k == '-C':
      m = re.match(r'^(\d+)x(\d+)\+(\d+)\+(\d+)$', v)
      if not m:
        print >>stderr, 'Invalid clipping specification:', v
        return usage()
      x = map(int, m.groups())
      info.clipping = (x[2],x[3], x[0],x[1])
    elif k == '-s':
      info.scaling = float(v)
  if not args:
    print >>stderr, 'Specify at least one input movie.'
    return usage()
  return play(args, info, debug=debug)
Exemplo n.º 3
0
def main(argv):
  import getopt
  def usage():
    print >>stderr, '''usage: %s
    [-d] [-c] [-t type] [-f|-F frames] [-a mp3file] [-r framerate]
    [-S mp3sampleskip] [-C WxH+X+Y] [-B blocksize] [-K keyframe]
    [-R framestep] [-s scaling]
    -o outfile.swf file1 file2 ...

    Specify one output filename from the following:
      *.swf: generate a SWF movie.
      *.flv: generate a FLV movie.
      *.mpg: generate a MPEG movie.
      *.png|*.bmp: save snapshots of given frames as "X-nnn.png"
      
    -d: debug mode.
    -c: compression.
    -t {swf5,swf7,flv,mpeg,png,bmp}: specify the output movie type.
    -f(-F) frames: frames to extract. e.g. 1-2,100-300,310,500-
       -F disables seeking audio.
    -R framestep: frame resampling step (default: 1)
    -s scaling: scale factor (default: 1.0)
    -a filename: attach MP3 file(s). (multiple files can be specified)
    -r framerate: override framerate.
    -B blocksize: (SWF7 and FLV mode only) blocksize of video packet (must be a multiple of 16)
    -K keyframe: keyframe interval
    -S N[s]: skip the first N samples (or N seconds) of the sound when the movie starts.
    -C WxH+X+Y: crop a specific area of the movie.
    -b: disable seekbar.
    -l: disable loop.
    -z: make the movie scalable.
    ''' % argv[0]
    return 100
  try:
    (opts, args) = getopt.getopt(argv[1:], 'dr:o:t:cHa:S:C:B:K:f:F:R:s:blz')
  except getopt.GetoptError:
    return usage()
  #
  debug = 0
  info = SWFInfo()
  range_str = '-'
  step = 1
  streamtype = None
  kfinterval = 0
  mp3skip = 0
  mp3seek = True
  loop = True
  seekbar = True
  for (k, v) in opts:
    if k == '-d':
      debug += 1
    elif k == '-r':
      info.set_framerate(float(v))
    elif k == '-o':
      info.filename = v
    elif k == '-t':
      v = v.lower()
      if v not in ('swf5','swf7','mpeg','mpg','flv','png','bmp','gif'):
        print >>stderr, 'Invalid output type:', v
        return usage()
      streamtype = v
    elif k == '-a':
      fp = file(v, 'rb')
      print >>stderr, 'Reading mp3 file: %s...' % v
      info.reg_mp3blocks(fp)
      fp.close()
    elif k == '-S':
      if v.endswith('s'):
        mp3skip = float(v[:-1])
      else:
        mp3skip = int(v)
    elif k == '-C':
      try:
        info.set_clipping(v)
      except ValueError:
        print >>stderr, 'Invalid clipping specification:', v
        return usage()
    elif k == '-B':
      blocksize = int(v)
      assert 0 < blocksize and blocksize <= 256 and blocksize % 16 == 0, 'Invalid block size.'
      info.blocksize = blocksize
    elif k == '-K':
      kfinterval = int(v)
    elif k == '-c':
      info.compression = True
    elif k == '-f':
      range_str = v
    elif k == '-F':
      range_str = v
      mp3seek = False
    elif k == '-R':
      step = int(v)
      mp3seek = False
    elif k == '-s':
      info.scaling = float(v)
      assert 0 < info.scaling and info.scaling <= 1.0, 'Invalid scaling.'
    elif k == '-b':
      seekbar = False
    elif k == '-l':
      loop = False
    elif k == '-z':
      info.set_scalable(True)
  if not args:
    print >>stderr, 'Specify at least one input movie.'
    return usage()
  if not info.filename:
    print >>stderr, 'Specify exactly one output file.'
    return usage()
  if not streamtype:
    v = info.filename
    if v.endswith('.swf'):
      streamtype = 'swf5'
    elif v.endswith('.png'):
      streamtype = 'png'
    elif v.endswith('.bmp'):
      streamtype = 'bmp'
    elif v.endswith('.gif'):
      streamtype = 'gif'
    elif v.endswith('.mpg') or v.endswith('.mpeg'):
      streamtype = 'mpeg'
    elif v.endswith('.flv'):
      streamtype = 'flv'
    else:
      print >>stderr, 'Unknown stream type.'
      return 100
  if streamtype == 'mpeg' and not MPEGVideoStream:
    print >>stderr, 'MPEGVideoStream is not supported.'
    return 100
  stream = None
  if streamtype == 'swf5':
    stream = SWFShapeStream(info, debug=debug)
  elif streamtype == 'swf7':
    stream = SWFVideoStream(info, debug=debug)
  elif streamtype in ('mpg', 'mpeg'):
    stream = MPEGVideoStream(info, debug=debug)
  elif streamtype == 'flv':
    stream = FLVVideoStream(info, debug=debug)
  else:
    stream = ImageSequenceStream(info, debug=debug)
  try:
    return reorganize(info, stream, args, range_str,
                      loop=loop, seekbar=seekbar,
                      step=step, kfinterval=kfinterval, 
                      mp3seek=mp3seek, mp3skip=mp3skip,
                      debug=debug)
  except RangeError, e:
    print >>stderr, 'RangeError:', e
    return 100
Exemplo n.º 4
0
def main(argv):
  import getopt
  def usage():
    print >>stderr, '''usage: edit.py
    [-d] [-c] [-V] [-f|-F frames] [-a mp3file] [-r framerate]
    [-S mp3sampleskip] [-C WxH+X+Y] [-B blocksize] [-K keyframe]
    [-R framestep] [-s scaling]
    -o outfile.swf file1 file2 ...

    Specify one output filename from the following:
      *.swf: generate a reorganized and/or augmented movie.
      *.png|*.bmp: save snapshots of given frames as "X-nnn.png"
      *.mp3: extract an MP3 audio stream from a movie.
      
    -d: debug mode.
    -c: compression.
    -V: generate a movie in ScreenVideo format. (Flash version7 or above only)
    -f(-F) frames: frames to extract. e.g. 1-2,100-300,310,500-
       -F disables seeking audio.
    -R framestep: frame resampling step (default: 1)
    -s scaling: scale factor (default: 1)
    -a filename: attach MP3 file(s). (multiple files can be specified)
    -r framerate: override framerate.
    -B blocksize: (Video mode only) blocksize of video packet (must be a multiple of 16)
    -K keyframe: keyframe interval
    -S N: skip the first N samples of the sound when the movie starts.
    -C WxH+X+Y: crop a specific area of the movie.
    '''
    sys.exit(2)
  try:
    (opts, args) = getopt.getopt(argv, 'dr:o:VcHa:S:C:B:K:f:F:R:s:')
  except getopt.GetoptError:
    usage()
  #
  debug = 0
  info = SWFInfo()
  range_str = '-'
  step = 1
  is_video = False
  kfinterval = 0
  mp3skip = 0
  mp3seek = True
  for (k, v) in opts:
    if k == '-d':
      debug += 1
    elif k == '-r':
      info.set_framerate(float(v))
    elif k == '-o':
      info.filename = v
    elif k == '-a':
      fp = file(v)
      print 'Reading mp3 file: %s...' % v
      info.reg_mp3blocks(fp)
      fp.close()
    elif k == '-S':
      mp3skip = int(v)
      assert 0 <= mp3skip
    elif k == '-C':
      m = re.match(r'^(\d+)x(\d+)\+(\d+)\+(\d+)$', v)
      if not m:
        print >>stderr, 'Invalid clipping specification:', v
        usage()
      x = map(int, m.groups())
      info.clipping = (x[2],x[3], x[0],x[1])
    elif k == '-B':
      blocksize = int(v)
      assert 0 < blocksize and blocksize <= 256 and blocksize % 16 == 0
      info.blocksize = blocksize
    elif k == '-K':
      kfinterval = int(v)
    elif k == '-V':
      is_video = True
    elif k == '-c':
      info.compression = True
    elif k == '-f':
      range_str = v
    elif k == '-F':
      range_str = v
      mp3seek = False
    elif k == '-R':
      step = int(v)
      mp3seek = False
    elif k == '-s':
      info.scaling = float(v)
  if not args:
    print >>stderr, 'Specify at least one input movie.'
    usage()
  if not info.filename:
    print >>stderr, 'Specify exactly one output file.'
    usage()
  try:
    reorganize(info, args,
               range_str, step=step,
               is_video=is_video, kfinterval=kfinterval, 
               mp3seek=mp3seek, mp3skip=mp3skip)
  except RangeError, e:
    print >>stderr, 'RangeError:', e