Page 1 of 2

### Batch to multiple sizes

Posted: Tue Jun 07, 2016 3:08 pm
I would like handbrake to be able batch a file to multiple sizes. when I use VOD with Wowza media server I have to have each file sized to all sizes so that JWPlayer will be able to auto select the best file based on internet speed, IE: 1920x108,1280x720, 960x540, 640x360.

to save time so I dont have to do each file manually.

0.10.5.0 64bit

Windows 10 Pro 64bit

### Re: Batch to multiple sizes

Posted: Tue Jun 07, 2016 4:56 pm
The simplest way to do this would be to create a batch file, something like:

handbrakecli -i c:\in.mkv -o c:\out1920.mkv -w 1920 etc
handbrakecli -i c:\in.mkv -o c:\out1280.mkv -w 1280 etc
handbrakecli -i c:\in.mkv -o c:\out960.mkv -w 960 etc
handbrakecli -i c:\in.mkv -o c:\out640.mkv -w 640 etc

### Re: Batch to multiple sizes

Posted: Thu Jun 09, 2016 5:53 pm
ok, sounds great but how and where do I do that?

John

### Re: Batch to multiple sizes

Posted: Thu Jun 09, 2016 6:11 pm
ok this is working,

I would like it to just get any file I have in the "VIDEO" folder and output to the "MP4" folder keeping the same name on the file, is that possible? ie: C:\Users\John\Desktop\VIDEO\test.mov to C:\Users\John\Desktop\MP4\test1920.mp4, etc... I don't want to have to change the name of the file or the script each time.

I want to put a file in the Video folder (filename.mov) and have it output to the MP4 folder (filename1920.mp4) and I dont want to have to change the "filename" is there a wildcard or code for "filename"?

handbrakecli -i C:\Users\John\Desktop\VIDEO\test.mov -o C:\Users\John\Desktop\MP4\1920.mp4 -w 1920 --preset="Normal"
handbrakecli -i C:\Users\John\Desktop\VIDEO\test.mov -o C:\Users\John\Desktop\MP4\1280.mp4 -w 1280 --preset="Normal"
handbrakecli -i C:\Users\John\Desktop\VIDEO\test.mov -o C:\Users\John\Desktop\MP4\960.mp4 -w 960 --preset="Normal"
handbrakecli -i C:\Users\John\Desktop\VIDEO\test.mov -o C:\Users\John\Desktop\MP4\640.mp4 -w 640 --preset="Normal"

### Re: Batch to multiple sizes

Posted: Thu Jun 09, 2016 8:35 pm
Batch file for which operating system?

Windows uses %~n1 for "file name without extension", so I have batch files like this:

Code: Select all

title "%~n1" Droid & "C:\Program Files\Handbrake\HandBrakeCLI.exe" -i "Z:\Fairy Tail\%~n1.mkv" -t 1 -o "V:\Anime\Tablet\dubbed\Fairy Tail\%~n1.m4v" -O -f mp4 -w 720 --loose-anamorphic  -e x264 -q 22 --vfr  -a 1 -E faac -B 128 -6 dpl2 -R Auto -D 0 --gain=0 --audio-copy-mask none --audio-fallback ffac3 --subtitle 2 --subtitle-burn=1 -x weightp=0:cabac=0 --verbose=1 --previews 30

title "%~n1" & "C:\Program Files\Handbrake\HandBrakeCLI.exe" -i "Z:\Fairy Tail\%~n1.mkv" -t 1 -o "V:\Anime\dubbed\Fairy Tail\%~n1.mkv"  -f mkv --strict-anamorphic  -e x264 -q 20 --vfr  -a 1,2,4 -E faac,copy:ac3,faac -B 160,0,160 -6 dpl2,auto,dpl2 -R Auto,Auto,Auto -D 0,0,0 --gain=0,0,0 --audio-copy-mask none --audio-fallback ffac3 --subtitle 2,1 --markers="C:\Users\jeffb\AppData\Local\Temp\Fairy Tail HD165-1-chapters.csv" -x ref=1:weightp=1:subq=2:rc-lookahead=10:trellis=0:8x8dct=0 --verbose=1 --previews 30

I can then call the batch file with the name of the source as an argument, and it will deal with the file names for output from that source.

### Re: Batch to multiple sizes

