How would you route and sync the audio of video playback in Max 7 (avf)?

Masa's icon

Hi, I used to use spigot~ to sync and route (to specific outputs) the audio of video playback in Max 6, but now I'm planning to do differently to benefit from avf engine (and 64 bit Jitter).

My current basic idea is:
1. Set engine to qt and create an audio file separately by using spigot~ and locate it under "spigot-cache" folder
2. Set engine back to avf
3. Play the audio file with sfplay~ and sync by sending "gettime" message to jit.movie and routing the 'time' data to sfplay~

I appreciate your idea,
Masa

Rob Ramirez's icon
Max Patch
Copy patch and select New From Clipboard in Max.

depending on the size of the movie file, i would use the import message to buffer~, and use groove~ to control playback, and sync using the groove~ sync-out with the new jit.movie @position attribute.

unfortunately, this only works in 32 bit mode. if you must use 64 bit mode, or if your movie files are too large to fit into memory, then i would simply export your movie audio to a separate audio track using quicktime or mpeg streamclip. the syncing can be done the same way, or you can sync using sfplay~ instead of buffer~ and groove~. in that case you need to tell sfplay~ to create a third outlet that outputs the current playback time. check out the "more features" tab of the sfplay~ help file for info. the playback time is in milliseconds, so simply divide by 1000.0 and send to the new jit.movie @time_secs attribute.

Masa's icon

Thank you very much for the great example patch and the explanation. I can learn a lot from them!
Thank you for the alternative idea for 64 bit mode as well.
By the way, it's kind of a sub-topic and out of curiosity, but 'spigot_cache' message for spigot~ has been discontinued?

kleurbleur's icon

After done some testing I expected much less impact to route the audio to another channel.
Testing is done with Max 7.0.5, OSX 10.10.5, mbp retina 2014 Gefore GT 750M.
H264 and ProRess are identical, res is 1080P. Frame rates were all good unless noted.

jit.movie: H264 6% CPU
jit.movie sfplay~: H264 90%
jit.movie groove~: H264 30~40% ProRess 100%
jit.movie spigot~: H264 100% (10fps avg) ProRess 100% (60fps avg)
jit.qt.movie (vade optimatizations): H264 40%

In the end I want to play three 1080P files on a new top of the line yet to buy Mac Mini with each file having a headphone for itself. I was very positive after building the first part with only jit.movie. Now I'm not so sure if the Mac Mini is capable of doing the groove~ option. Any ideas on this?

Rob Ramirez's icon

3 simultaneous 1080p movies with synced audio tracks should be possible with a new-ish mac mini, as long as you have @output_texture enabled and keeping the default avf engine as the backend (which means no spigot~ functionality).

if you only need playback, and won't require random time seeking, or backwards playback, you might be better off with h264, which will keep the file size down. if you need random seeking, then you should use prores or photo-jpeg.

kleurbleur's icon

No random seeking is needed, just playback. I'll go with the buffer~/groove~ option. Will try to post here if I got some test results.Thanks!

Any clue when more normal audio outputs from jit.movie are coming?

Fedde's icon

It seems that 3 simultaneous 1080p movies is the absolute maximum on my mac pro 2ghz intel core i7, with Intel Iris Pro 1536 MB.

When inserting another (4th) audio synced video player, this one starts to freeze, while the other players stay fluid, when reading the frame rate all the four players are running on 24 fps. So what's the hidden clue here?

Rob Ramirez's icon

you might have more luck with the jit.gl.hap external (32 bit only), and encoding your movies with the HAP encoder. search above to find the external in the toolbox, with links to the codec.

kleurbleur's icon

We ended up encoding the right channel output in the PhotoJPG encoded Quicktime movie after exporting from Final Cut Pro. You can set the channel in Quicktime Pro 7 by pressing cmd+j, select the audio track and the choose the right channel.

We messed up this project mainly because we found out that the external audio card (Hercules DEEJAAY 4+6) has a delay compared to the HDMI output from the Mac Mini + TripleHead2Go. In the final version we exported the movie with an audio delay so it would be in sync again.

Fedde's icon

@Rob Hap increases the performance significantly.
It runs five instances of audio synced video at a 45FPS on my on my mac pro 2ghz intel core i7, with Intel Iris Pro 1536 MB.

But since hap encoding produces pretty large files I'll need a proper external ssd for the amount of material I'm going to process.
Do you think the LACIE RUGGED THUNDERBOLT SSD 250 GB is fast enough for this?

Fedde's icon

The external ssd drive is definitely fast enough. My project runs like a charm. 5 screens on high definition simultaneously alternating different video's and different audio sources perfectly in sync. I think I can even scale the project up to a few more displays.

Gaston Ibarroule's icon

Hello everyone! I’m pretty new in Max but I’m trying to build a video player, Quikctime with 7.1 multichannel audio, and I would like to extract the audio and reroute the channels to different speakers. I have been having problems with other player and I feel Max will be the most versatile. Can anyone point me in the direction to be able to extract the audio and reroute? Thank you!