Optimizing .mkv files for streaming with mkclean during postprocessing

Feature Request:
The option in post processing to automatically optimize downloaded .mkv files for streaming with mkclean.

Why is this necessary:
Some devices with built in media-players such as smart tv’s, blu-ray players etc. are unable to play some mkv files which are muxed in a certain way (about 50% of the online content). There are two ways to fix this, one way is to remux the mkv file, the other is to “clean” the mkv file. The cleaning is more practical since it takes much less time and cpu power and can be done with a small standalone opensource program called mkclean, made available by the matroska group. After the file is cleaned it is playable again for any player that vaguely supports mkv files. It also improves the stream-ability of mkv files (less stutter).

What is mkclean (from the matroska website):

mkclean is a command line tool to clean and optimize Matroska (.mkv / .mka / .mks / .mk3d) and WebM (.webm / .weba) files that have already been muxed. It reorders the elements with the Cues at the front, so your Matroska files are ready to be streamed efficiently over the web. It also removes elements not found in the Matroska specs and the extra Meta Seek list of Clusters that some program add to their file. It can also optionally remux the Cluster blocks to start each boundary with a keyframe and the matching audio/subtitle blocks for that keyframe.
source: http://www.matroska.org/downloads/mkclean.html

Why would it be awesome if it’s integrated in Sonarr:
The beauty about programs like Sonarr is that everything goes automatic, the only thing I still have to do with my downloaded series/movies is checking if the file can be played. As I said with 50% of the downloaded files this is not the case, then I need to download the file from my NAS to my computer, run mkclean and re-upload it to my NAS. Which gets annoying…
An argument could be made that you can make a script that refers to mkclean, but i don’t have the knowledge to do it and i don’t know how to run mkclean on my NAS. Besides, if you would go that route, you’ll probably need 2 blackhole folders which isn’t the cleanest method.

Anyway, I don’t know if it’s easy or very hard to implement, but I would appreciate it if you could at least determine if it’s easy or hard and then go from there. If it’s hard and it takes too much time I fully understand. I will keep using Sonarr either way :wink: .

source code mkclean:

1 Like

This seems like a great use for: https://trello.com/c/mCJyYeZl/122-custom-notifications-scripts-similar-to-sab-post-processing-scripts once its implemented. I really don’t see this being something implemented in Sonarr, I realize this makes it a bit harder to do, but ultimately it gives much more control to everyone, without use having to maintain it and support it on multiple platforms.

Just a suggestion for OP (and something I may do) - put this in an nzbget PP script. :smile:

@markus101 If I understand things correctly, if I do put this in an nzbget PP script, the script would run first, then sonarr would process the file, yes?

That is correct.

I see, well thanks for looking into it :wink:

Yeah that’s a good suggestion, I use transmission but it’s the same concept. Only problem is that I don’t have the skills to be able to run mkclean on my NAS and write a script for it ;).

Well, I’m working on it for my ubuntu servers. Want my finished product once I have it, if I have it?

mkclean has source files, so you may be able to compile it on the nas.

I think I actually have this working now. :smile:
Let me know if you want the PP script I made for nzbget.

Keep in mind that this only works for nzb grabs, not torrents. I’m not sure if running it on torrents will work, as it may change the torrent, thus screwing up your seeding.

Yeah that would be great! I don’t know if I can get it working with torrents as you said but I might be able to do some adjustments. At the moment I’m still trying to figure out how to cross compile the source code to be able to work with the arm processor of my nas.

Here’s my really simple and probably really bad script, but it seems to work.

Thank you :wink:

where do we put that script to get sonarr to run it automatically

It’s an nzbget script, not a sonarr script.

So if you’re running nzbget, you put it in the scripts directory and just tell it to add that to all downloaded nzbs.

It works reasonably well, but running the mkclean does increase processing time noticeably.