Posted: Fri Jun 10, 2016 12:57 am
OS is windows 10 Pro 64bit

%~n1 is not working for me?

handbrakecli -i C:\Users\John\Desktop\VIDEO\%~n1.mov -o C:\Users\John\Desktop\MP4\%~n11920.mp4 -w 1920 --preset="Normal"

### Re: Batch to multiple sizes

Posted: Fri Jun 10, 2016 2:57 pm
You need quotes, like I had in my sample...

Code: Select all

handbrakecli -i "C:\Users\John\Desktop\VIDEO\%~n1.mov" -o "C:\Users\John\Desktop\MP4\%~n11920.mp4" -w 1920 --preset="Normal"
Without quotes around the file names, you can end up with incorrect names if the file name has spaces in it.

You'll also need quotes around the file name when you call the batch file.

### Re: Batch to multiple sizes

Posted: Fri Jun 10, 2016 4:30 pm
I tried that, not working. this is just a single file, not a DVD, etc...

libbluray/bdnav/index_parse.c:162: indx_parse(): error opening C:\Users\John\Desktop\VIDEO\.mov/BDMV/index.bdmv
libbluray/bdnav/index_parse.c:162: indx_parse(): error opening C:\Users\John\Desktop\VIDEO\.mov/BDMV/BACKUP/index.bdmv
libbluray/bluray.c:2182: nav_get_title_list(C:\Users\John\Desktop\VIDEO\.mov) failed
[09:28:03] bd: not a bd - trying as a stream/file instead
libdvdnav: Using dvdnav version 5.0.1
libdvdread: Could not open input: No such file or directory
libdvdnav: vm: failed to open/read the DVD
[09:28:03] dvd: not a dvd - trying as a stream/file instead
[09:28:03] hb_stream_open: open C:\Users\John\Desktop\VIDEO\.mov failed
[09:28:03] scan: unrecognized file type
[09:28:03] libhb: scan thread found 0 valid title(s)
No title found.

### Re: Batch to multiple sizes

Posted: Fri Jun 10, 2016 4:39 pm
How are you calling the batch file?

This works inside a batch file, not as a command line by itself to make handbrake run. Handbrake doesn't have a looping structure built into it.

Use a text editor to create the batch file "test.bat", with the contents:

Code: Select all

handbrakecli -i "C:\Users\John\Desktop\VIDEO\%~n1.mov" -o "C:\Users\John\Desktop\MP4\%~n11920.mp4" -w 1920 --preset="Normal"
You would then execute using:

Code: Select all

test "my video name goes here.mov"
Then the %~n1 will be replaced with "video name goes here" (the extension is removed).

(note that there are several scripts in the Support/CLI section for Windows, using CMD, PowerShell, and other scripting languages to do this sort of thing)

### Re: Batch to multiple sizes

Posted: Fri Jun 10, 2016 9:22 pm
I think you are misunderstanding what I am trying to do. I don't want to have to edit the batch file every time and put a name in there.

I want to put a file in the "VIDEO" folder what ever the name, kids.mov and have the batch file out put 4 sizes named kids1920.mp4, kids1280.mp4 etc... I want it to just pickup the and use the name of the original file. in Handbrake it will do this but wont do the 4 sizes at one time. the batch file does work doing the 4 sizes, but I want it to do it using the name of the file I put in the VIDEO folder, the name will be different every time.

### Re: Batch to multiple sizes

Posted: Fri Jun 10, 2016 10:03 pm
That can all be automated with a minimal amount of scripting in the batch file.

### Re: Batch to multiple sizes

Posted: Sat Jun 11, 2016 2:49 am
so how do I figure this out, 3 days of trying so far?

it takes me about 20 minute just to add one movie to Wowza, the code on website, the title picture, etc, just trying to make it a little simpler, I cant believe things like this are still so much work, seems simple. take a file, name it size it 4 ways and put it in the folder I want, wow, I guess I am asking way to much as always. so much for technology.

Thanks,
John

### Re: Batch to multiple sizes

Posted: Sat Jun 11, 2016 4:10 am
Not saying to edit the file each time; The script I posted above is one I have for a particular long-running series, where there have been (so far) 239 episodes, and I have a few others. It would be possible to make it more flexible, but rarely do different series have the same audio/subtitle settings, so there are limits to "it does it without me having to edit".

