Experimental Video Playback Solution (cantabile-media-server)

Here’s a first pass of a barely working, minimally viable MIDI controllable video/image playback solution.

Installation/configuration instructions.

It works by using a web browser as the video playback front end. It includes a simple web server that runs on your local machine and can serve media files. It can be MIDI controlled so from Cantabile you can switch videos, play, pause etc…

Let me know of any issues, questions etc…

Brad

2 Likes

Ta. Will take a look when I get five mins

1 Like

Hi @brad

Testing on a local machine first, and I have the basics working, with the following observations, some of which I need to double check. Will have a bit more time to look at this again tomorrow.

  • GIT needs to be installed on your machine as well as Node JS, otherwise the npm install command to install the cantabile-media-server as git is an unexpected command, so suggest adding that git dependency to the instructions
  • My Floyd video files are MPG not MP4, so were not being played, as I assume the mime type is not registered. Could MPG be added? I converted a couple to MP4 to get going, and could carry on with that if needed.
  • Need to double check as I was changing things whilst trying to get the video to work, but I am guessing file names with spaces in are not liked and names/extensions are case sensitive? - need to check further
  • Also assume if you change the programFile contents you need to kill and restart the cantabile-media-server fails?
  • On that note, there seems to be no way to kill cantabile-media-server other than closing the CMD prompt and starting a new one. Well, CTRL+C did not work, you get a SIGINT message in the terminal but nothing happens.

Hope that is all useful feedback. I think this will be incredibly useful as it matures, and probably will allow me to forget the clunky SCS11 as even now, I think the features of cantabile-media-server are all I need.

Once I am happy with the local operation, I will move onto a distributed system via RtPMIDI

Probably. Eventually I’ll post it to npm which will remove that requirement.

Might just need to add file extension support if supported by browser. If not they’ll need conversion (manual for now maybe auto later)

Will check.

Correct for now. Was planning on adding auto reload.

Hrm. Worked for me but maybe because I’m using Windows Termial (not cmd.exe). I’ll look into it.

Thanks for testing/feedback.

Brad

No problem. I managed a little further testing, and names with spaces are fine (my preference)

I have also wrapped up the commands into a batch file, which makes restarting a lot easier.

Would there be a way of specifying the default MIDI channel in the browser rather than setting it all the time?

Also, happy to convert the videos to MP4 if needed.

Anway, a few bindings in Cantabile and the basics are there

There’s no “default”, but you can specify it in the URL like so which means you can link to it, bookmark it etc…

http://localhost:3000/#ch=2

Looks like you’ll need to do this. The files need to be in a format supported natively by the browser. See here. I’ve tested with mp4 and webm. Not ogg yet.

I’m a bit conflicted whether to include support for automatic transcoding. It’d be nice I guess, but also not something you want to waste CPU cycles on in a setup like this.

fwiw, ffmpeg makes it easy to convert files:

ffmpeg -i input.mpg output.mp4

Great, thanks for testing.

I’ve reproduced this at least once - I’ll see if I can get it fixed. Fixed.

To install latest just re-run the install command:

npm install -g github:toptensoftware/cantabile-media-server

Latest version also displays version number/banner when run:

cantabile-media-server 0.0.2
Copyright (C) 2024 Topten Software. All Rights Reserved

Changes in 0.0.2

  • Ctrl+C now shutsdown cleanly
  • .ogv file support (in theory, untested)
  • Updated docs
1 Like

Hi, @brad

I agree it is not worth converting files on the fly, I do not want to waste CPU cycles live on doing that!

Thanks for pointing out FFMPEG. I was looking for a free tool yesterday for doing this and could not find one. It converted my two video files I am testing with fine. More than happy to do that conversion for all files offline as it is a one time task that will not take long.

I can also confirm that CTRL+C is now working on my setup as well.

So, this is all working nicely now. With my test files (including videos and static images) now working on my video laptop as well via an RtPMIDI network connection.

