Matroska Headercompression vs. WDTV


Seit geraumer Zeit bin ich Besitzer eines oder einer WDTV Live. Das Gerät steht unter meinem Fernseher und dient nur dem Zweck Filme die auf dem NAS abgelegt sind auf meinem Fernseher abzuspielen. Das Gerät kommt mit so ziemlich allen Formaten klar – abgesehen von manchen Mkv Dateien. Nach kurzer Recherche stand fest, dass dies mit der Headercompression zusammenhängt, doch was hat es damit auf sich?

Matroska ist ein Containerformat, das heißt in einem Matroska Container liegen die eigentlichen Dateien wie Audio und Videospuren, Untertitel usw. Im Header des Containers wird beschrieben welche Dateien enthalten sind und von welchem Typ sie sind. Die Matroskaspezifikation besagt, daß dieser Header auch komprimiert werden kann. Leider ist dieses Feature in den meisten Hardwareplayern anscheinend nicht implementiert obwohl die Spezifikation schon recht alt ist. Das war nie ein Problem bis sich Matroska entschloss die Headercompression standardmäßig in der aktuellen Version ihrer Tools zu aktivieren. Wenn man nun vergisst beim Mergen das entsprechende Flag zu setzen oder ein Mkv File von einem Bekannten bekommt, der solche Sorgen sieht man nur einen schwarzen Bildschirm.

Abhilfe schafft bei mir dieses kleine Bashscript. Die Mkv Tools müssen installiert sein. Die paar Zeilen machen nichts anderes als eine Prüfung auf Headerkomprimierung und ggfs. den Container ohne Kompression nochmal zu mergen. Das kann erfahrungsgemäß ein wenig dauern:

#!/bin/bash

function hascompression()
{
en=’Algorithm: 3 (header removal)‘
de=’Algorithmus: 3 (Entfernen von Kopfdaten)‘
mkvinfo $1 | grep -e „$en“ -e „$de“ &>/dev/null
ret=$?
if [ $ret -eq 0 ]
then
echo „komprimierte Header in $1“
return 0
else
echo „nichts komprimiertes gefunden in $1“
return 1
fi
}
#function
function removecompression()
{
hascompression $1

if [ $? -eq 0 ]
then

mv $1 $1.bak
mkvmerge -o „$1“ –engage keep_bitstream_ar_info -A -S –compression -1:none „$1.bak“ -D -S –compression -1:none „$1.bak“ -A -D –compression -1:none „$1.bak“
rm $1.bak
echo fukr
fi

}
#function

onlyinfo=false
while getopts ‚:i‘ OPTION; do
case „$OPTION“ in
i) onlyinfo=true && shift;;
*) echo „Unbekannter Parameter“

esac
done

for ARG in $@
do
if [ -f $ARG ]
then
if [ $onlyinfo == true ]
then
hascompression $ARG
else

removecompression $ARG
fi
else
echo $ARG isn\’t a file
fi

done

WordPress versaut leider die Einrückungen aber ein ordentlichen Texteditor sollte das wieder zurechtrücken. 🙂

Matthias hat sich die Mühe gemacht und ein Applescript erstellt um dem Matroska Container auch unter MacOS die Komprimierung zu rauben:

on open someDroppedAliases
set theAlias to first item of someDroppedAliases
tell application „Finder“
set filename to name of theAlias
set ParentFolder to container of theAlias
set the item_count to the number of items in the ParentFolder
set parentFolderAlias to ParentFolder as alias
end tell
set parentFolderPath to POSIX path of parentFolderAlias
set ausgabe to do shell script „mkvinfo “ & quoted form of POSIX path of someDroppedAliases
if ausgabe contains „Content compression“ then

do shell script „mkvmerge -o “ & quoted form of parentFolderPath & „clean_“ & quoted form of filename & “ –compression 1:none “ & quoted form of POSIX path of someDroppedAliases

tell application „GrowlHelperApp“
set the allNotificationsList to ¬
{„Reparieren“}

set the defaultNotificationsList to ¬
{„Reparieren“}

register as application ¬
„Growl AppleScript Sample“ all notifications allNotificationsList ¬
default notifications defaultNotificationsList ¬
icon of application „Mkvtoolnix“

— Send a Notification…
notify with name ¬
„Reparieren“ title ¬
filename description ¬
„Kompression erfolgreich entfernt.“ application name „Growl AppleScript Sample“
end tell
else
tell application „GrowlHelperApp“
set the allNotificationsList to ¬
{„Nichts zu reparieren“}

