Auto Convert TV-Shows and Movies to MP4 (Sonarr and Sabnzbd)

Come up with a useful post-processing script? Share it here!

Auto Convert TV-Shows and Movies to MP4 (Sonarr and Sabnzbd)

Postby BrooBee » October 15th, 2016, 12:28 pm

Hi,

Here is a script that converts files to MP4, rename them (Movies through Sabnzbd's Sorting and TV-Shows through my setup in Sonarr) and move them where you want.

Code: Select all
@ECHO OFF
ECHO.
ECHO Begin SAB Post-Proccess Video - Remux AVI or MKV to MP4
ECHO.
REM Change these variables to match your system
SET FFMPEG=D:\ffmpeg\bin\ffmpeg.exe
SET OldAVI=avi
SET OldMKV=mkv
SET NewFormat=mp4

REM You shouldn't need to edit anything below here. Only if you add another format (Container) OldASF, OldWMV etc.
ECHO.
ECHO Deleting Unnecessary files before converting (Samples etc, so it does not convert them too)!
ECHO.
del /Q /F "%~1\*RARBG.COM*","%~1\*sample*","%~1\*.idx","%~1\*.sub","%~1\*.srr","%~1\*.par2","%~1\*.jpg","%~1\*.url","%~1\*.pdf","%~1\*.m2ts","%~1\*.srs"
ECHO.
ECHO Looking in "%~1" for %OldAVI% or %OldMKV% files.
ECHO Using %FFMPEG% to convert %OldAVI% or %OldMKV% to %NewFormat%...
ECHO.
ECHO These are the files to convert:
ECHO.
for %%i IN ("%~1\*.%OldAVI%","%~1\*.%OldMKV%") DO (ECHO "%%i")
ECHO.
ECHO Starting Conversion (If there are any files)
ECHO.
ECHO.
ECHO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ START CONVERTING %time:~0,-3% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
D:\Timer\timer.exe /q
for %%i IN ("%~1\*.%OldAVI%","%~1\*.%OldMKV%") DO (%FFMPEG% -nostats -loglevel warning -y -i "%%i" -c:v copy -c:a libfdk_aac "%~1\%%~ni.%NewFormat%")
ECHO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ END   CONVERTING %time:~0,-3% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ECHO.
ECHO Conversion took:
@ECHO OFF
D:\Timer\timer.exe /n /nologo /s
ECHO.

REM Pause for 5 seconds once processing is complete to let things settle a bit

PING 127.0.0.1 -n 1 -w 5000 >NUL

ECHO.
REM Change the del command below, if you want to add or remove files to delete or keep.

    ECHO Deleting %OldAVI% or %OldMKV% and unnecessary files!
   ECHO.
    del /Q /F "%~1\*.%OldAVI%","%~1\*.%OldMKV%","%~1\*RARBG.COM*","%~1\*sample*","%~1\*.idx","%~1\*.sub","%~1\*.srr","%~1\*.par2","%~1\*.jpg","%~1\*.url","%~1\*.pdf","%~1\*.m2ts","%~1\*.srs"

ECHO Checking for new format files in %~1
ECHO.
IF EXIST "%~1\*.%NewFormat%" (
Dir /B %~1\*.mp4
   ECHO.
    ECHO Found %NewFormat% in folder!
   ECHO.
    PING 127.0.0.1 -n 1 -w 5000 >NUL   
)
ECHO.
ECHO Done!


Download Timer.exe from http://www.gammadyne.com/cmdline.htm#timer a simple dos program to calculate time for a command to process, change Folder where you put timer.exe (Timer is Optional)
Setup your sonarr as you want it with TV-Shows.
Setup your Sabnzbd as you want it.
Make a file with the above code and put the file in Sabnzbd's Script folder. (C:\Program Files (x86)\SABnzbd\scripts\)
Setup your Categories in Sabnzbd (TV-Shows and Movies) and point to the script file you made.
Setup Sorting in Sabnzbd if you want.

TV-Shows will be converted to MP4 and Sonarr takes care of the renaming and moving of files.
Movies will be converted to MP4 and Sabnzbd will take care of the renaming (if you use sorting) and moving files.


It is easy to change so it suits your wishes, files to delete Before converting, how to convert it, files to delete after etc.


P.S All THANKS goes to porp in this Thread! https://www.reddit.com/r/usenet/comments/20qzkr/converting_from_mkv_to_mp4_automatically_in/

Updated script 29 October 2016 at 19:09 Added Timer to calculate time it takes to convert the file D.S
Last edited by BrooBee on October 29th, 2016, 12:16 pm, edited 10 times in total.
Best Regards,

BrooBee
User avatar
BrooBee
Newbie
Newbie
 
Posts: 10
Joined: September 29th, 2016, 1:51 pm

Re: Auto Convert TV-Shows and Movies to MP4 (Sonarr and Sabn

Postby BrooBee » October 15th, 2016, 1:10 pm

This is how it looks like in Sabnzbd's Logs after my script is done:

Code: Select all
Begin SAB Post-Proccess Video - Remux AVI or MKV to MP4


Deleting Unnecessary files before converting (Samples etc, so it does not convert them too)!


Looking in "F:\TORRENT\Done\Test Movie Awesomeness (2016)" for avi or mkv files.
Using D:\ffmpeg\bin\ffmpeg.exe to convert avi or mkv to mp4...

These are the files to convert:

"F:\TORRENT\Done\Test Movie Awesomeness (2016)\Test Movie Awesomeness (2016).mkv"

Starting Conversion (If there are any files)
 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ START CONVERTING 19:16:41 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ END   CONVERTING 19:24:06 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Conversion took:
0:07:25.36


Deleting avi or mkv and unnecessary files!

Checking for new format files in F:\TORRENT\Done\Test Movie Awesomeness (2016)

Test Movie Awesomeness (2016).mp4

Found mp4 in folder!


Done!



Hiding some Conversion info, nicer look in Logs, delete files before conversion and after conversion, time info for the conversion etc.
Best Regards,

BrooBee
User avatar
BrooBee
Newbie
Newbie
 
Posts: 10
Joined: September 29th, 2016, 1:51 pm

Re: Auto Convert TV-Shows and Movies to MP4 (Sonarr and Sabn

Postby BrooBee » October 30th, 2016, 11:11 pm

Is there anyone using this script?

Any wishes to add in the script?
Best Regards,

BrooBee
User avatar
BrooBee
Newbie
Newbie
 
Posts: 10
Joined: September 29th, 2016, 1:51 pm

Re: Auto Convert TV-Shows and Movies to MP4 (Sonarr and Sabn

Postby mkoppers » November 6th, 2016, 10:21 am

Just installed your script.I have been looking for this for a very long time and ended up converting videos manually. If it works - and I'm sure it will - you will have saved me many hours.
Thank you
mkoppers
Newbie
Newbie
 
Posts: 1
Joined: November 6th, 2016, 10:16 am

Re: Auto Convert TV-Shows and Movies to MP4 (Sonarr and Sabn

Postby BrooBee » November 9th, 2016, 12:48 pm

mkoppers wrote:Just installed your script.I have been looking for this for a very long time and ended up converting videos manually. If it works - and I'm sure it will - you will have saved me many hours.
Thank you


Ah great :D

Yeah, let me know how it works and let me know if there are something you wonder.
Best Regards,

BrooBee
User avatar
BrooBee
Newbie
Newbie
 
Posts: 10
Joined: September 29th, 2016, 1:51 pm

Re: Auto Convert TV-Shows and Movies to MP4 (Sonarr and Sabn

Postby olilogic » December 20th, 2016, 2:12 am

I had some trouble with the ffmpeg call as I didn't have the libfdk_aac library installed, so I changed that to aac instead and it worked ok .. other than that it works great!
olilogic
Newbie
Newbie
 
Posts: 1
Joined: December 20th, 2016, 1:58 am


Return to Post-Processing Scripts