[Windows] Convert .MKV to .AVI and send to SickBeard
Posted: February 1st, 2012, 10:31 am
Hello all,
I've put together a script to automatically convert any .mkv file to .avi so that I can use my XBOX 360 to watch the video. This is primarily for TV shows - so I have integrated calling SabToSickBeard from within the script once the file has been converted. I'm using XenonMKV to convert the file - which doesn't reencode the video, but rather it repackages high-definition H.264/x264 video and 5.1 audio contained in MKV files to an MP4 format that the Xbox 360 can play. (It also renames it to .avi so that XBox will recognize it to play.)
After much trial and error, I think I've got it about right, but I'm a novice with this stuff - so I'd love some feedback and suggestions on how I could make it better. (One thing that I've noticed the last few times the script ran, was that SAB didn't rename the folder from "_UNPACK_" when it was done. This caused the script to fail to find the correct directory and not process correctly. Is this something that I'm not doing correctly in the script, e.g. not giving SAB enough time to rename the folder?)
I've put together a script to automatically convert any .mkv file to .avi so that I can use my XBOX 360 to watch the video. This is primarily for TV shows - so I have integrated calling SabToSickBeard from within the script once the file has been converted. I'm using XenonMKV to convert the file - which doesn't reencode the video, but rather it repackages high-definition H.264/x264 video and 5.1 audio contained in MKV files to an MP4 format that the Xbox 360 can play. (It also renames it to .avi so that XBox will recognize it to play.)
After much trial and error, I think I've got it about right, but I'm a novice with this stuff - so I'd love some feedback and suggestions on how I could make it better. (One thing that I've noticed the last few times the script ran, was that SAB didn't rename the folder from "_UNPACK_" when it was done. This caused the script to fail to find the correct directory and not process correctly. Is this something that I'm not doing correctly in the script, e.g. not giving SAB enough time to rename the folder?)
Code: Select all
@ECHO OFF
ECHO.
ECHO ------------------------------------------------------------------------------------------
ECHO This postprocessing script runs after video is downloaded in SAB.
ECHO It will look to see if the file is a MKV format and attempt to convert to AVI
ECHO If the video is a TV show (Category="tv" in SAB), then it will run SabToSickBeard script
ECHO Output Params: %1 %2 %3 %4 %5 %6 %7
ECHO ------------------------------------------------------------------------------------------
ECHO.
ECHO Begin SABPostProccessVideo...
ECHO.
SET SabToSickBeard=C:\SickBeard\autoProcessTV\sabToSickBeard.exe
SET XenonMKV=C:\XenonMKV\XenonMKV.exe
CD /d %1\..
ECHO Looking for MKV files. If any are found, will run XenonMKV to convert them to AVIs...
ECHO.
IF EXIST "%CD%\%3\*.mkv" (
ECHO MKVs Found. Running XenonMKV...
ECHO.
%XenonMKV% -inputfolder %1 -outputfolder %1) ELSE (
ECHO No MKV files found. Video was probably AVI already.
ECHO.
GOTO TRY_SAB_TO_SICKBEARD)
ECHO XenonMKV complete.
ECHO.
ECHO Checking for AVI files to see if conversion worked...
ECHO.
CD /d %1\..
IF EXIST "%CD%\%3\*.avi" (
IF EXIST "%CD%\%3\*.mkv" (
ECHO AVIs found, so conversion appears to have been sucessful.
ECHO.
ECHO Removing original MKVs...
ECHO.
DEL "%CD%\%3\*.mkv") ELSE (
ECHO AVIs found, so conversion appears to have been sucessful.
ECHO.
ECHO However no MKVs were found. So it's possible that the original MKVs were already removed or the conversion didn't really work.
ECHO.)) ELSE (
ECHO AVI files were not found so conversion probably failed.
ECHO.
ECHO Any original MKV files were not removed.
ECHO.)
GOTO TRY_SAB_TO_SICKBEARD
:TRY_SAB_TO_SICKBEARD
ECHO Looking to see if video is a TV Episode. If it is SabToSickBeard will run...
ECHO.
IF %5 == tv (
ECHO Video was a TV Show, running SabToSickBeard script...
ECHO.
%SabToSickBeard% %1 %2 %3 %4 %5 %6 %7
ECHO End SABPostProcessVideo.
exit) ELSE (
ECHO Video is NOT a TV Show, so sabToSickBeard was not run.
ECHO End SABPostProcessVideo.
exit)
REM Below are the attributes sent from SAB to the Postprocessing Script:
REM %1 The final directory of the job (full path)
REM %2 The original name of the NZB file
REM %3 Clean version of the job name (no path info and ".nzb" removed)
REM %4 Indexer's report number (if supported)
REM %5 User-defined category
REM %6 Group that the NZB was posted in e.g. alt.binaries.x
REM %7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+21