Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting popen to work with mkvtoolnix?
    text
    copied!<p>Most Matroska Video Files (.mkv's) nowadays have header compression enabled. This breaks compatibility with hardware players, and so I created a batch long ago "fixing" that by using mkvtoolnix to reassemble the files without using header compression. But strangely the batch doesn't work on some .mkv's, even though the source is correct. There's just no pattern in the hiccups...</p> <p>Because of that I started to write a small Python 3.2 script today, with the only purpose to iterate through the .mkv-files in the CWD and use them as parameters to call the mkvtoolnix-.exe using parameters. I tried using both os.popen() and os.system() on my prepared command, and while system() seems to misinterprete the command, removing double quotes where it shouldn't, even when escaped, popen seems to work atleast a bit.</p> <p>And that's my problem here. Executing the script now, it creates a .mkv_fix-file for every .mkv-file in the folder, which is fine, but it's size is only a small part of the original one and it is unplayable. To me it seems like popen calls the .exe just fine, but terminates it almost instantly afterwards, leaving only an unfinished file.</p> <p>I've taken the mkvtoolnix windows executables as a 7zip archive from <a href="http://www.bunkus.org/videotools/mkvtoolnix/downloads.html" rel="nofollow">here</a> and put them in a subdirectory of the CWD of the script.</p> <p>I should also note that the executables produce console output when called from the batch, which isn't the case with the .py-script.</p> <p>The important part of the code:</p> <pre><code>for file in glob.iglob('*.mkv'): if file.count('_fix') == 0: print(file) convertCMD = '"{0}\mkvtoolnix\mkvmerge.exe" -o "{1}_fix" --engage keep_bitstream_ar_info -A -S --compression -1:none "{1}" -D -S --compression -1:none "{1}" -A -D "{1}"'.format(os.getcwd(),file) os.popen(convertCMD) print('Converted '+file) </code></pre> <p>Any kind of help is appreciated.</p> <p>Additional info:</p> <p>Usual mkvtoolnix output:</p> <pre><code>mkvmerge v5.5.0 ('Healer') built on Apr 6 2012 21:43:24 'F:\$PRECONVERT\MKVFILENAME': Using the demultiplexer for the format 'Matroska'. 'F:\$PRECONVERT\MKVFILENAME': Using the demultiplexer for the format 'Matroska'. 'F:\$PRECONVERT\MKVFILENAME': Using the demultiplexer for the format 'Matroska'. 'F:\$PRECONVERT\MKVFILENAME' track 0: Using the output module for the format 'MPEG-4'. 'F:\$PRECONVERT\MKVFILENAME' track 1: Using the output module for the format 'Vorbis'. 'F:\$PRECONVERT\MKVFILENAME' track 2: Using the output module for the format 'Vorbis'. 'F:\$PRECONVERT\MKVFILENAME' track 3: Using the output module for the format 'text subtitles'. 'F:\$PRECONVERT\MKVFILENAME' track 4: Using the output module for the format 'text subtitles'. The file 'F:\$PRECONVERT\MKVFILENAME.mkv_fix' has been opened for writing. Progress: 0% Progress: 16% Progress: 39% Progress: 56% Progress: 78% Progress: 96% Progress: 100% The cue entries (the index) are being written... Muxing took 3 seconds. </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload