Using flatpak mkvmerge fails with returncode 137

I tried adapting a python script of mine which previously called mkvmerge via the plain Ubuntu installed mkvmerge, but I want to use a more up-to-date version, so I installed the flatpak version, so far no issues.

I can mkvmerge call with flatpak run org.bunkus.mkvtoolnix-gui mkvmerge "$@" and that works for me.

In the subrocess.run call I now supply the above, and it gives me the correct version number, great.

However, I have noticed that the command:
flatpak run org.bunkus.mkvtoolnix-gui mkvmerge -v -o 'normalized_staging/movie name.mkv' --no-audio 'movie name.mkv' -D -S -B -T -M --no-chapters --no-global-tags 'normalized_temp/movie name.mkv.audio-000.mkv.normalized.mkv' -D -S -B -T -M --no-chapters --no-global-tags 'normalized_temp/movie name.mkv.audio-001.mkv.normalized.mkv' -D -S -B -T -M --no-chapters --no-global-tags 'normalized_temp/movie name.mkv.audio-002.mkv.normalized.mkv' -D -S -B -T -M --no-chapters --no-global-tags 'normalized_temp/movie name.mkv.audio-003.mkv.normalized.mkv' -D -S -B -T -M --no-chapters --no-global-tags 'normalized_temp/movie name.mkv.audio-004.mkv.normalized.mkv' -D -S -B -T -M --no-chapters --no-global-tags 'normalized_temp/movie name.mkv.audio-005.mkv.normalized.mkv' -D -S -B -T -M --no-chapters --no-global-tags 'normalized_temp/movie name.mkv.audio-006.mkv.normalized.mkv' -D -S -B -T -M --no-chapters --no-global-tags 'normalized_temp/movie name.mkv.audio-007.mkv.normalized.mkv' -D -S -B -T -M --no-chapters --no-global-tags 'normalized_temp/movie name.mkv.audio-008.mkv.normalized.mkv'

fails with exit code 137.

I do not know why or what that code means.

My script Is used to normalize audio in parallel, since ffmpeg-normalize does not do that.

I first use FFmpeg to extract the video stream (where I only give it a length of 0 for video, to save time and disc space) with each one audio track which I then give ffmpeg-normalize with some arguments.

Afterward I want to combine the now normalized audio track and throw away the video of zero length which sits in each normalized file.

I need the video track to keep the offset of the audio relative to the video, otherwise this metadata is missing, and I’d need to manually re-align the audio.

Here is the output while running the above command:

