This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
tutorial:batch_processing [2011/01/09 16:34] agent_007 more linux examples |
tutorial:batch_processing [2011/04/17 13:20] agent_007 [Combination of command-line and JS scripting] |
||
---|---|---|---|
Line 28: | Line 28: | ||
<code bash> | <code bash> | ||
#!/bin/bash | #!/bin/bash | ||
- | VAR="batchfiles.txt" | ||
VIDEOCODEC="Xvid" | VIDEOCODEC="Xvid" | ||
AUDIOCODEC="MP3" | AUDIOCODEC="MP3" | ||
- | ls *.mp4 | sort > $VAR # Collect the files in the current directory | + | for FIL in `ls *mp4 | sort` ; do |
- | cat $VAR | while read line; do # Loop read the filenames from the file | + | avidemux2 --video-codec $VIDEOCODEC --audio-codec $AUDIOCODEC --force-alt-h264 --load "$FIL" --save ${FIL%.*}.avi --quit |
- | INPUT=$(echo ${line}) # Grab the next new filename | + | |
- | OUTPUT=${INPUT%.*4} # Remove shortest match of characters between the '. ' and the '4' at end of string | + | |
- | OUTPUT+=".avi" # Append new extension | + | |
- | avidemux2 --video-codec $VIDEOCODEC --audio-codec $AUDIOCODEC --force-alt-h264 --load "$INPUT" --save "$OUTPUT" --quit | + | |
done | done | ||
- | rm $VAR # Remove the text file with the file names | ||
</code> | </code> | ||
(this will create **something.avi** from **something.mp4**) | (this will create **something.avi** from **something.mp4**) | ||
Line 61: | Line 55: | ||
VIDEOBITRATE="cbr=512" | VIDEOBITRATE="cbr=512" | ||
AUDIOBITRATE="64" | AUDIOBITRATE="64" | ||
- | ls *.mp4 | sort > $VAR # Collect the files in the current directory | + | for FIL in `ls *mp4 | sort` ; do |
- | cat $VAR | while read line; do # Loop read the filenames from the file | + | avidemux2 --video-codec $VIDEOCODEC --video-conf $VIDEOBITRATE --audio-codec $AUDIOCODEC --audio-bitrate $AUDIOBITRATE --force-alt-h264 --load "$FIL" --save ${FIL%.*}.avi --quit |
- | INPUT=$(echo ${line}) # Grab the next new filename | + | |
- | OUTPUT=${INPUT%.*4} # Remove shortest match of characters between the '. ' and the '4' at end of string | + | |
- | OUTPUT+=".avi" # Append new extension | + | |
- | avidemux2 --video-codec $VIDEOCODEC --video-conf $VIDEOBITRATE --audio-codec $AUDIOCODEC --audio-bitrate $AUDIOBITRATE --force-alt-h264 --load "$INPUT" --save "$OUTPUT" --quit | + | |
done | done | ||
- | rm $VAR # Remove the text file with the file names | ||
</code> | </code> | ||
(this will create **something.avi** from **something.mp4**) | (this will create **something.avi** from **something.mp4**) | ||
Line 223: | Line 212: | ||
</code> | </code> | ||
+ | You can create scripts quite easily by yourself. You can apply needed settings via GUI and then use **File -> Save Project As...** to create text file that contains all settings. Then you can open that file in text editor and copy+paste needed stuff to new script (or replaces parts of other script). | ||
==== Combination of command-line and JS scripting ==== | ==== Combination of command-line and JS scripting ==== | ||
Line 263: | Line 252: | ||
<code bash> | <code bash> | ||
#!/bin/bash | #!/bin/bash | ||
- | VAR="batchfiles.txt" | + | for FIL in `ls *mp4 | sort` ; do |
- | ls *.mp4 | sort > $VAR # Collect the files in the current directory | + | avidemux2 --force-alt-h264 --load "$FIL" --run something.js --save ${FIL%.*}.avi --quit |
- | cat $VAR | while read line; do # Loop read the filenames from the file | + | |
- | INPUT=$(echo ${line}) # Grab the next new filename | + | |
- | OUTPUT=${INPUT%.*4} # Remove shortest match of characters between the '. ' and the '4' at end of string | + | |
- | OUTPUT+=".avi" # Append new extension | + | |
- | avidemux2 --force-alt-h264 --load "$INPUT" --run something.js --save "$OUTPUT" --quit | + | |
done | done | ||
- | rm $VAR # Remove the text file with the file names | ||
</code> | </code> | ||
(this will create **something.avi** from **something.mp4**) | (this will create **something.avi** from **something.mp4**) | ||
- | If you create your own combine batch settings, make sure order of command-line parameters is always --load something, --run something and --save something (AVIdemux will run these options in give order). | + | If you create your own combine batch settings, make sure order of command-line parameters is always --load something, --run something and --save something (AVIdemux will run these options in given order). |
- | + | ||
==== Tips ==== | ==== Tips ==== | ||
- | * You can replace **avidemux2** with **avidemux2_cli** if you want to process files via GUI | + | * You can replace **avidemux2** with **avidemux2_cli** if you want to process files without GUI |
* You can use **--nogui** option in case you want to suppress all dialogs (it must be first option!) | * You can use **--nogui** option in case you want to suppress all dialogs (it must be first option!) |