Author Topic: Batch Creation Script  (Read 1035 times)

cpl_cadaver

  • Newbie
  • *
  • Posts: 1
Batch Creation Script
« on: February 24, 2016, 03:05:54 AM »
HI!

I just finished making a batch creation script using Python. The Script is for AVI DEMUX 2.5 windows version.

The Python version is 3.1.1

Well, anyways, the script takes the videos in a particular folder, grabs the filenames, then generates a simple conversion script in the AVI DEMUX jobs folder which can be run from the AVI DEMUX job script options for batch conversion.

Inputs are varied but the current iteration converts to XVID with MP3 audio with the output being 640 x 480 resolution.

Eventually, when I learn more Python (if ever), I am going to make a GUI for a script that will allow more options.

I made this script as I wanted a flexible batch creation capability but sadly, AVI DEMUX doesn't have that option. I have many videos and I want them to be consistent in encoding, size and most importantly, capable of being played back on my Creative Vision ZEN portable media player.

I had a bit of difficulty making a .js script from a Python source as some iterators are not all that compatible.

I'm sure a few people out there could use such a script and can easily modify it to accommodate other options.

Feel free to share but leave my name at the top so I can get credit.

*****Here is the Python Script*****
#Avi Demux batch conversion creation script
#Created by Bill "Cpl.Cadaver" Combs
import os
import tkinter
from tkinter import *
import string
# Variables for use later in this script

demuxinputfilenames = []
demuxoutputfilenames = []
GenNumberCounter = 0

# List of File Extensions. By no means complete.
# If there is a file extension you are aware of that isn't on the list,
# Feel free to add it. Just observe the naming conventions.

fileExtensions = ".AVI",".avi",".DIVX",".divx",".MP4",".mp4",".Mp4",".MOV",".mov"

# Opens three .js Files and read the contents for AviDemux Paramaters


a = open('C:/Users/New_New_Bill/Videos/avidemux_batch_script/script_master_1st.js','r')
Line1=a.read()

b = open('C:/Users/New_New_Bill/Videos/avidemux_batch_script/script_master_2nd.js','r')
Line2=b.read()

c = open('C:/Users/New_New_Bill/Videos/avidemux_batch_script/script_master_3rd.js','r')
Line3=c.read()

# Gets the list of filenames from the input directory.
# The output then creates the outputfile name with the proper extension
# which in this case is .avi  XVID with MP3 Encoding

FileListIn = os.listdir("C:/Users/New_New_Bill/Videos/AVI Demux Input")
for i in FileListIn:
    gamma = 0
    for j in fileExtensions:
        EndOfName=fileExtensions[gamma]
        TempName = FileListIn[GenNumberCounter]
        LengthOfName=len(EndOfName)
        delta=TempName[-LengthOfName:]
        if delta == EndOfName:
            alphaname=TempName.replace(EndOfName,".avi")
            demuxoutputfilenames.append(alphaname)
           
        gamma += 1
    GenNumberCounter += 1

# Generates the script by taking the old filenames and new filenames
# and adding them to the pre-generated script files and writing them
# to a pre-designated script file in the AVI Demux Jobs Folder

GenNumberCounter = 0
g = open('C:/Users/New_New_Bill/AppData/Roaming/avidemux/jobs/DVD_Ready_script.js','w')
h = open('C:/Users/New_New_Bill/AppData/Roaming/avidemux/jobs/DVD_Ready_script.js','a')

for i in demuxoutputfilenames:
    FileNameIn=(FileListIn[GenNumberCounter]+'");')
    FileNameOut=demuxoutputfilenames[GenNumberCounter]
    h.write (Line1)
    h.write (FileNameIn)
    h.write (Line2)
    h.write (demuxoutputfilenames[GenNumberCounter])
    h.write (Line3)
    GenNumberCounter +=1

g.close()
h.close()

#End of Python Script

*****First .JS Script*****

//AD  <- Needed to identify//
//--automatically built--
//--Project: C:\Users\New_New_Bill\AppData\Roaming\avidemux\jobs\/script_master.js

var app = new Avidemux();app.load("C:/Users/New_New_Bill/Videos/AVI Demux Input/

*****Second .JS Script


//** Postproc **
app.video.setPostProc(3,3,0);


app.video.addFilter("resize","w=640","h=480","algo=0");



//** Video Codec conf **
app.video.codecPlugin("92B544BE-59A3-4720-86F0-6AD5A2526FD2", "Xvid", "CBR=1000", "<?xml version='1.0'?><XvidConfig><XvidOptions><threads>0</threads><vui><sarAsInput>false</sarAsInput><sarHeight>1</sarHeight><sarWidth>1</sarWidth></vui><motionEstimation>high</motionEstimation><rdo>dct</rdo><bFrameRdo>false</bFrameRdo><chromaMotionEstimation>true</chromaMotionEstimation><qPel>false</qPel><gmc>false</gmc><turboMode>false</turboMode><chromaOptimiser>false</chromaOptimiser><fourMv>false</fourMv><cartoon>false</cartoon><greyscale>false</greyscale><interlaced>none</interlaced><frameDropRatio>0</frameDropRatio><maxIframeInterval>300</maxIframeInterval><maxBframes>2</maxBframes><bFrameSensitivity>0</bFrameSensitivity><closedGop>false</closedGop><packed>false</packed><quantImin>1</quantImin><quantPmin>1</quantPmin><quantBmin>1</quantBmin><quantImax>31</quantImax><quantPmax>31</quantPmax><quantBmax>31</quantBmax><quantBratio>150</quantBratio><quantBoffset>100</quantBoffset><quantType>h.263</quantType><intraMatrix><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value></intraMatrix><interMatrix><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value></interMatrix><trellis>true</trellis><singlePass><reactionDelayFactor>16</reactionDelayFactor><averagingQuantiserPeriod>100</averagingQuantiserPeriod><smoother>100</smoother></singlePass><twoPass><keyFrameBoost>10</keyFrameBoost><maxKeyFrameReduceBitrate>20</maxKeyFrameReduceBitrate><keyFrameBitrateThreshold>1</keyFrameBitrateThreshold><overflowControlStrength>5</overflowControlStrength><maxOverflowImprovement>5</maxOverflowImprovement><maxOverflowDegradation>5</maxOverflowDegradation><aboveAverageCurveCompression>0</aboveAverageCurveCompression><belowAverageCurveCompression>0</belowAverageCurveCompression><vbvBufferSize>0</vbvBufferSize><maxVbvBitrate>0</maxVbvBitrate><vbvPeakBitrate>0</vbvPeakBitrate></twoPass></XvidOptions></XvidConfig>");




//** Audio **
app.audio.reset();
app.audio.codec("Lame",128,20,"80 00 00 00 00 00 00 00 01 00 00 00 02 00 00 00 00 00 00 00 ");


app.audio.normalizeMode=0;
app.audio.normalizeValue=0;
app.audio.delay=0;
app.audio.mixer="NONE";


app.setContainer("AVI");


setSuccess(app.save("C:/Users/New_New_Bill/Videos/AVI Demux Output/

*****Third .JS Script

"));
//app.Exit();

//End of script