I found this little script that I use after a TV-Show or a Movie etc is downloaded.
It works in Windows and is easy to change to fit your wishes.
It converts MKV or AVI to MP4, can be edited to convert more formats.
I have setup Sonarr to check for TV-Shows with indexers to find them, then Sonarr tells Sabnzbd to download them and execute the script to convert the TV-Shows to MP4, then the TV-Show gets moved to the right folder by Sonarr, Sonarr and Sabnzb deletes the files you dont want and only keep the TV-Show MP4.
It works with Movies etc too.
I hope someone has any use of it.
Code: Select all
@ECHO OFF
ECHO.
ECHO Begin SABPostProccessVideo - Remux 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 Looking in "%~1" for %OldAVI% or %OldMKV% files. Using %FFMPEG% to convert %OldAVI% or %OldMKV% to %NewFormat%...
ECHO.
ECHO Deleting unnecessary Files...
ECHO.
del /Q /F "%~1\*.*sample*","%~1\*.idx","%~1\*.sub","%~1\*.srr","%~1\*.jpg","%~1\*.url","%~1\*.pdf"
ECHO.
ECHO These are the files to convert:
ECHO.
for %%i IN ("%~1\*.%OldAVI%","%~1\*.%OldMKV%") DO (ECHO "%%i")
ECHO.
ECHO.
ECHO Starting Conversion (If there are any files)
ECHO.
ECHO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~START CONVERTING~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
for %%i IN ("%~1\*.%OldAVI%","%~1\*.%OldMKV%") DO (%FFMPEG% -y -i "%%i" -c:v copy -c:a libfdk_aac "%~1\%%~ni.%NewFormat%")
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
REM This part checks to see if the old format files were converted to new format
ECHO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~END CONVERTING~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ECHO.
ECHO Checking for new format files in %~1
ECHO.
IF EXIST "%~1\*.%NewFormat%" (
ECHO.
ECHO Found %NewFormat% in folder!
ECHO.
ECHO Deleting old files then
ECHO.
ECHO Pause for 5 seconds before trying to delete files
ECHO.
PING 127.0.0.1 -n 1 -w 5000 >NUL
ECHO Deleting %OldAVI% or %OldMKV% and unnecessary files! Change the del command below, if you want to add or remove files to delete or keep.
ECHO.
del /Q /F "%~1\*.%OldAVI%","%~1\*.%OldMKV%","%~1\*.*sample*","%~1\*.idx","%~1\*.sub","%~1\*.srr","%~1\*.par2","%~1\*.jpg","%~1\*.url","%~1\*.pdf"
)
ECHO.
ECHO Done!
Works now with Sorting in Sabnzbd, my settings are:
Copy the code above, save to a file, for example convert.bat, put the file (convert.bat) in your Sabznbd Script folder.
In Sabnzbd setup your categories and choose the Script file "Convert.bat" click save to the right of that column.
Here is a result in Sabnzbd Log:
Code: Select all
Begin SABPostProccessVideo - Remux MKV to MP4
Looking in "F:\MOVIES" 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:\MOVIES\THIS IS A TEST FILE (2016).mkv"
Starting Conversion (If there are any files)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~START CONVERTING~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ffmpeg version N-81884-ge5bbedf Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.9.3 (GCC)
configuration: --arch=x86_64 --target-os=mingw32 --cross-prefix=/home/USER/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/bin/x86_64-w64-mingw32- --pkg-config=pkg-config --disable-w32threads --enable-libsoxr --enable-fontconfig --enable-libass --enable-libbluray --enable-iconv --enable-libtwolame --extra-cflags=-DLIBTWOLAME_STATIC --enable-libzvbi --enable-libcaca --enable-libmodplug --extra-libs=-lstdc++ --extra-libs=-lpng --enable-decklink --extra-libs=-loleaut32 --enable-libmp3lame --enable-version3 --enable-zlib --enable-librtmp --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libopenjpeg --enable-gnutls --enable-libgsm --enable-libfreetype --enable-libopus --enable-bzlib --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-libschroedinger --enable-libvpx --enable-libilbc --enable-libwavpack --enable-libwebp --enable-libgme --enable-dxva2 --enable-avisynth --enable-gray --enable-libopenh264 --enable-libebur128 --enable-netcdf --enable-libflite --enable-lzma --enable-libsnappy --enable-libzimg --enable-gpl --enable-libx264 --enable-libx265 --enable-frei0r --enable-filter=frei0r --enable-librubberband --enable-libvidstab --enable-libxavs --enable-libxvid --enable-libmfx --extra-libs=-lpsapi --extra-libs=-lspeexdsp --extra-cflags='-mtune=core2' --extra-cflags=-O3 --enable-static --disable-shared --prefix=/home/USER/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32 --enable-nonfree --enable-libfdk-aac --enable-runtime-cpudetect
libavutil 55. 32.100 / 55. 32.100
libavcodec 57. 60.101 / 57. 60.101
libavformat 57. 51.102 / 57. 51.102
libavdevice 57. 0.102 / 57. 0.102
libavfilter 6. 63.100 / 6. 63.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 2.100 / 2. 2.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, matroska,webm, from 'F:\MOVIES\THIS IS A TEST FILE (2016).mkv':
Metadata:
title : THIS IS A TEST FILE 2016
ENCODER : Lavf56.40.101
Duration: 00:06:30.56, start: 0.000000, bitrate: 3165 kb/s
Stream #0:0(eng): Video: h264 (High), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc (default)
Metadata:
LANGUAGE : eng
BPS : 5856854
BPS-eng : 5856854
ENCODER : Lavc56.60.100 libx264
DURATION-eng : 00:06:30.557000000
NUMBER_OF_FRAMES: 11705
NUMBER_OF_FRAMES-eng: 11705
NUMBER_OF_BYTES : 285929433
NUMBER_OF_BYTES-eng: 285929433
_STATISTICS_WRITING_APP: mkvmerge v9.3.1 ('Mask Machine') 64bit
_STATISTICS_WRITING_APP-eng: mkvmerge v9.3.1 ('Mask Machine') 64bit
_STATISTICS_WRITING_DATE_UTC: 2016-08-15 11:13:52
_STATISTICS_WRITING_DATE_UTC-eng: 2016-08-15 11:13:52
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
DURATION : 00:06:30.557000000
Stream #0:1(eng): Audio: aac (LC), 44100 Hz, mono, fltp (default)
Metadata:
LANGUAGE : eng
BPS : 191999
BPS-eng : 191999
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
DURATION-eng : 00:06:30.536000000
NUMBER_OF_FRAMES: 16819
NUMBER_OF_FRAMES-eng: 16819
NUMBER_OF_BYTES : 9372852
NUMBER_OF_BYTES-eng: 9372852
_STATISTICS_WRITING_APP: mkvmerge v9.3.1 ('Mask Machine') 64bit
_STATISTICS_WRITING_APP-eng: mkvmerge v9.3.1 ('Mask Machine') 64bit
_STATISTICS_WRITING_DATE_UTC: 2016-08-15 11:13:52
_STATISTICS_WRITING_DATE_UTC-eng: 2016-08-15 11:13:52
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
DURATION : 00:06:30.536000000
Stream #0:2(eng): Subtitle: subrip (default)
Metadata:
title : Color Yellow Forced
LANGUAGE : eng
BPS : 213
BPS-eng : 213
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
DURATION-eng : 00:06:23.233000000
NUMBER_OF_FRAMES: 147
NUMBER_OF_FRAMES-eng: 147
NUMBER_OF_BYTES : 10231
NUMBER_OF_BYTES-eng: 10231
_STATISTICS_WRITING_APP: mkvmerge v9.3.1 ('Mask Machine') 64bit
_STATISTICS_WRITING_APP-eng: mkvmerge v9.3.1 ('Mask Machine') 64bit
_STATISTICS_WRITING_DATE_UTC: 2016-08-15 11:13:52
_STATISTICS_WRITING_DATE_UTC-eng: 2016-08-15 11:13:52
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
DURATION : 00:06:23.633000000
Stream #0:3(eng): Subtitle: subrip
Metadata:
title : No Forced Color
LANGUAGE : eng
BPS : 124
BPS-eng : 124
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
DURATION-eng : 00:06:23.233000000
NUMBER_OF_FRAMES: 147
NUMBER_OF_FRAMES-eng: 147
NUMBER_OF_BYTES : 5968
NUMBER_OF_BYTES-eng: 5968
_STATISTICS_WRITING_APP: mkvmerge v9.3.1 ('Mask Machine') 64bit
_STATISTICS_WRITING_APP-eng: mkvmerge v9.3.1 ('Mask Machine') 64bit
_STATISTICS_WRITING_DATE_UTC: 2016-08-15 11:13:52
_STATISTICS_WRITING_DATE_UTC-eng: 2016-08-15 11:13:52
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
DURATION : 00:06:23.633000000
Output #0, mp4, to 'F:\MOVIES\THIS IS A TEST FILE (2016).mp4':
Metadata:
title : THIS IS A TEST FILE 2016
encoder : Lavf57.51.102
Stream #0:0(eng): Video: h264 (High) ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 29.97 fps, 29.97 tbr, 16k tbn, 1k tbc (default)
Metadata:
LANGUAGE : eng
BPS : 5856854
BPS-eng : 5856854
ENCODER : Lavc56.60.100 libx264
DURATION-eng : 00:06:30.557000000
NUMBER_OF_FRAMES: 11705
NUMBER_OF_FRAMES-eng: 11705
NUMBER_OF_BYTES : 285929433
NUMBER_OF_BYTES-eng: 285929433
_STATISTICS_WRITING_APP: mkvmerge v9.3.1 ('Mask Machine') 64bit
_STATISTICS_WRITING_APP-eng: mkvmerge v9.3.1 ('Mask Machine') 64bit
_STATISTICS_WRITING_DATE_UTC: 2016-08-15 11:13:52
_STATISTICS_WRITING_DATE_UTC-eng: 2016-08-15 11:13:52
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
DURATION : 00:06:30.557000000
Stream #0:1(eng): Audio: aac (libfdk_aac) ([64][0][0][0] / 0x0040), 44100 Hz, mono, s16, 96 kb/s (default)
Metadata:
LANGUAGE : eng
BPS : 191999
BPS-eng : 191999
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
DURATION-eng : 00:06:30.536000000
NUMBER_OF_FRAMES: 16819
NUMBER_OF_FRAMES-eng: 16819
NUMBER_OF_BYTES : 9372852
NUMBER_OF_BYTES-eng: 9372852
_STATISTICS_WRITING_APP: mkvmerge v9.3.1 ('Mask Machine') 64bit
_STATISTICS_WRITING_APP-eng: mkvmerge v9.3.1 ('Mask Machine') 64bit
_STATISTICS_WRITING_DATE_UTC: 2016-08-15 11:13:52
_STATISTICS_WRITING_DATE_UTC-eng: 2016-08-15 11:13:52
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
DURATION : 00:06:30.536000000
encoder : Lavc57.60.101 libfdk_aac
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (aac (native) -> aac (libfdk_aac))
Press [q] to stop, [?] for help
frame= 653 fps=0.0 q=-1.0 size= 8103kB time=00:00:21.68 bitrate=3060.8kbits/s speed=43.4x
frame= 1275 fps=1275 q=-1.0 size= 15601kB time=00:00:42.44 bitrate=3011.3kbits/s speed=42.4x
frame= 1910 fps=1273 q=-1.0 size= 23743kB time=00:01:03.63 bitrate=3056.7kbits/s speed=42.4x
frame= 2584 fps=1292 q=-1.0 size= 30965kB time=00:01:26.12 bitrate=2945.4kbits/s speed=43.1x
frame= 3247 fps=1299 q=-1.0 size= 39419kB time=00:01:48.25 bitrate=2983.1kbits/s speed=43.3x
frame= 3854 fps=1285 q=-1.0 size= 48027kB time=00:02:08.49 bitrate=3061.9kbits/s speed=42.8x
frame= 4431 fps=1266 q=-1.0 size= 55795kB time=00:02:27.74 bitrate=3093.6kbits/s speed=42.2x
frame= 5058 fps=1264 q=-1.0 size= 62637kB time=00:02:48.66 bitrate=3042.2kbits/s speed=42.2x
frame= 5643 fps=1254 q=-1.0 size= 70056kB time=00:03:08.18 bitrate=3049.6kbits/s speed=41.8x
frame= 6270 fps=1254 q=-1.0 size= 77364kB time=00:03:29.11 bitrate=3030.7kbits/s speed=41.8x
frame= 6915 fps=1257 q=-1.0 size= 85161kB time=00:03:50.63 bitrate=3024.9kbits/s speed=41.9x
frame= 7533 fps=1255 q=-1.0 size= 95573kB time=00:04:11.25 bitrate=3116.1kbits/s speed=41.9x
frame= 8200 fps=1261 q=-1.0 size= 99975kB time=00:04:33.50 bitrate=2994.4kbits/s speed=42.1x
frame= 8840 fps=1263 q=-1.0 size= 107529kB time=00:04:54.86 bitrate=2987.3kbits/s speed=42.1x
frame= 9404 fps=1254 q=-1.0 size= 114037kB time=00:05:13.68 bitrate=2978.2kbits/s speed=41.8x
frame= 9877 fps=1235 q=-1.0 size= 119522kB time=00:05:29.46 bitrate=2971.9kbits/s speed=41.2x
frame=10417 fps=1225 q=-1.0 size= 127363kB time=00:05:47.48 bitrate=3002.6kbits/s speed=40.9x
frame=11009 fps=1223 q=-1.0 size= 135323kB time=00:06:07.23 bitrate=3018.7kbits/s speed=40.8x
frame=11705 fps=1233 q=-1.0 Lsize= 146640kB time=00:06:30.53 bitrate=3076.0kbits/s speed=41.1x
video:141511kB audio:4588kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.370807%
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~END CONVERTING~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Checking for new format files in F:\MOVIES
Found mp4 in folder!
Deleting old files then
Pause for 5 seconds before trying to delete files
Deleting avi or mkv and unnecessary files! Change the del command below, if you want to add or remove files to delete or keep.
Done!
Happy Downloading
AND ALL THANKS GOES TO porp in this Thread:
https://www.reddit.com/r/usenet/comment ... ically_in/
Thanks A LOT porp, Awesome
P.S Updated script 8 October 2016 D.S