In this case, you can look at several of the existing scripting examples here, and make one major change... When the command line is constructed, you make as many copies of that line as you want different resolutions.

The majority of the problem of scripting is finding what files to operate on. I've seen over a dozen scripts posted here, half for Windows, which do that part just fine, and build a command line to execute. You want to create 4 command lines instead of 1, with a few parameters different between them. It shouldn't take that one to modify one.

But even if you want to do it for your own education (a worthy goal in and of itself), studying how others do it is part of the learning process.

### Re: Batch to multiple sizes

Posted: Sat Jun 11, 2016 8:51 pm
johnzapf wrote:so how do I figure this out, 3 days of trying so far?

it takes me about 20 minute just to add one movie to Wowza, the code on website, the title picture, etc, just trying to make it a little simpler, I cant believe things like this are still so much work, seems simple. take a file, name it size it 4 ways and put it in the folder I want, wow, I guess I am asking way to much as always. so much for technology.
I'm a bit confused, what have you been trying to do for 3 days?

The technology for this kind of automation is simple and readily available. A bit of variable substitution in the appropriate scripting language for your platform shouldn't take 3 days for someone of average intelligence.

Are you waiting for someone to spoon-feed you a script tailored specifically for your use case?

### Re: Batch to multiple sizes

Posted: Sun Jun 12, 2016 12:47 am
I can write the script, I am simply trying to find a command? if someone knows the command to use the original file name in the output file that would be great, that is all I am asking for.

Thanks.

### Re: Batch to multiple sizes

Posted: Sun Jun 12, 2016 1:09 am
Literally the first hit on Google for "variable substitution windows batch" covers it http://cplusplus.bordoon.com/cmd_exe_variables.html

### Re: Batch to multiple sizes

Posted: Sun Jun 12, 2016 1:27 am
Hmm, non of that works form me, thanks for trying, I will figure it out.

### Re: Batch to multiple sizes

Posted: Sun Jun 12, 2016 3:20 am
Use a text editor to create the batch file "test.bat", with the contents:

handbrakecli -i "C:\Users\John\Desktop\VIDEO\%~n1.mov" -o "C:\Users\John\Desktop\MP4\%~n11920.mp4" -w 1920 --preset="Normal"

You would then execute using:

test "my video name goes here.mov"

---------------------
So what is the easiest way to run the bat file with "my video name goes here.mov"? having to open a command prompt and do it that way is not cool. is there a way to have the bat file prompt me for that name? just trying to save time not make things more work.

### Re: Batch to multiple sizes

Posted: Sun Jun 12, 2016 3:42 am
First Google hit for "windows batch request input" covers it: http://stackoverflow.com/questions/1223 ... nother-com

Noticing a pattern here?

### Re: Batch to multiple sizes

Posted: Sun Jun 12, 2016 10:38 am
johnzapf wrote: So what is the easiest way to run the bat file with "my video name goes here.mov"? having to open a command prompt and do it that way is not cool. is there a way to have the bat file prompt me for that name? just trying to save time not make things more work.
This should work:

set /P file=Enter file:
Handbrakecli -i d:\temp\%file% -o d:\temp\%file%1920.mp4

### Re: Batch to multiple sizes

Posted: Sun Jun 12, 2016 11:08 am
Moving to command line support forum.

### Re: Batch to multiple sizes

Posted: Mon Jun 13, 2016 3:47 pm
this almost works
set /P file=Enter file:
Handbrakecli -i d:\temp\%file% -o d:\temp\%file%1920.mp4

it prompts me, I type in test.mov and it starts BUT the out put file has the extension of the input file on it.

IE: test.mov1920.mp4 needs to end up just, test1920.mp4

### Re: Batch to multiple sizes

Posted: Mon Jun 13, 2016 4:50 pm
You could ask for 2 inputs, file and extension or use the methods mduell posted above.

### Re: Batch to multiple sizes

Posted: Mon Jun 13, 2016 7:01 pm
Can you point me in the right direction on how to ask for 2 inputs, file and extension? I am not a code person at all that is why I am on this forum asking for help.

### Re: Batch to multiple sizes

Posted: Mon Jun 13, 2016 7:08 pm
set /P filein=Enter input file:
set /P fileext=Enter input file extension:
Handbrakecli -i d:\temp\%filein%.%fileext% -o d:\temp\%filein%1920.mp4