mkvmerge v80.0 ('Roundabout') 64-bit
matroska_reader: Track 0 seems to be ok.
matroska_reader: Track 1 seems to be ok.
matroska_reader: Track 2 seems to be ok.
matroska_reader: Track 3 seems to be ok.
matroska_reader: Track 4 seems to be ok.
matroska_reader: Track 5 seems to be ok.
matroska_reader: Track 6 seems to be ok.
matroska_reader: Track 7 seems to be ok.
matroska_reader: Track 8 seems to be ok.
matroska_reader: Track 9 seems to be ok.
matroska_reader: Track 10 seems to be ok.
matroska_reader: Track 11 seems to be ok.
matroska_reader: Track 12 seems to be ok.
matroska_reader: Track 13 seems to be ok.
matroska_reader: Track 14 seems to be ok.
matroska_reader: Track 15 seems to be ok.
matroska_reader: Track 16 seems to be ok.
matroska_reader: Track 17 seems to be ok.
matroska_reader: Track 18 seems to be ok.
'movie name.mkv': Using the demultiplexer for the format 'Matroska'.
matroska_reader: Track 0 seems to be ok.
matroska_reader: Track 1 seems to be ok.
'normalized_temp/movie name.mkv.audio-000.mkv.normalized.mkv': Using the demultiplexer for the format 'Matroska'.
matroska_reader: Track 0 seems to be ok.
matroska_reader: Track 1 seems to be ok.
'normalized_temp/movie name.mkv.audio-001.mkv.normalized.mkv': Using the demultiplexer for the format 'Matroska'.
matroska_reader: Track 0 seems to be ok.
matroska_reader: Track 1 seems to be ok.
'normalized_temp/movie name.mkv.audio-002.mkv.normalized.mkv': Using the demultiplexer for the format 'Matroska'.
matroska_reader: Track 0 seems to be ok.
matroska_reader: Track 1 seems to be ok.
'normalized_temp/movie name.mkv.audio-003.mkv.normalized.mkv': Using the demultiplexer for the format 'Matroska'.
matroska_reader: Track 0 seems to be ok.
matroska_reader: Track 1 seems to be ok.
'normalized_temp/movie name.mkv.audio-004.mkv.normalized.mkv': Using the demultiplexer for the format 'Matroska'.
matroska_reader: Track 0 seems to be ok.
matroska_reader: Track 1 seems to be ok.
'normalized_temp/movie name.mkv.audio-005.mkv.normalized.mkv': Using the demultiplexer for the format 'Matroska'.
matroska_reader: Track 0 seems to be ok.
matroska_reader: Track 1 seems to be ok.
'normalized_temp/movie name.mkv.audio-006.mkv.normalized.mkv': Using the demultiplexer for the format 'Matroska'.
matroska_reader: Track 0 seems to be ok.
matroska_reader: Track 1 seems to be ok.
'normalized_temp/movie name.mkv.audio-007.mkv.normalized.mkv': Using the demultiplexer for the format 'Matroska'.
matroska_reader: Track 0 seems to be ok.
matroska_reader: Track 1 seems to be ok.
'normalized_temp/movie name.mkv.audio-008.mkv.normalized.mkv': Using the demultiplexer for the format 'Matroska'.
'movie name.mkv' track 0: Using the output module for the format 'AVC/H.264'.
'movie name.mkv' track 10: Using the output module for the format 'HDMV PGS'.
'movie name.mkv' track 11: Using the output module for the format 'HDMV PGS'.
'movie name.mkv' track 12: Using the output module for the format 'HDMV PGS'.
'movie name.mkv' track 13: Using the output module for the format 'HDMV PGS'.
'movie name.mkv' track 14: Using the output module for the format 'HDMV PGS'.
'movie name.mkv' track 15: Using the output module for the format 'HDMV PGS'.
'movie name.mkv' track 16: Using the output module for the format 'HDMV PGS'.
'movie name.mkv' track 17: Using the output module for the format 'HDMV PGS'.
'movie name.mkv' track 18: Using the output module for the format 'HDMV PGS'.
'normalized_temp/movie name.mkv.audio-000.mkv.normalized.mkv' track 1: Using the output module for the format 'Opus'.
'normalized_temp/movie name.mkv.audio-001.mkv.normalized.mkv' track 1: Using the output module for the format 'Opus'.
'normalized_temp/movie name.mkv.audio-002.mkv.normalized.mkv' track 1: Using the output module for the format 'Opus'.
'normalized_temp/movie name.mkv.audio-003.mkv.normalized.mkv' track 1: Using the output module for the format 'Opus'.
'normalized_temp/movie name.mkv.audio-004.mkv.normalized.mkv' track 1: Using the output module for the format 'Opus'.
'normalized_temp/movie name.mkv.audio-005.mkv.normalized.mkv' track 1: Using the output module for the format 'Opus'.
'normalized_temp/movie name.mkv.audio-006.mkv.normalized.mkv' track 1: Using the output module for the format 'Opus'.
'normalized_temp/movie name.mkv.audio-007.mkv.normalized.mkv' track 1: Using the output module for the format 'Opus'.
'normalized_temp/movie name.mkv.audio-008.mkv.normalized.mkv' track 1: Using the output module for the format 'Opus'.
The file 'normalized_staging/movie name.mkv' has been opened for writing.

After about 6% it just stops and gives no further output, the $? is 137.

With the available default via apt on ubuntu 22.04.3 LTS I have version mkvmerge v65.0.0 ('Too Much') 64-bit with which the above does work.

And on another machine with Ubuntu 20.04.6 LTS with version mkvmerge v45.0.0 ('Heaven in Pennies') 64-bit it also works

Welcome!

I’m sorry, but I don’t know what the cause might be. It sounds like the mkvmerge executable might have been killed by a signal (out of memory? some kind of violation of the Flatpak sandbox? no idea…). You might want to look into available logs from Flatpak and the system’s journal around the timestamp when the run failed.

That being said, I also offer up-to-date binaries for Ubuntu, including 22.04. See here for instructions. I suggest you use those if the Flatpak variant doesn’t work properly.

Ah, I so far am not familiar with how to do that since I never had the need to do that.

I am fine with using both the default and the one from flatpak. Since when both are installed my script just uses the first available one, which I changed to be the default opposed to flatpak.
And in any interactive shell I have aliases for the flatpak version, meaning I can copy merge commands from the flatpak-GUI into an ssh session and run them in a screen session on another machine and detach. Previously, this was not possible for me because of the version mismatch between the OSes running on the two machines.
But just selecting fewer and renaming audio tracks worked great with the flatpak version.

And I ever so much appreciate the newer version having a dark mode.

Unfortunately I cannot help with that either (as in I don’t know if Flatpak has any kind of logging in the first place, and if it does, where it logs to). I suggested the system’s journal as that’s a likely place.

I just ran it with flatpak run -vv but that only printed a bit of info at the start, nothing at the end
https://pastebin.com/ME4k1GAJ

And the native “Log” app doesn’t show anything worthwhile when I search for flatpak or bunkus. A bunch of messages by systemd about starting a flatpak job, and that they finished successfully.

I also tried to run it locally, without accessing a file system on another machine through sshfs.
That did work, here is a log of that (since it ran through my python script, I had to replace the escaped newlines with actual newlines, and the stderr and stdout are not mixed)
https://pastebin.com/9FWgLaeB

Edit:
Yea, the problem seems to stem from the flatpak version and using some network attached storage mounted on a local path. When I run the same flatpak command on the machine where the storage resides, it merges without error.