scratch youtube using puredata
import sys, os, signal, subprocess, re
savepath = os.getcwd()

def Walk( root, recurse=1, pattern='*', return_folders=0 ):
    import fnmatch, os, string

    # initialize
    result = []

    # must have at least root folder
        names = os.listdir(root)
    except os.error:
        return result

    # expand pattern
    pattern = pattern or '*'
    pat_list = string.splitfields( pattern , ';' )

    # check each file
    for name in names:
        fullname = os.path.normpath(os.path.join(root, name))

        # grab if it matches our pattern and entry type
        for pat in pat_list:
            if fnmatch.fnmatch(name, pat):
                if os.path.isfile(fullname) or (return_folders and os.path.isdir(fullname)):

        # recursively scan other folders, appending results
        if recurse:
            if os.path.isdir(fullname) and not os.path.islink(fullname):
                result = result + Walk( fullname, recurse, pattern, return_folders )

    return result

def getframeinfo(input):
    length = None
    framerate = None
    f = os.popen("tcprobe -i '%s'" % input, "r")
    for l in f:
        m ="-f ([\d\.]+)", l)
        if m:
            framerate = float(
        m ="length: (\d+) frames", l)
        if m:
            length = int(

    return framerate, length

files = Walk(str(savepath), 1, '*.flv')

for file in files:
    os.system('ffmpeg -i '+str(file)+' -acodec pcm_s16le -sameq '+str(file[0:-3])+'mov')
    os.system('transcode -i '+str(file[0:-3])+'mov -y ffmpeg,wav -F mjpeg -G 1.2 -Z 640x480 --zoom_filter Mitchell -c 2100-2600 -m '+str(file[0:-4])+'temp.wav -o '+str(file[0:-3])+'avi')
    os.system('rm -rf '+str(file[0:-3])+'mov')
    os.system('sox '+str(file[0:-4])+'temp.wav -r 44100 '+str(file[0:-3])+'wav')
    os.system('rm -rf '+str(file[0:-4])+'temp.wav')
    os.system('normalize-audio '+str(file[0:-3])+'wav')
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License