欢迎来到虫虫下载站 | 资源下载 资源专辑 关于我们
虫虫下载站

makepli.py

Motion JPEG编解码器源代码
PY
第 1 页 / 共 2 页
字号:
    s = s + "must preceed clips and comments may be placed anywhere.\n\n"    sst = 1    s = s + str(st) + "." + str(sst) + " Directives\n\n"    s = s + "Directives are lines that begin with '$<directiveName>'. Currently there is only one\n"    s = s + "directive, $format:\n\n"    s = s + "$format offset:<units> <lenOrEnd type>:<units>\n"    s = s + "\twhere <units> is either 's' (seconds) or 'f' (frames);\n"    s = s + "\t<lenOrEnd type> is either 'length', meaning that the lenOrEnd value\n"    s = s + "\tspecifies the clip length, or 'stop' meaning that the lenOrEnd value\n"    s = s + "\tspecifies the end of the clip relative to the offset.\n"    s = s + "If there is more than one $format line, the last one takes precedence.\n\n"    s = s + "Format Examples:\n\n"    s = s + "\t$format offset:s length:s\n"    s = s + "\t$format offset:f length:s\n"    s = s + "\t$format offset:f stop:f\n\n"    st = st + 1    s = s + str(st) + " Clips\n\n"    s = s + "Clips are lines that specify the source files, the position to start\n"    s = s + "in the clip, and the position to end in the clip:\n\n"    s = s + "<filename> <offset> <lenOrEnd>\n"    s = s + "\twhere <filename> is the name of the lav source;\n"    s = s + "\t<offset> is the starting position in the clip as determined by the $format;\n"    s = s + "\t<lenOrEnd> is the ending position in the clip as determined by the $format.\n\n"    s = s + "Both start and end may be expressed in frames or seconds as determined by the $format.\n\n"    s = s + "Clip Examples:\n\n"    s = s + "\tintro.avi 0 25\n"    s = s + "\tmain.avi 15.37 30.25\n\n"    s = s + "Note that the numeric values may be either integers or floats; the proper\n"    s = s + "type is determined by the $format; if the type is frames, the value should be an int;\n"    s = s + "if the type is seconds, the value can be a float.\n\n"    s = s + "A full example\n\n"    s = s + "Given the input file montage.ppli containing the following:\n\n"    s = s + "#a sample ppli file\n"    s = s + "$format offset:f length:s\n"    s = s + "intro.avi 0 30\n"    s = s + "clip.avi 61 25.37\n"    s = s + "end.avi 0 30\n\n"    s = s + "Running this command from a shell:\n\n"    s = s + "\t$ python makePLI.py --file montage.ppli > montage.pli\n\n"    s = s + "produces this output:\n\n"    s = s + "LAV Pipe List\n"    s = s + "NTSC\n"    s = s + "3\n"    s = s + "lav2yuv -v 0 -o $o -f $n intro.avi\n"    s = s + "lav2yuv -v 0 -o $o -f $n clip.avi\n"    s = s + "lav2yuv -v 0 -o $o -f $n end.avi\n"    s = s + "868\n"    s = s + "1\n"    s = s + "0 0\n"    s = s + "-\n"    s = s + "30\n"    s = s + "2\n"    s = s + "0 869\n"    s = s + "1 60\n"    s = s + "transist.flt -v 0 -s $o -n $n -o 0 -O 255 -d 30\n"    s = s + "699\n"    s = s + "1\n"    s = s + "1 90\n"    s = s + "-\n"    s = s + "30\n"    s = s + "2\n"    s = s + "1 790\n"    s = s + "2 0\n"    s = s + "transist.flt -v 0 -s $o -n $n -o 0 -O 255 -d 30\n"    s = s + "868\n"    s = s + "1\n"    s = s + "2 30\n"    s = s + "-\n\n"    s = s + "Error reporting\n\n"    s = s + "Some attempt is made to spot errors. If a specified clip is not long\n"    s = s + "enough to satisfy the required lengths, you will get an error message like:\n\n"    s = s + "(makePLI.py) - intro.avi is too short; total needed: 51 frames; actual length: 44 frames\n\n"    s = s + "Notes\n\n"    s = s + "It seems that there is a limit on the number of clips that can be\n"    s = s + "processed at once. I do not know where the limitation lies. On my system\n"    s = s + "the limit seems to be about 15 clips. To get around this problem\n"    s = s + "I break up the lists into two files, then combine the result with\n"    s = s + "another ppli and lavpipe operation.\n\n"    s = s + "Author\n\n"    s = s + "The program and the documentation were written by Bob Matlin <bob.kannon@excite.com>.\n\n"    return(s)#mainif (len(sys.argv) < 2 or '--help' == sys.argv[1]):    print(getUsage())    sys.exit(0)#default valuesfileName = NonetransLen = 30 #each transition is 30 frames#get argumentsfor i in range(len(sys.argv)):    if (sys.argv[i] == '--file'):        i = i + 1        fileName = sys.argv[i]    elif (sys.argv[i] == '--transLen'):        i = i + 1        transLen = int(sys.argv[i])    elif (sys.argv[i] == '--man'):        s = getMan()        print s        sys.exit(0)        if (fileName == None):    s = "(makePLI.py) - no file specified.\n\n"    s = s + getUsage()    raise Exception(s)if (not os.path.exists(fileName)):    s = "(makePLI.py) - given file does not exist: '" + str(fileName) + "'\n\n"    s = s + getUsage()    raise Exception(s)    #read filef = open(fileName)flist = []l = "a"ppliFile = PPLIFile()while (l):    l = f.readline()    clip = ppliFile.handleLine(l)    if (clip != None):        flist.append(clip)    #the pli headers = 'LAV Pipe List\n's += 'NTSC\n's += str(len(flist))print s#the stream listst = 'lav2yuv -v 0 -o $o -f $n 'for i in range(len(flist)):    c = flist[i]    s = st + c.fileName    print s#build sequences#first clipidx = 0##print "sequence " + str(idx)c = flist[idx]if (1 + transLen >= c.lengthFrames):    tot = 1 + transLen    raise "(makePLI.py) - " + c.fileName + " is too short; total needed: " + str(tot) + " frames; actual length: " + str(c.lengthFrames) + " frames"l = c.lengthFrames - transLen - 1s = str(l) + '\n's += '1\n's += str(idx) + ' ' + str(c.lastFrame) + '\n'c.lastFrame += ls += '-'print s#the middle sequencestransist = 'transist.flt -v 0 -s $o -n $n -o 0 -O 255 -d 'seqn = -1for idx in range(len(flist) - 1):    #the transition    seqn += 2    ##print "sequence " + str(seqn)    l = transLen    c1 = flist[idx]    c2 = flist[idx + 1]    if (1 + (2*transLen + 1)  > c2.lengthFrames):        #there is a 1 frame minimum for this clip on its own; the extra 1 is for 1 frame at the end        tot = 1 + 2*transLen + 1        raise "(makePLI.py) - seq " + str(seqn) + ": " + c2.fileName + " is too short; needed: " + str(tot) + ", available: " + str(c2.lengthFrames)    s = str(l) + '\n'    s += '2\n'    s += str(idx) + ' ' + str(c1.lastFrame + 1) + '\n'    c1.lastFrame += l     if (c1.lastFrame >= c1.clipEnd):        raise "(makePLI.py) - " + c1.fileName + " will go past the clip end."            s += str(idx + 1) + ' ' + str(c2.lastFrame) + '\n'    c2.lastFrame += l    s += transist + str(l)    print s    if (idx + 1 == len(flist) - 1): continue    #the next clip    ##print "sequence " + str(seqn + 1)    l = c2.lengthFrames - (2*transLen + 1)    s = str(l) + '\n'    s += '1\n'    s += str(idx + 1) + ' ' + str(c2.lastFrame) + '\n'    c2.lastFrame += l    if (c2.lastFrame >= c2.clipEnd):        raise "(makePLI.py) - " + c2.fileName + " will go past the clip end."    s += '-'    print s#last frame##print "sequence: " + str(seqn + 2)idx = len(flist) - 1c = flist[idx]l = c.lengthFrames - transLen - 1s = str(l) + '\n's += '1\n's += str(idx) + ' ' + str(c.lastFrame) + '\n'c.lastFrame += lif (c.lastFrame >= c.clipEnd):    raise "(makePLI.py) - " + c.fileName + " will go past the clip end."s += '-'print s#debug##for c in flist:##    print "file: " + c.fileName + ", end: " + str(c.clipEnd) + ", lastFrame: " + str(c.lastFrame)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -