PDA

View Full Version : Handbrake/VAP post-processing scripts



KryptoNyte
February 21st, 2012, 04:24 PM
There are a couple VAP post processing scripts attached here, one for 1080i and another for 720p. You'll need to run through them line by line to be sure that they are adjusted to fit your situation and preferences.

EDIT: Note that this;

rem Delete the source file and leave only the encoded file
del %inName%

deletes the source file, so if you don't want to do that, be sure to rem it out.

dlflannery
February 21st, 2012, 08:32 PM
Cool. Let's see what user reaction we get from these. I might want to include them in the VAP distribution, along with the generic version already included, from which they are adapted.

Any comments you have on how or why you chose some of the Handbrake options, e.g., bitrates, probably would be of interest.

KryptoNyte
February 22nd, 2012, 07:23 PM
Reference the Handbrake CLI guide at the link below which further explains the settings in greater detail so that you can make your own decisions as most settings are subjective, file, and/or player dependent;

https://trac.handbrake.fr/wiki/CLIGuide

Target devices to play the final, encoded files:
- HD Televisions and desktop/laptop computers
- External player devices, such as WDTVLive
- This config is NOT meant for handheld devices

For the output files, the 720p post-processing script, hbOptions:

-w 1280 -l 720 --crop:0:0:0:0
Identifying both the width/length and cropping to zeros is probably redundant if you can verify that your source input is always exactly 1280x720. For television, I would recommend that you at least keep the "--crop:0:0:0:0" unless you are comfortable doing otherwise. Keep in mind that if you leave all this info out, especially the cropping values, that Handbrake will "autocrop" which it doesn't always perform to the user's liking. There are a couple other reasons as I recall this is set as it is that I won't go into.

-e x264
Sets the encoder to h264, which is typically preferred unless you plan to play the file(s) on some older hardware that is not h264 compatible.

-b 2000
Sets the final file VIDEO bitrate. This setting is subjective. Generally speaking, the larger the number, the larger the file and the higher the quality. My personal experiences have been that I have greater control over final file size and consistence in playing files smoothly on various device than if I use the constant quality (or other) settings.

-2
Sets the video encoder to make (2) passes instead of just (1) pass. Subjective, one pass may be good enough for you.

-a 1
Selects the first audio track in the input file (handbrake default is 1). If you have VAP set to QSF your file in VRD, then this setting would be unecessary as [at this time] VRD+QSF = 1 audio stream only.

-E copy:ac3
Forces Handbrake to passthrough the AC3 audio without any processing/changes (assuming your source audio is AC3).

-6 auto
Not required if you are consistently doing an AC3 passthrough.

-R Auto
Not required if you are using audio passthrough, or want to otherwise leave the original sample rate (kHz) as it was in the source file.

-B auto
Not required for audio passthrough of a single stream.

-D 0
See Handbrake CLI guide if this is something that you might want to use. Not applicable with AC3 audio.

-x b-adapt=2:rc-lookahead=50
These set the advanced encoding options. If you open the Handbrake GUI, you can actually generate/see this string in the last tab based on user and/or device preference, profiles, etc.

--verbose=1
Sets the level of Handbrake logging.

-----------------------------------------
Regarding the output filetype, my entire video library is mkv, as it is the most flexible container. For the configuration above, I believe you could use mp4 output with no compromises.

KryptoNyte
February 22nd, 2012, 07:33 PM
Regarding the 1080i script file, it's similar, with a few exceptions;

The video is interlaced, so I use the decomb filter. If you do some Googling, you can find arguments as to why you might want to use decomb over deinterlacing, or vice versa.

The final image in my 1080i files has some cable company artifacts right at the bottom edge of the video (every time), I am able to remove that by cropping the bottom of the image. If you also have this problem, you can see this issue plainly if you set all crop values to zero and play the file on the computer. No issues, then set all crop values to zero.

The width and height are adjusted to match the source input file for 1080i, so my image is effectively stretched a bit vertically (after the cropping), but effectly creates 1080p video output in the correct aspect ratio.

KryptoNyte
February 28th, 2012, 06:53 PM
I'm attempting to use HB to encode .wtv files from 7MC. WTV files and Handbrake don't play together. I did find that .dvr-ms do work with HB, when testing with Handbrake's GUI, but for some reason, Vappostprocess + HandbrakeCLI can't seem to deal with the .dvr-ms file extension. So as it stands, I have VAP's profile match string set as follows:

.wtv MPEG2 DVR-MS .mpg

which does work. Any idea why I can't get VAP + Handbrake CLI to process the file with the .dvr-ms file extension?

(the VAP post-processing script is attached)

dlflannery
February 28th, 2012, 09:43 PM
Have you uncommented the pause statement at the end of the postprocess script to see if you have any error messages?

Have you verified that a file with .dvr-ms extension is present in the output folder where the postprocess script is running?

Beyond that, start inserting echo and pause statements at various points in the script to debug.

KryptoNyte
February 29th, 2012, 10:55 PM
It's looking like this is a problem with HandbrakeCLI. I'll chase it down there.

dsk96m
September 24th, 2012, 05:59 PM
Can someone help me write a post processing script for VAP using Handbrake. I want to get the file sizes down based on the length of the video. So like a 1 hour show would be 350MB, etc etc. Can someone help me, please?

dsk96m
September 24th, 2012, 06:56 PM
This is my script. I cant seem to figure out how to get the correct file names in there without putting them in manually. How do i get just the filename or filename without extension?



@echo off
setlocal
set inExt=.ts
set outExt=.mp4
set outDir=C:\TVRecordings\Finished\
set HBpath=C:\handbrake\HandBrakeCLI.exe
set apPath="C:\Program Files (x86)\VAP\AtomicParsley.exe"
set optfile="C:\TVRecordings\Ice Road Truckers-0616-The Final Showdown.apo"
set outName="C:\TVRecordings\Finished\Ice Road Truckers-0616-The Final Showdown.mp4"

if exist %outName% del %outName%

set inName="C:\TVRecordings\Ice Road Truckers-0616-The Final Showdown.ts"
if exist %inName% goto inputHere
if not exist %inName% goto done2
:inputHere

rem %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SET Inform_parms=%%Width%%+%%Height%%+%%FrameRate%%+%% Duration%%
FOR /F "usebackq delims=" %%B IN (`C:\TVRecordings\MediaInfo_CLI\mediainfo.exe "--Inform=Video;%Inform_parms%" "C:\TVRecordings\Ice Road Truckers-0616-The Final Showdown.ts"`) DO (
FOR /F "tokens=1-4 delims=+" %%C IN ("%%B") DO (
SET width=%%C
SET height=%%D
SET fps=%%E
SET duration=%%F
ECHO %duration%
ECHO %%F
ECHO.
)
)
echo duration %duration%
echo width %width%
echo height %height%
pause

if %duration% lss 1800000 (
set tsize=175
echo %tsize%
goto finished
)
if %duration% lss 3600000 (
set tsize=350
echo %tsize%
goto finished
)
if %duration% lss 5400000 (
set tsize=525
echo %tsize%
goto finished
)
if %duration% lss 7200000 (
set tsize=700
echo %tsize%
goto finished
)
if %duration% grt 7200000 (
set tsize=875
echo %tsize%
goto finished
)
:finished

echo %tsize%
pause

rem %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%

if %height% lss 800 (
goto 720
)
if %height% grt 900 (
goto 1080
)

:720
rem set hbOptions= -f avi -C 5 -e xvid -5 -9 -S %tsize%
set hbOptions= -w 1280 -l 720 --crop 0:0:0:0 -e x264 -b 2000 -2 -a 1 -E copy:ac3 -6 auto -R Auto -B auto -D 0 -x b-adapt=2:rc-lookahead=50 --verbose=1
rem -S %tsize%
goto hbdone

:1080
rem set hbOptions= -f avi -C 5 -e xvid -5 -9 -S %tsize%
set hbOptions= --decomb -w 1920 -l 1080 --crop 0:8:0:0 -e x264 -b 2000 -2 -a 1 -E copy:ac3 -6 auto -R Auto -B auto -D 0 -x b-adapt=2:rc-lookahead=50 --verbose=1
rem -S %tsize%

