Python Scripts

Script to walk though directory (Directory Traversal) and find out .dmp files and change the modes.

#!/usr/bin/python
import os
allFiles = os.walk(os.getcwd())
print(" Current Directory is : " + os.getcwd())
for i in allFiles:
    for x in i[2]:
        print(x)
        if x.find('.MP4') > 0:
            #--------Extract Audio Conversion to MP3----------------
        #os.system("c:\Softwares\MPlayer\mplayer -ao pcm:file=in.wav -vo NULL \"" + x + "\"")
            #os.system("c:\Softwares\lame.exe -b 96 -h in.wav \""+ x[0:len(x)-9] + "\".mp3")
            #--------Convert to x264_vorbis using x264---------------
            print(x)
            #os.system(r"c:\Softwares\MPlayer\mplayer -ao pcm:file=in.wav -vo yuv4mpeg:file=in.y4m " + x)
            #os.system(r"C:\Softwares\x264 in.y4m --crf 26 --profile high --preset placebo -o test.mkv")
            #os.system(r"C:\Softwares\vorbis-tools\oggenc --managed -q -1 in.wav")
            #os.system(r"C:\Softwares\mkvtoolnix\mkvmerge.exe -o " + x + r"1.mkv test.mkv in.ogg")
            #--------Convert to x264_vorbis using ffmpeg--------------
        #(scale : -s 640x480 or 800x480)   
            #os.system(r"C:\Softwares\ffmpeg.exe -i " + x + " -vcodec libx264 -crf 26  -flags +loop -g 250 -refs 6 -bf 16 -b_strategy 2 -me_method umh -coder 1  -subq 6 -partitions +parti4x4+parti8x8+partp8x8+partb8x8 -flags2 +bpyramid+wpred+mixed_refs+dct8x8 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -directpred 1 -flags2 +fastpskip -dts_delta_threshold 1  -acodec libvorbis -aq 0 " + x + ".mkv")
            #-----Create webm video-------------
        #just replace libx264 with libvpx in above commandline
            os.system(r"ffmpeg -y -i " + x + " -threads 0 -f webm -vcodec libvpx -speed 0 -g 250 -qmin 2 -qmax 51 -rc_buf_aggressivity 1 -acodec libvorbis -aq 0 " + x[0:len(x)-4] + ".webm")



truncate deleted files.


#!/usr/bin/python
import commands

(exitstatus, outtext) = commands.getstatusoutput('lsof | grep deleted | grep /u01/app')
lines = outtext.splitlines()
pids = []
for line in lines:
        pid = line.split()[1]
        if pid not in pids:
                pids.append(pid)

for pid in pids:
        (exitstatus, outtext) = commands.getstatusoutput('ls -lrth /proc/' + pid + '/fd | grep deleted | grep /u01/app');
        lines = outtext.splitlines()
        for line in lines:
                print 'cat /dev/null>/proc/' + pid + '/fd/' + line.split()[7]
                print 'echo ' + line.split()[9]



Subpages (1): Python IDE
Č
ċ
ď
convert.py
(1k)
Jobin Augustine,
Aug 18, 2009 8:35 AM
ċ
ď
filerename.py
(0k)
Jobin Augustine,
Sep 4, 2009 7:29 AM

Comments

Jobin Augustine - Aug 18, 2009 8:36 AM

convert.py is to convert movies using x264 and voribis in windows. paths are hard coded