Example #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)
Example #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)
Example #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
Example #4
0
def main(argv):
  import getopt
  def usage():
    print ('usage: %s [-d] [-n] [-o filename] [-t {flv|mpeg|swf5|swf7|vnc}]'
           ' [-e encoding] [-N] [-C clipping] [-r framerate] [-s scaling] [-z] [-m] [-a] [-V]'
           ' [-S subprocess] [-P pwdfile] [host[:display] [port]]' % argv[0])
    return 100
  try:
    (opts, args) = getopt.getopt(argv[1:], 'dno:t:e:NC:r:S:P:s:zmaVR:')
  except getopt.GetoptError:
    return usage()
  (debug, console, outtype, subprocess, merge, pwdfile, isfile) = (0, False, None, None, False, None, False)
  (cursor, host, port, preferred_encoding) = (True, 'localhost', 5900, (0,))
  info = SWFInfo()
  for (k, v) in opts:
    if k == '-d': debug += 1
    elif k == '-n': console = True
    elif k == '-t': outtype = v
    elif k == '-e': preferred_encoding = tuple([ int(i) for i in v.split(',') ])
    elif k == '-N': cursor = False
    elif k == '-S': subprocess = Subprocess(v)
    elif k == '-a': subprocess = RecordingThread(v)
    elif k == '-m': merge = True
    elif k == '-P': pwdfile = v
    elif k == '-V': isfile = True
    elif k == '-o':
      info.filename = v
    elif k == '-R':
      reconnect = v
    elif k == '-C':
      try:
        info.set_clipping(v)
      except ValueError:
        print 'Invalid clipping specification:', v
        return usage()
    elif k == "-r":
      info.framerate = int(v)
    elif k == "-z":
      info.set_scalable(True)
    elif k == '-s':
      info.scaling = float(v)
      assert 0 < info.scaling and info.scaling <= 1.0, 'Invalid scaling.'
  if not outtype:
    if info.filename:
      if info.filename.endswith('.vnc'):
        outtype = 'vnc'
      elif info.filename.endswith('.swf'):
        outtype = 'swf5'
      elif info.filename.endswith('.mpg') or info.filename.endswith('.mpeg'):
        outtype = 'mpeg'
      elif info.filename.endswith('.flv'):
        outtype = 'flv'
    else:
      outtype = 'swf5'
  if outtype not in ('swf5','swf7','vnc','mpeg','flv'):
    print 'Please specify the output type or file extension.'
    return usage()
  if cursor:
    preferred_encoding += (-232,-239,)
  if 1 <= len(args):
    if ':' in args[0]:
      i = args[0].index(':')
      host = args[0][:i] or 'localhost'
      port = int(args[0][i+1:])+5900
    else:
      host = args[0]
  if 2 <= len(args):
    port = int(args[1])
  if console:
    if not info.filename:
      print 'Please specify the output filename.'
      return usage()
    vncfile = None
    if isfile:
      vncfile = sys.stdin
      if args:
        vncfile = file(args[0], 'rb')
    vnc2swf(info, outtype, host, port,
            preferred_encoding=preferred_encoding,
            subprocess=subprocess, pwdfile=pwdfile, vncfile=vncfile,
            merge=merge, debug=debug, reconnect=reconnect)
  else:
    tempdir = os.path.join(tempfile.gettempdir(), 'pyvnc2swf')
    try:
      os.mkdir(tempdir)
    except OSError:
      pass
    VNC2SWFWithTk(tempdir, info, outtype, host, port,
                  preferred_encoding=preferred_encoding,
                  subprocess=subprocess, pwdfile=pwdfile,
                  debug=debug).run()
  return
Example #5
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