set the defaultNotificationsList to ¬
{„Nichts zu reparieren“}

register as application ¬
„Growl AppleScript Sample“ all notifications allNotificationsList ¬
default notifications defaultNotificationsList ¬
icon of application „Mkvtoolnix“

— Send a Notification…
notify with name ¬
„Nichts zu reparieren“ title ¬
filename description ¬
„Keine Kompression vorhanden“ application name „Growl AppleScript Sample“
end tell
end if
end open

Hf^^

Dieser Beitrag wurde unter bash, linux, schlaue tipps für dein Leben abgelegt und mit , , , , verschlagwortet. Setze ein Lesezeichen auf den Permalink.

4 Antworten zu Matroska Headercompression vs. WDTV

  1. Matthias schreibt:

    Hi!

    Genau so etwas könnte ich sehr gut gebrauchen! Ich sitzt aber aber vor einem Mac – kannst du mir da irgendwie weiterhelfen? Leider bin ich ein total Terminal Trottel…
    Danke schon mal im voraus…

    Matthias

  2. augeauge schreibt:

    Hi, ich habe leider nicht soviel Ahnung von Mac’s.
    Du auf jeden Fall die Programme mkvinfo und mkvmerge. Die 2 Tools sind in dem Paket mkvtoolnix enthalten. Du mußt im Internet nach einer Mac Version der Pakete suchen und die installieren. Danach ist das Schlimmste geschafft. Starte Deine Suche auf der Seite http://www.matroska.org/.
    Zur Erstellung des Skripts kann ich Dir nicht viel sagen . Leg eine Textdatei an, kopier das Skript aus dem Artikel in das File und mach es ausführbar (chmod +x SKRIPTNAME). Danach könntest Du die Datei z.B. als root nach /bin kopieren und
    durch Aufruf von mkvheader meinfilm.mkv die Compression ausschalten
    Frag Doch mal ganz freundlich in einem Mac Chatchannel oder einem Forum, da wird Dir garantiert qualifiziert geholfen :). Über ein Script für Macintosh würde ich mich natürlich auch freuen und es an bekannter Stelle publizieren ^^

    Grüße

  3. Matthias schreibt:

    Hab das Script nochmals überarbeitet – sorry für Doppel-Post:

    [CODE]
    on open someDroppedAliases
    set theAlias to first item of someDroppedAliases
    tell application „Finder“
    set filename to name of theAlias
    set ParentFolder to container of theAlias
    set the item_count to the number of items in the ParentFolder
    set parentFolderAlias to ParentFolder as alias
    end tell
    set parentFolderPath to POSIX path of parentFolderAlias
    set ausgabe to do shell script „mkvinfo “ & quoted form of POSIX path of someDroppedAliases
    if ausgabe contains „Content compression“ then

    do shell script „mkvmerge -o “ & quoted form of parentFolderPath & „clean_“ & quoted form of filename & “ –compression 1:none “ & quoted form of POSIX path of someDroppedAliases

    tell application „GrowlHelperApp“
    set the allNotificationsList to ¬
    {„Reparieren“}

    set the defaultNotificationsList to ¬
    {„Reparieren“}

    register as application ¬
    „Growl AppleScript Sample“ all notifications allNotificationsList ¬
    default notifications defaultNotificationsList ¬
    icon of application „Mkvtoolnix“

    — Send a Notification…
    notify with name ¬
    „Reparieren“ title ¬
    filename description ¬
    „Kompression erfolgreich entfernt.“ application name „Growl AppleScript Sample“
    end tell
    else
    tell application „GrowlHelperApp“
    set the allNotificationsList to ¬
    {„Nichts zu reparieren“}

    set the defaultNotificationsList to ¬
    {„Nichts zu reparieren“}

    register as application ¬
    „Growl AppleScript Sample“ all notifications allNotificationsList ¬
    default notifications defaultNotificationsList ¬
    icon of application „Mkvtoolnix“

    — Send a Notification…
    notify with name ¬
    „Nichts zu reparieren“ title ¬
    filename description ¬
    „Keine Kompression vorhanden“ application name „Growl AppleScript Sample“
    end tell
    end if
    end open
    [/CODE]

  4. Pingback: Wester Digital HDTV live und MKV Header Compression » Centurios Blog

Hinterlasse einen Kommentar