I have the Video MIDI port for Cantabile on my DAW PC going to both LoopMIDI and RtPMIDI so I can fire both local videos and videos on the laptop to start at the same time, and performance is good. I cannot see any discernible latency between the videos being served on my DAWPC (would be my GIGPC when playing live) or on the VIDEOPC

I currently have two songs in my old Welsh Floyd set being used for testing (the first two videos in alphabetical order!)

  • Another Brick In the Wall Parts 1 and 2
  • Breathe, On the Run and Time

Both songs and the bindings in them are working perfectly in terms of selecting, starting and stopping the videos, so if we get going again, I now have no need to faff about with re-registering and getting the clunky old SCS11 product that I was using up and running again (it was an affordable but not elegant solution for PC that supported MIDI triggers). I am already happy to move over to the Cantabile Media Server. :slight_smile:

I will for completeness now convert the whole set, so it’s done and ready if we do start again, and of course follow development of the Cantabile Media Server with interest, and happy to do more testing.

If it helps others experiment with this, here are some screen shots of my bindings. I have them working now on CH14, which is my video channel as that keeps video MIDI cues separate to DMXIS MIDI cues, which are also sent via RtPMIDI on different channels. I am using a bookmark in my browser as you suggested above to recall the connection on the correct channel.

The binding group, with three bindings is shown first. I do not use a background rack, but for those who do, the transport bindings could go in the background rack or other common rack for a set. In Welsh Floyd I cannot do that as we need to start at least one video manually, which I do from a high key on the keyboard.

The binding to select the correct video in the Cantabile Media Server - the PC number will of course change per song to match what is in the programListFile. I also have bindings to select a static pre-show image, and a blank image.

The binding to start the video when song playback starts.

The binding to stop the video when song playback stops.

Thanks for your work on this. If you remember, I have two video use cases, one in Spectral Streams that dynamic and interactive for which I am using Imaginando Visual Synthesizer, and one for Welsh Floyd that is more linear playback of precanned videos along with a linear click/backing track. Cantabile Media Server already fits my second use case perfectly :slight_smile:

3 Likes

My Welsh Floyd set is now all completely setup with video back on all the songs that require it, so I would say this is a great function which even in an early release form does what I need.

The only problem I have noticed is that FFMPEG does not successfully convert all videos - they freeze at some point in playback in some videos - especially the length ones - consistently at the same point for each video - I see the same problem if I play the video in Windows video player and VLC, whereas the original MPG files are fine. So will need to look into that. That is of course not an issue with the Media Server. If you search the internet for “FFMPEG Freeze”, it seems a common problem as you come across posts with lots or arcane command line options!

I was thinking, as a lot of the Floyd videos can be a black screen for a long time, if it was possible for the Media Server to send some form of feedback via Media to reflect that it has acknowledged commands, which you could use to drive an indicator on the Cantabile tool bar. E.g. a MIDI CC to reflect the selected program/video and a CC to show transport status (0=stopped, 1 = paused, 2 = play). Just a thought.

Maybe you need one of FFMPEG’s ten thousands switches+parameters? :thinking:

Another option is Handbrake.

1 Like

That’s an idea. What if for now it just confirmed it with a log entry in the server’s output window?

Another thing I’ve been thinking here, is it would be relatively easy to provide a network (instead of MIDI) based control interface to the server. This could more easily provide acknowledgement feedback. Downside - it would also require changes in Cantabile to send such network commands.

I’ve just pushed up version 0.0.4 with:

  • Option to watch the programList.txt for changes and automatically reload (requires --watch command line option ie:
    cantabile-media-server --watch
    
  • Command line switch to list available midi devices
  • Command line switch to control logging verbosity
Usage: cantabile-media-server [options]

Options:
   --list-midi-devices      Shows a list of available midi devices
   --watch                  Watch and automatically reload program list file when changed
   --verbose                Shows more logging
   --help                   Shows this help
   --version                Shows version info

I’m going to leave development of this as is for now (bugs and simple suggestions not withstanding).

There are still two areas I’d like to address at some point and I’m cursiou for further feedback:

Time Sync

I’d like to provide more precise time-syncing abilities by broadcasting time clock information. This will require considerably more effort, including adding MTC broadcast support to Cantabile and devising an algorithm to adjust the playback speed of the web video players to keep things in sync and prevent drift.

I’m not against doing this but I can’t justify that effort without more demand for it (although curiosity might cause me lean into it at some point).

Camera Support

Theoretically this could support cameras as is, but would require a separate external streaming server to provide the video feed. Suppose you had a such a feed(s) available you should be able to configure the feed URLs into the program list and selecting that program should show that camera feed.

Here’s a guide on setting up OBS with a custom RTMP nginx server that should work. It doesn’t - see below.

I’ve not looked into this any further except to guess that it should maybe perhaps be possible. If anyone experiments with this and figures it out, please post about it here.

1 Like

So nginx/rtmp doesn’t really work for broadcasting camera feeds to a web browser.

What looks like it should work though is OBS → MediumTx → WebRTC → Browser. I haven’t got it working with cantabile-media-server yet, but did get a feed going to the browser.

From what I’ve read WebRTC is the lowest latency way of doing this.

Question: how much latency on the camera feed is tolerable?

Here’s a video showing it.

The “camera” is just a screen capture of the top left display and there are two client views. The top-right is the same machine, the bottom laptop view is over a local wifi network (machine 1 → wifi router → machine 2). You can see as I drag the window the two remote views lag by about 0.5 seconds.

I suspect this is about as good as it gets.

Maybe a first iteration could just be a location sync, without any fancy playback speed adjustment. Just react to MTC → if current play position is too far off the MTC position (e.g. > 1 sec), simply skip to the correct position. This would help when skipping within a song especially during testing / rehearsal, e.g. “let’s play chorus 1”.

This would also act as a (brutally rough) drift prevention - if things get too far apart, simply skip to the correct position, but don’t spend too much effort on micro-adjustment to correct for millisecond drift…

I think a minimal “skip to MTC position” would be super-helpful in a lot of usage scenarios.

1 Like

I use Handbrake or XMedia Recode - both have a number of reasonable presets for MP4 encoding that work nicely for me

Hi, Brad

You are already doing that :slight_smile:

But the issue is if I have the laptop fully screen (assuming I am not extending the desktop) then I will only see the video. Ditto, Cantabile is fullscreen on my GIGPC.

That’s why I was suggesting CCs as a simple feedback option without having to update Cantabile.

But reflecting on it, maybe I am being overly pessimistic. it is working fine and if part way through a song where a video is meant to go from black screen to content, then we are not going to restart the song!

So I would say consider a feedback option only if it is trivial.

Thanks all for the comments/suggestions.

In the end I went for Movavi Video Converter for Mac – Free Download which is a paid annual subscription (but I only need it now) once I verified in the trial version (which watermarks videos) that it was doing the job for all videos with no need for experimentation for a myriad of arcane command line options.

OK, not a free solution I was ideally after, but neither really is time spent wasted on finding something that works. So I went for a paid solution in the end. BTW the MAC choice was deliberate as that is what I do video editing on.

It also did a good job of up scaling these old videos to 1080p, so one less thing to have to tax a processor to do in real time.

1 Like

Hi, @brad

I would say you are already there in terms of useful core functionality. I personally do not need MTC sync as long as the trigger is low latency/low jitter, which it appears to be.

But as you say, sometimes the technical challenge reels you in! :slight_smile: That’s happened to me a few times, especially when people think it cannot be done! For me it was adding SMDI support to my EX5 librarian and then coding around the EX5 SYSEX bugs to allow data transfer via SYSEX without data corruption!

No comment on Camera Support as I have no need for that.

1 Like

Hi Brad - one feature I forgot to mention is control over the video playback’s audio volume. In my case most of the videos have audio but I want to keep their audio off; for one song I do need the audio turned on.