Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fully non-interactive work-flow #50

Closed
csillag opened this issue May 30, 2020 · 8 comments
Closed

Fully non-interactive work-flow #50

csillag opened this issue May 30, 2020 · 8 comments

Comments

@csillag
Copy link

csillag commented May 30, 2020

I would like to integrate MIDIVisualizer into my automatic workflow for creating educational videos based on MIDI files. Basically, I would like to use it is a filter within a scripted workflow: the MIDI file comes in, and the rendered images come out.

Currently, I have to manually open the MIDI file, then manually load the settings, set the image size (via setting window size), set the FPS, then start the button for offline rendering, select the directory, etc.

Ideally, I would like to specify all of these either as command like arguments, or as part of the settings file to load. (And then the name of the setting file should be added as a command line argument.)

When running the app in this mode, the GUI shouldn't even be shown; just execute the task at hand, and then exit.

What do you think about this? Would you accept a PR that enables this?

@csillag
Copy link
Author

csillag commented May 30, 2020

The most difficult design question here is figuring out the syntax the CLI argument. Currently there is some guess-work, based on the number of parameters given. Ideally the syntax could be made more flexible by introducing name parameters, like --midi <path-to-midi-file> --color R G B --resolution <WxH> --settings <path-to-ini-file> --fps 50 --generate

There are several libraries that make things like this very easy... but if we really want to avoid adding any dependencies, it's also possible to it manually...

@csillag
Copy link
Author

csillag commented May 30, 2020

Hmm, I see that this is implemented on @ekuiter's fork...

@ekuiter
Copy link

ekuiter commented May 30, 2020

Yes, in my fork you can run sth like this to render the individual frames. ("State" is the configuration file.)

./MIDIVisualizer [path/to/file.mid [state [width height framerate [output_directory]]]]

Or you can omit the directory and pipe the raw video stream into ffmpeg to render a video file:

./MIDIVisualizer file.mid state width height framerate \
    | ffmpeg -y -hide_banner -r framerate -f image2pipe -vcodec ppm -i - -c:v libx264 -pix_fmt yuv420p -crf 0 video.mp4

If you are working with MuseScore/MusicXML files: bemuse uses this internally to export a MSCZ file to PDF, MIDI, MP4 etc. and also has nicer command line arguments.

@csillag
Copy link
Author

csillag commented May 30, 2020

Yes, I have already integrating the fork into my workflow. Actually, I have a simpler command:

midiviz $(MIDI_FILE) $(MIDIVIZ_CONFIG) $(VIDEO_W) $(VIDEO_H) $(VIDEO_FPS) | \
   ffmpeg -r $(VIDEO_FPS) -i - -vcodec libx264 -crf 0 -preset veryslow $(OUTPUT)

Actually, I see two challenges with the fork:

  • The pre-roll setting seems to be ignored (until that's fixed, I will have to compensate by other means)
  • I prefer the major/minor coloring, as opposed to tracks, because there is only one track. (I will have to do some MIDI pre-processing to restore the major/minor behavior.)

I will check out bemuse later. I am using MuseScore, but not for the current project. For this, I am using live MIDI recordings..

@ekuiter
Copy link

ekuiter commented May 30, 2020 via email

@csillag
Copy link
Author

csillag commented Jun 1, 2020

As for the key coloring, yes, this would have to be undone manually (maybe you could revert some of the commits on my fork, or just check out an older version where the key coloring was still unchanged, and cherry-pick the stdout rendering).

Nah. I just created a small MIDI pre-processor, so that I can use your version as-is, without making any changes to the code, but still get the result I need.

@kosua20
Copy link
Owner

kosua20 commented Jul 20, 2020

Hello to both of you! First of all a huge thanks for your suggestions and solutions, and your assistance with the Github issues!
I've added support for a full command-line export pipeline, directly to video (or images) in the latest v5.1 release. I hope this helps, and could probably be backported to your forks if needed.
I'm also planning on fixing the multi-tracks issue in the near future, with some options to preserve the current major/minor coloring, but I need a bit more time for this, and I really wanted to get the video export out of the door.

@kosua20 kosua20 closed this as completed Jul 25, 2020
@csillag
Copy link
Author

csillag commented Mar 5, 2021

Hi @kosua20!

I took a bit of a pause from generating music videos, but now I am back. I have recently tested this, and it works wonderfully!
Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants