Command-line conversion - keep musecore running for faster conversion?
I'm looking into MuseScore for bulk typesetting small MusicXML files that are generated on the fly. I want to do this online, so performance is important. Using the standard command-line options it takes upwards of 1 second on my machine. I'm sure that most of that is setup and teardown. Batch mode doesn't solve my problem because it's a never-ending batch.
Is there any way to keep the process running and pipe data in and out of it? Like with STDIN/OUT or a socket? The command-line options don't hint at anything.
Thanks in advance!
Comments
there is a) the batch convert plugin and b) the -j jsonfile option, both allow to converte multiple files in one session, but neither allows musescore to be run in a pipe or socket, such thing is not possible with MuseScore as it never reads files from stdin nor writes them to stdout
In reply to there is a) the batch… by Jojo-Schmitz
Thanks a lot JoJo, it's good to know I'm not looking for something that isn't there!
In reply to Thanks a lot JoJo, it's good… by afandian
You could have a look to the OSC server implementation and add a command to do the conversion. Check osc.cpp in the code base.
In reply to there is a) the batch… by Jojo-Schmitz
The batch conversion works rather well if you can generate (all) the input files before you need the first output file, though. Or can convert in batches.
I would also love to hear about this. The dream is that Musescore would run from the command line without loading QT / connecting the window server (which is probably most of the startup time) and in a continuous mode like this. But I guess it'd need a fair bit of work to get there.
In reply to I would also love to hear… by Geordie J
Oh, right, the PR got merged, so you can now batch-convert in large style in 3.1.
Not using Qt, not connecting to the X Window server, is not feasible though: a lot of the things it does depend on it, down to font configuration. In
-j
mode, at least it doesn’t create the GUI, so there’s that (it’s a tad faster).In reply to Oh, right, the PR got merged… by mirabilos
Thanks for the news! I’m stuck on 2.x until the extent of plugin support catches up in the new versions but sounds like something to look forward to.
In reply to Thanks for the news! I’m… by Geordie J
The Debian GNU/Linux packages of 2.3.2 also ship the extended batch conversion code ;-)
In reply to The Debian GNU/Linux… by mirabilos
I did see the -j option but the inline help doesn’t give any examples of how to use it. Is there documentation for it online that I’ve missed?
Edit: I found this https://musescore.org/en/handbook/3/command-line-options#EXAMPLES
But I suspect the issue we are having is actually different: In my tests if I ran Musescore with a plug-in, the svg output produced (on the same invocation) was produced before running the plugin. Maybe this bug has been fixed now but we actually had to save a new mscx file with changes from the plugin and run another invocation.
I’m just editing the mscx XML programmatically instead now (which I’d rather not do, but seems to be the only way of reliably changing the page layout) so maybe running the plugin and exporting in one invocation will be enough.
In reply to I did see the -j option but… by Geordie J
$ cat foo.jsn
[
{
"in": "/usr/share/mscore-snapshot-3.1/demos/Reunion.mscz",
"out": "Reunion-coloured.pdf",
"plugin": "colornotes.qml"
}
]
$ musescore-snapshot -j foo.jsn
This generates a PDF with coloured notes for me. Mind, the plugin must be in the correct directory for this to work. (I also forgot the
.qml
at first, making it silently ignore the plugin line.)I am having the same problem trying to convert a large number of XML files to images and running a plugin. I found that using batch option -j takes still 85% of the time compared to calling MuseScore as separate command on each file. In my case this results in upwards to 24h of waiting.
Has something changed in the mean time, allowing to do jobs like this more quickly/without all the MuseScore startup?
Is there a certain reason why command line is not substantially quicker than starting MuseScore.exe?
In reply to I am having the same problem… by harmony8
I fear the conversion just does take the time, and Mu͒seScore Studio is not the most efficient software in existence (though for me, all but the MP3 generation is relatively speedy).
You do put all the files to convert into one JSON and run the mscore command just once, right?
In reply to I fear the conversion just… by mirabilos
I do both versions in a multithreaded python script
In reply to I do both versions in a… by harmony8
You “do both versions”?
In reply to You “do both versions”? by mirabilos
Once calling MuseScore per command line on each score and once calling MuseScore once per command line utilizing the job option