:hbdone

echo %hbOptions%
Pause

echo HB started at %time% > "VAPlog.txt"
"%HBpath%" -i %inName% -o %outName% %hbOptions% >hblog.txt
echo HB completed at %time% >> "VAPlog.txt"

Pause

echo %outName% >> "HandbrakeBatchLog.txt"
if not exist %optfile% goto done2
set /p options=<%optfile%
echo "Started AP run at %time%" >> vaplog.txt
%apPath% %outName% %options%
echo "Ended AP run at %time%" >> vaplog.txt

:done2
rem del %inName%
del C:\TVRecordings\hblog.txt
del C:\TVRecordings\HandbrakeBatchLog.txt
Pause

dlflannery
September 25th, 2012, 12:05 AM
Can someone help me write a post processing script for VAP using Handbrake. I want to get the file sizes down based on the length of the video. So like a 1 hour show would be 350MB, etc etc. Can someone help me, please?
There is a script called VAPpostProcessHBandAP.cmd that is distributed with VAP. If you edit in the correct user-defined parameters, rename the file to VAPpostprocess.cmd and place it in your output folder(s), you should be in business.

dsk96m
September 25th, 2012, 04:53 PM
Yes, i am using from that. My input file is ts.
So I do this: and get:
echo "%~3%" - ""
echo "%~1%" -"C:\TVRecordings\filename.ts"
echo "%~3%~1%inExt%" - "C:\TVRecordings\filename.ts.ts"
echo "%~3%~1.apo" - "C:\TVRecordings\filename.ts.apo"
echo "%outDir%%~1%outExt%" - "C:\TVRecordings\Finished\C:\TVRecordings\filename. ts.avi"

It is giving me the full path.
It should be .ts instead of .ts.ts, .apo instead of .ts.apo, and C:\TVRecordings\Finished\filename.avi

dsk96m
September 25th, 2012, 06:13 PM
Also, i am getting a bunch of stalls. I saw I could change:
<MaxStalledFileRetries>1</MaxStalledFileRetries>
<StallCheckIntervalSeconds>2400</StallCheckIntervalSeconds>
<StallRetryIntervalMinutes>10</StallRetryIntervalMinutes>
<StallCpuUseThreshold>0.01</StallCpuUseThreshold>

but where is that?

dlflannery
September 26th, 2012, 09:23 AM
Yes, i am using from that. My input file is ts.
So I do this: and get:
echo "&#37;~3%" - ""
echo "%~1%" -"C:\TVRecordings\filename.ts"
echo "%~3%~1%inExt%" - "C:\TVRecordings\filename.ts.ts"
echo "%~3%~1.apo" - "C:\TVRecordings\filename.ts.apo"
echo "%outDir%%~1%outExt%" - "C:\TVRecordings\Finished\C:\TVRecordings\filename. ts.avi"

It is giving me the full path.
It should be .ts instead of .ts.ts, .apo instead of .ts.apo, and C:\TVRecordings\Finished\filename.avi
Please attach a copy of your VAPpostProcess.cmd file. My guess is somehow an extra ".ts" (or inExt) is getting added in the batch script.

What is your process flow? QSF? AdScan? AutoCut? Manual Review of cuts?

dlflannery
September 26th, 2012, 09:33 AM
Also, i am getting a bunch of stalls. I saw I could change:
<MaxStalledFileRetries>1</MaxStalledFileRetries>
<StallCheckIntervalSeconds>2400</StallCheckIntervalSeconds>
<StallRetryIntervalMinutes>10</StallRetryIntervalMinutes>
<StallCpuUseThreshold>0.01</StallCpuUseThreshold>

but where is that?
Stalls during what processing step? (QSF? AdScan?).
What version of VRD are you using?
If you perform the exact process flow you are using in VAP but manually using only VRD, what happens? If it stalls that way, the problem is VRD not VAP.
If it stalls only when using VAP I will need all the configuration and file details in order to try to duplicate the problem.