Problem calling mkvmerge with .json options file

Probably I am a blind while reading the documentation
However, I am not able to call mkvmerge with a json option file on windows (11) - neither from cmd nor from powershell.
I must be doing something completely wrong, I guess.

I do have a .json file named c:\temp\arglist.json

using cmd I do get

c:\temp>start "C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" @argfile.json
Die Datei "@argfile.json" kann nicht gefunden werden.

using powershell I get

PS C:\temp> & "C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" @argfile.json
In Zeile:1 Zeichen:52
+ & "C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" @argfile.json
+                                                    ~~~~~~~~
Der Splat-Operator "@" kann nicht dazu verwendet werden, auf Variablen in einem Ausdruck zu verweisen. "@argfile" kann nur als Argument fĂŒr einen Befehl verwendet werden. Wenn Sie auf Variablen in
einem Ausdruck verweisen möchten, verwenden Sie "$argfile".
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : SplattingNotPermitted

which I can understand, since i am not going to splat anything. But stopping to parse in powershell like this

PS C:\temp> & "C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" --% @argfile.json
mkvmerge v79.0 ('Funeral Pyres') 64-bit
Fehler: Es wurde kein Name fĂŒr die Zieldatei angegeben.

does not help either.
the argfile.json looks like this

[
    "--output \"N:\\mediathek-shows\\Bettys Diagnose\\Kein Empfang.mkv\"",
    "--language 0:ger",
    "--track-name 0:\"Kein Empfang\"",
    "--language 1:ger",
    "--track-name 1:\"Audiodeskription\"",
    "--default-track-flag 1:no",
    "\"N:\\mediathek\\Bettys Diagnose\\ZDF_Bettys Diagnose_Kein Empfang (Audiodeskription)_mediathek.mp4\"",
    "--no-video",
    "--language 0:de",
    "--default-track-flag 0:no",
    "--track-name 0:\"Audiodeskription\"",
    "\"N:\\mediathek\\Bettys Diagnose\\ZDF_Bettys Diagnose_Kein Empfang (Audiodeskription)_mediathek.srt\"",
    "--no-video",
    "--language 1:ger",
    "--track-name 1:\"Standard\"",
    "--default-track-flag 1:yes",
    "--visual-impaired-flag 1:no",
    "\"N:\\mediathek\\Bettys Diagnose\\ZDF_Bettys Diagnose_Kein Empfang_mediathek.mp4\"",
    "--no-video",
    "--language 0:de",
    "--default-track-flag 0:no",
    "--track-name 0:\"Standard\"",
    "\"N:\\mediathek\\Bettys Diagnose\\ZDF_Bettys Diagnose_Kein Empfang_mediathek.srt\"",
    "--track-order 0:0,0:1,1:0,2:1,3:0"
]

So i was trying to merge set of video files with and without descriptive audio to a single one holding the video only once - however that does not seem to be the problem to me. the corresponding full command line call giving all the options on the command line works just fine.

I will appreciate any hint, where I need to change something
Best regards

Welcome!

I think you made a simple mistake of misremembering your file name. First you write:

but in the command you use

list vs file

As for the PowerShell case, you need to tell PowerShell to treat @ like a regular character instead of a symbol special to PowerShell. What you’ve tried, --%, starts a line comment, making PowerShell ignore everything from there to the end of the line, which includes @argfile.json. You’re effectively running mkvmerge.exe without parameters in this case.

The way to go here is to quote the whole argument in double quotes:

mkvmerge.exe "@arglist.json"

Note that you also used the wrong file name in your PowerShell example.

thanks for the quick response
in fact, it was a typo, the file actually is named argfile.json.
As of my understanding, my experience and according to [Stop-Parsing - PowerShell - SS64.com](Stop-Parsing - PowerShell - SS64.com) --% is not starting a line comment in the powershell console, though.

Anyways 
 giving it a try and quoting the argument leads to this:

PS C:\temp> & "C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" "@argfile.json"
mkvmerge v79.0 ('Funeral Pyres') 64-bit
Fehler: Es wurde kein Name fĂŒr die Zieldatei angegeben.

Eventually my json file does have a flaw?
However, trying the same thing in cmd yields

c:\temp>start "C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" "@argfile.json"
Die Datei "@argfile.json" kann nicht gefunden werden.

Any clues?

Ah, your JSON file is completely wrong. You must use one string element in the array per command-line argument.

Meaning
 "--output \"N:\\mediathek-shows\\Bettys Diagnose\\Kein Empfang.mkv\"" is only one string element, but they must be two: "--output", "N:\\mediathek-shows\\Bettys Diagnose\\Kein Empfang.mkv"

The same applies to all the other entries.

When in doubt run MKVToolNix GUI, set up a file, change some options, then let the GUI generate a JSON file for you via “Multiplexing” → “Show command line” & changing the type to the option files.

1 Like

Aaaah.
Ok - that makes sense.
I‘ll give it a try tomorrow

Thanks again for being this quick - and helpful

You’re quite welcome.

That was it - thanks again!