HandbrakeCLI + AACGain video encode button

Thought I'd put this up here in case it's useful to someone else. You will (probably) need to change the paths depending where you put things. It all outputs to a single Script window (so quick and easy checking of the log).The window title displays what is currently happening for a quick reference.

Output is 640x480 (maximum of each dimension) .m4v file (same as an .mp4 but video only), size for a movie is normally somewhere around 1gb, but this is quality based and not size based. These play perfectly well via my iPhone / AppleTV etc.

Both Handbrake and AACGain are easy to find online - but the base script itself can be altered for anything, just change the commands between the ":encode" and "goto:eof" lines - the "call:encode {file$} {destpath$}{file$|ext=m4v}" is duplicated by DOpus once for each file (why it's not using a loop or anything). The initial "for..." loop counts the total number of files being passed.

<?xml version="1.0"?> <button backcol="none" display="both" label_pos="right" textcol="none"> <label>Encode M4V</label> <tip>Encode any video file to .m4v by quality</tip> <icon1>#video</icon1> <function type="batch"> <instruction>@disablenosel</instruction> <instruction>@filesonly</instruction> <instruction>@runmode:min</instruction> <instruction>@externalonly</instruction> <instruction /> <instruction>set _count=0</instruction> <instruction>set _total=0</instruction> <instruction>for %%i in ({allfileshort$}) do set /A _total+=1</instruction> <instruction /> <instruction>call:encode {file$} {destpath$}{file$|ext=m4v}</instruction> <instruction /> <instruction>goto:eof</instruction> <instruction /> <instruction>:encode</instruction> <instruction>set /A _count+=1</instruction> <instruction>IF EXIST &quot;%~2&quot; (</instruction> <instruction> echo Skipping %~n1</instruction> <instruction>) ELSE (</instruction> <instruction> title Encoding %~n1 [%_count%/%_total%]</instruction> <instruction> echo Encoding %~n1</instruction> <instruction> &quot;C:\Program Files\HandBrake\HandBrakeCLI.exe&quot; -i &quot;%~1&quot; -t 1 -c 1 -o &quot;%~2&quot; -O -f m4v -X 640 -Y 480 --loose-anamorphic --decomb -e x264 -q 20 -a 1 -E faac -B 160 -R 48 -6 dpl2 -x me=umh -v</instruction> <instruction> title Normalizing %~n1 [%_count%/%_total%]</instruction> <instruction> echo Normalizing %~n1</instruction> <instruction> &quot;C:\Program Files (x86)\aacgain\aacgain.exe&quot; /c /e /r /p &quot;%~2&quot;</instruction> <instruction>)</instruction> <instruction>goto:eof</instruction> </function> </button>

First of all I like this butten and use it often. I shall try to ecplain what I want with this bad english. Everytime I take a movie with mobile its have to be rotate and handbrake can do this. I can not program so I need help. It would be nice to have a button that rotate video 90 degrees and keep the original size. I put the command in handbrake under video extra options:. The command there is , --rotate=4 It doesnt work without the initial comma and without the space. Is it possible to create a button to do that I will be very happy.
Regards Stefan :smiley:

This button should do what you want. Converts with the original resolution and rotates the video 90 degrees.

<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
	<label>Encode M4V</label>
	<tip>Encode any video file to .m4v by quality</tip>
	<icon1>#video</icon1>
	<function type="batch">
		<instruction>@disablenosel</instruction>
		<instruction>@filesonly</instruction>
		<instruction>@runmode:min</instruction>
		<instruction>@externalonly</instruction>
		<instruction />
		<instruction>set _count=0</instruction>
		<instruction>set _total=0</instruction>
		<instruction>for %%i in ({allfileshort$}) do set /A _total+=1</instruction>
		<instruction />
		<instruction>call:encode {file$} {destpath$}{file$|ext=m4v}</instruction>
		<instruction />
		<instruction>goto:eof</instruction>
		<instruction />
		<instruction>:encode</instruction>
		<instruction>set /A _count+=1</instruction>
		<instruction>IF EXIST &quot;%~2&quot; (</instruction>
		<instruction>  echo Skipping %~n1</instruction>
		<instruction>) ELSE (</instruction>
		<instruction>  title Encoding %~n1 [%_count%/%_total%]</instruction>
		<instruction>  echo Encoding %~n1</instruction>
		<instruction>  &quot;C:\Program Files\HandBrake\HandBrakeCLI.exe&quot; -i &quot;%~1&quot; -t 1 -c 1 -o &quot;%~2&quot; -O , --rotate=4 -f m4v --keep-display-aspect --decomb -e x264 -q 20 -a 1 -E faac -B 160 -R 48 -6 dpl2 -x me=umh -v</instruction>
		<instruction>  title Normalizing %~n1 [%_count%/%_total%]</instruction>
		<instruction>  echo Normalizing %~n1</instruction>
		<instruction>  &quot;C:\Program Files (x86)\aacgain\aacgain.exe&quot; /c /e /r /p &quot;%~2&quot;</instruction>
		<instruction>)</instruction>
		<instruction>goto:eof</instruction>
	</function>
</button>

Great. I'm very happy for that and big thanks for your help :smiley: