News:

--

Main Menu

Help With Bash Script (cropping)

Started by remanifest, April 17, 2013, 02:51:26 AM

Previous topic - Next topic

remanifest

I have a bash script that automatically converts files of a certain type to another type, and along with that conversion, I would like to crop the files - there is unneeded black space on top and bottom, and the width is not a multiple of 8.  I can crop this easily enough through the GUI, but I'd really like to automate it in my bash script.

I have tried exporting the SpiderMonkey ECMAScript and taking the values I need from there, but it's not working the way I hoped it would (not suprised).  It would be awesome if someone can help me out with this, as I have about 100 files that need to be cropped the same way.

I tried using the --filters argument to no avail.  Any ideas?

Here is what I'm using so far:
avidemux --nogui --filters $FILTER --video-codec $VIDEOCODEC --audio-codec $AUDIOCODEC --force-alt-h264 --load "$FIL" --save "${FIL%.*}.avi" --quit

$FILTER is currently defined as follows: FILTER="app.video.addFilter('crop','left=2','right=2','top=46','bottom=46')"
Which is obviously not working... any help would be greatly appreciated - thanks!

mit

Export filters and codec settings as script, then load via --run argument.
You can see example here.

remanifest

#2
Fantastic!  Thank you for your quick response, this was so simple once you showed me how to do it.

For anyone else who comes across this thread, my script now looks like this:

#!/bin/bash
CROP="./crop.py"
for FIL in `ls *FLV | sort` ; do
  avidemux --nogui --load "$FIL" --run $CROP --save "${FIL%.*}.avi" --quit
done


Yes I know I should be using find, and shouldn't be using `, but this works great for my local purposes.  I'll probably rename CROP to PRESETS or something else since it's loading all my codecs too, but for now that's working beautifully.

For anyone interested, my crop.py looks like this:
//AD  <- Needed to identify//
//--automatically built--

var app = new Avidemux();

//** Video **

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

app.video.fps1000 = 29970;

//** Filters **
app.video.addFilter("crop","left=2","right=2","top=48","bottom=48");

//** Video Codec conf **
app.video.codecPlugin("92B544BE-59A3-4720-86F0-6AD5A2526FD2", "Xvid", "AQ=26", "(null)");

//** 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(1);
//app.Exit();

//End of script

Jan Gruuthuse

Thanks for sharing. If for some reason you find video shows artifacts with GUI or from CLI. check your settings from GUI Main Menu: Edit: Preferences: [Video] and change the
Default Postprocessing to
[ ] Horizontal deblocking
[ ] Vertical deblocking
[ ] Deringing
Strength: 0

this would show up in save project as: app.video.setPostProc(0,0,0)

This is not a credo and sometimes you do want this to be active when using degraded clips or noticing  this in processed video.
ringing artifacts, deblocking filter