Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
2nd August 2010, 13:18 | #1 | Link |
Guest
Posts: n/a
|
fixMKV v2 *updated* - MKV Header Compression fix
Hi all,
New version in post 19 BELOW!, stuff kept here for prosperity and continuity of replies :P I have a couple of standalone media players that don't like the recent MKVToolnix v4.1.1 or greater MKVmerge default of using header compression So as an interim fix (until firmware upgrades available, etc) I have coded this quick and dirty BAT file to convert all problem MKVs in a directory into good behaving citizens on media players! Code:
@ECHO OFF SET HOMEDIR=%~dp0 REM SET %MKVTOOLPATH=C:\Program Files\MKVToolnix SET KEY="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\mmg.exe" FOR /F "tokens=2*" %%A IN ('REG QUERY %KEY%') DO SET MKVTOOLPATH=%%B IF "%MKVTOOLPATH%" == "" ( DIR "%HOMEDRIVE%\mkvmerge.exe" /s /b >"%HOMEDIR%findmkvmerge" SET /P MKVTOOLPATH=<"%HOMEDIR%findmkvmerge" DEL "%HOMEDIR%findmkvmerge" ) IF "%MKVTOOLPATH%" == "" ( ECHO MKVToolnix NOT found!!!>"%HOMEDIR%logging.txt" GOTO STATUS ) ELSE ( ECHO MKVToolnix found at "%MKVTOOLPATH%">"%HOMEDIR%logging.txt" ECHO.>>"%HOMEDIR%logging.txt" ) :STARTFILES IF "%~dpnx1" == "" GOTO DRAGDONE ECHO PROCESSING ALL FILES DRAGGED AND DROPPED!! ECHO PROCESSING ALL FILES DRAGGED AND DROPPED>>"%HOMEDIR%logging.txt" ECHO.>>"%HOMEDIR%logging.txt" SET dropped=yes CALL :MKVFIXMUX %1 "%MKVTOOLPATH%" SHIFT GOTO STARTFILES :DRAGDONE IF "%dropped%" == "yes" GOTO STATUS ECHO PROCESSING ALL FILES IN THIS DIRECTORY AND ALL SUBDIRECTORIES!! ECHO PROCESSING ALL FILES IN THIS DIRECTORY AND ALL SUBDIRECTORIES>>"%HOMEDIR%logging.txt" ECHO.>>"%HOMEDIR%logging.txt" FOR /F "delims=*" %%A IN ('dir /b /s *.MKV') do CALL :MKVFIXMUX "%%A" "%MKVTOOLPATH%" :STATUS START "" "%HOMEDIR%logging.txt" ping 1.1.1.1 -w 1000 -n 2$1>nul del "%HOMEDIR%logging.txt" GOTO END :MKVFIXMUX "%~dp2mkvmerge.exe" -o "%~dpn1_fix.MKV" -A -S --compression -1:none "%~dpnx1" -D -S --compression -1:none "%~dpnx1" -A -D "%~dpnx1">>"%HOMEDIR%logging.txt" if not errorlevel 0 ( ECHO FAILED! on "%~dpnx1" remux!>>"%HOMEDIR%logging.txt" ) if exist "%~dpn1_fix.MKV" ( del "%~dpnx1" rename "%~dpn1_fix.MKV" "%~nx1" ECHO SUCCESSFUL! processing of "%~dpnx1">>"%HOMEDIR%logging.txt" ) :END It requires MKVToolnix v4.1.1 or later INSTALLED or UNZIPPED onto the Windows Install drive (if you didn't install MKVToolnix and it's NOT on the same drive as Windows, you will have to remove the 'REM' command and manually specify where the MKVToolnix directory is located) ... 7ekno EDIT: Code fixed for inadvently removing subtitle header compression :P EDIT2: Code rewritten for Drag & Drop and Double Click function with better logging and self cleanup :P Last edited by 7ekno; 17th September 2011 at 21:00. Reason: Attachment & Script Update |
7th August 2010, 11:27 | #2 | Link |
Moderator
Join Date: Feb 2005
Location: Spain
Posts: 6,915
|
I don't found info in mkvmerge help about:
--engage keep_bitstream_ar_info For what is necessary? For me work for all tracks: --compression -1:none "%~dpnx1" instead: -A -S --compression -1:none "%~dpnx1" -D -S --compression -1:none "%~dpnx1" -A -D --compression -1:none "%~dpnx1" What is the difference selecting video, audio and subs separately?
__________________
BeHappy, AviSynth audio transcoder. |
7th August 2010, 11:49 | #3 | Link |
Registered User
Join Date: Apr 2007
Location: Lithuania
Posts: 120
|
there is special tool for this purpose, mkWDclean http://www.matroska.org/downloads/mkclean.html
|
7th August 2010, 15:45 | #5 | Link | |
RipBot264 author
Join Date: May 2006
Location: Poland
Posts: 7,815
|
Quote:
__________________
Windows 7 Image Updater - SkyLake\KabyLake\CoffeLake\Ryzen Threadripper |
|
7th August 2010, 19:01 | #6 | Link | |
Registered User
Join Date: Aug 2008
Location: The Land Of Dracula (Romania - EU)
Posts: 934
|
Quote:
Code:
for %%a in ("*.mkv") do mkWDclean --optimize %%a
__________________
if you ask a question and somebody give you the correct answer don't forget to leave a "thank you" note... Visit The Land Of Dracula (Romania - EU)! |
|
7th August 2010, 21:43 | #7 | Link | |
Registered User
Join Date: Apr 2008
Posts: 1,181
|
Quote:
keep_bitstream_ar_info keeps the original SAR information in SPS for AVC when you specify a DAR for the video stream. It is on by default now so it's not needed any more. |
|
8th August 2010, 18:59 | #9 | Link |
MKVToolNix author
Join Date: Sep 2002
Location: Braunschweig, Germany
Posts: 4,281
|
Those options are not supported (meaning I will not give support for questions regarding the use of or the result of the use of those options). They're development hacks, hacks used for testing, stuff that simply doesn't work correctly yet etc etc.
__________________
Latest MKVToolNix is v83.0 If I ever ask you to upload something, please use my file server. |
16th August 2010, 12:08 | #10 | Link | |
Moderator
Join Date: Feb 2005
Location: Spain
Posts: 6,915
|
Quote:
@all Thanks for your tips.
__________________
BeHappy, AviSynth audio transcoder. |
|
16th August 2010, 12:15 | #11 | Link |
MKVToolNix author
Join Date: Sep 2002
Location: Braunschweig, Germany
Posts: 4,281
|
VobSub subtitles have always been compressed in Matroska -- so either a player supports zlib compressed VobSubs or it doesn't support VobSubs in Matroska at all. That would be my guess.
__________________
Latest MKVToolNix is v83.0 If I ever ask you to upload something, please use my file server. |
19th August 2010, 04:48 | #12 | Link |
Registered User
Join Date: Sep 2003
Posts: 1
|
Hi Everyone,
So my 720p MKV tv shows used to work fine until recently when streamed to my Patriot Box Office or my Xbox 360. Now neither can play more recent MKV files. I tried your .bat fix and my xbox still cannot play it. I have no tried the Patriot yet. Any clue how to get MKVs to work on the Xbox again using windows media center on the xbox? |
15th September 2011, 06:22 | #18 | Link |
Registered User
Join Date: Feb 2006
Posts: 3
|
Thanks 7ekno, just the tool I need to simplify things.
However, is that possible to include a checking routine before fixing every mkv in the dir tree. What I meant was fix only the mkv with compressed header in it. Cool scripts, thanks. |
17th September 2011, 12:47 | #19 | Link | |
Guest
Posts: n/a
|
fixMKV version 2 *updated*
Quote:
Tools needed: MKVToolnix - Either installed or unzipped to the same drive as Windows (if not, you will have to remove the "REM" statement and manually enter the file path to mkvmerge.exe) MediaInfo CLI version - Use the same version as your OS (so 64bit for 64bit OS, 32bit for 32bit OS), extract "MediaInfo.dll" and "MediaInfo.exe" to the same folder as fixMKV v2 (if not, you will have to manually enter the file path to MediaInfo.exe by deleting the %~dp0 in the "SET MEDIAINFOPATH=%~dp0" line and replacing it with your file path) Code:
@ECHO OFF SET HOMEDIR=%~dp0 SET MEDIAINFOPATH=%~dp0 SET LOGFILE=%~dpn0_log.txt REM SET MKVTOOLPATH=C:\Program Files\MKVToolnix SET KEY="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\mmg.exe" FOR /F "tokens=2*" %%A IN ('REG QUERY %KEY%') DO SET MKVTOOLPATH=%%B IF "%MKVTOOLPATH%" == "" ( FOR /F "tokens=*" %%I IN ('DIR "%HOMEDRIVE%\mkvmerge.exe" /s /b') DO SET MKVTOOLPATH=%%I ) IF "%MKVTOOLPATH%" == "" ( ECHO %DATE%%TIME%: MKVToolnix NOT found!!!>"%LOGFILE%" GOTO STATUS ) ELSE ( ECHO %DATE%%TIME%: MKVToolnix found at "%MKVTOOLPATH%">"%LOGFILE%" ) IF EXIST "%MEDIAINFOPATH%MediaInfo.exe" ( ECHO %DATE%%TIME%: MediaInfo.exe CLI found at "%MEDIAINFOPATH%">>"%LOGFILE%" ) ELSE ( ECHO %DATE%%TIME%: MediaInfo.exe CLI NOT FOUND at "%MEDIAINFOPATH%">>"%LOGFILE%" GOTO STATUS ) IF (%1) == () GOTO CLICKED ECHO FixMKV v2 removing Header Compression from all files DROPPED!! ECHO %DATE%%TIME%: PROCESSING ALL FILES DRAGGED AND DROPPED>>"%LOGFILE%" :DROPFILES IF (%1) == () GOTO STATUS CALL :MKVFIXMUX %1 "%MKVTOOLPATH%" SHIFT GOTO DROPFILES :CLICKED ECHO FixMKV v2 removing Header Compression from all files in %HOMEDIR% AND all Sub-Directories!! ECHO %DATE%%TIME%: PROCESSING ALL FILES IN %HOMEDIR% + SUBDIRECTORIES>>"%LOGFILE%" FOR /F "delims=*" %%A IN ('dir /b /s *.MKV') DO CALL :MKVFIXMUX "%%A" "%MKVTOOLPATH%" :STATUS START "" "%LOGFILE%" PING 1.1.1.1 -w 1000 -n 2$1>nul DEL "%LOGFILE%" GOTO END :MKVFIXMUX "%MEDIAINFOPATH%mediainfo.exe" "%~dpnx1">"%HOMEDIR%%~n1.nfo" FIND /C /I "Header stripping" "%HOMEDIR%%~n1.nfo">nul IF NOT ERRORLEVEL 1 ( ECHO %DATE%%TIME%: "%~nx1" - Header Compression Found, processing ... >>"%LOGFILE%" "%~dp2mkvmerge.exe" -o "%~dpn1_fix.MKV" -A -S --compression -1:none "%~dpnx1" -D -S --compression -1:none "%~dpnx1" -A -D "%~dpnx1">nul IF ERRORLEVEL 1 ( ECHO %DATE%%TIME%: "%~nx1" - REMUX FAILED somehow!!>>"%LOGFILE%" GOTO CLEAN ) IF EXIST "%~dpn1_fix.MKV" ( DEL "%~dpnx1" RENAME "%~dpn1_fix.MKV" "%~nx1" ECHO %DATE%%TIME%: "%~nx1" - SUCCESSFUL remux.>>"%LOGFILE%" GOTO CLEAN ) ) ELSE ( ECHO %DATE%%TIME%: "%~nx1" - SKIPPED - No Header Compression.>>"%LOGFILE%" GOTO CLEAN ) :CLEAN DEL "%HOMEDIR%%~n1.nfo" :END - Bit more neat and concise logging with autocleanup - The use of MediaInfo to determine if an MKV has header compression or not and skip the file if nothing needs doing - Can be run from a top level directory and will automatically crawl all sub-directories - Files can be dragged and dropped on the BAT file for processing (and will still be skipped if not needed) Cheers, 7ekno Last edited by 7ekno; 17th September 2011 at 20:58. Reason: new update |
|
|
|