11ffload~ external

    Aug 17 2017 | 2:46 pm
    I just wrote an external using libav that requires the shared ffmpeg dll's. I noticed it keeps working even after removing the additional libs from the search path. So i did a search and it turned out the viddll package comes with this files. Does that mean we can write cool ffmpeg externals without having to provide the shared libraries. Is it the same on the Mac?

    • Aug 17 2017 | 4:09 pm
      possibly on windows, but the Mac libraries have to be loaded from the viddll.engine library so I don't think that will work.
    • Aug 17 2017 | 7:18 pm
      I'm seeing dylib files with the same names. isn't it the same prinziple on Mac (xcode), linking the project with dynam. libraries and that's it? I did compile externals for Mac but I think I never had to deal with dylib files. I'm going to find that out
    • Aug 18 2017 | 5:14 pm
      well, def let us know. maybe it works fine!
    • Sep 20 2017 | 1:28 pm
      Some progress here: On Windows it works fine. It's all good if the ffmpeg dlls are somewhere in the search path, which is granted if the VIDDLL 1.1 Package is present.
      On MacOs, after I successfully installed ffmpeg-devel package with MacPorts to get the header files, i'm adding the dylib files to the xcode project and the build succeeds. But when external gets loaded the dylibs can't be found : (for some reason it only reports the error for libavformat. I'm also using libavcodec and libavutil. I don't know if that means the other 2 dylibs have been opened successfully, I assume not)
      11ffload~: unable to load object bundle executable 2017-09-20 15:59:52.917 Max[727:707] Error loading /Users/admin/Desktop/max-sdk-7.1.0/externals/11ffload~.mxo/Contents/MacOS/11ffload~: dlopen(/Users/admin/Desktop/max-sdk-7.1.0/externals/11ffload~.mxo/Contents/MacOS/11ffload~, 262): Library not loaded: @loader_path/libavformat.57.dylib Referenced from: /Users/admin/Desktop/max-sdk-7.1.0/externals/11ffload~.mxo/Contents/MacOS/11ffload~ Reason: image not found
      Do you know where variable @loader_path is looked up or can be set to be the viddll support folder. It seems to look inside the mxo bundle for the dylibs. Do I maybe have to use dlopen() manually in the external? Would I even find the dylibs without hardcoded path? It seems the max.app folder is not in the search path opposed to Max 7 folder on Windows.
      I really prefer a solution that refers to VIDDLLs dylibs. Don't want to bundle 30mb with an extenal, 30mb that are already present in every users Packages folder.
    • Sep 21 2017 | 10:45 am
      I edited the binary in the mxo bundle with install_name_tool. I replace the "@loader_path" parts with absolute paths to "/Applications/Max.app/Contents/Resources/C74/packages/VIDDLL/support/libname.dylib" and IT WORKS. really, could it be so simple? (after reading endless posts, saying you can't link to a dylib outside the app bundle i'm confused) Is it correct that the Max app path is a fixed thing on Mac and I can rely on this hardcoded path working on every Mac + Max?
    • Sep 22 2017 | 12:40 pm
      Having all applications in the Application folder is something I never liked in OSX. So on my Macs, Max is not in the Application folder, nor in ~/Applications. And if you create standalones with you external, I guess it won't find the library.
    • Sep 22 2017 | 1:22 pm
      Hmm ok thanks for the info. So the path is not reliable. You are right, creating a standalone is another problem where it makes no sense to link to Max app. For now I was hoping I can make it work crossplatform in Max4Live. At least I can be sure the Max app is somewhere on disk in this environment. But i'm kinda loosing hope it will work on Mac. If I pack the libs with mxo bundle i got a 33mb external. Is that a problem at all? O.
    • Sep 22 2017 | 7:26 pm
      Omg, turns out every mxo knows the location of the Max binary at runtime and can navigate relative to this location. i'm setting the pathes like this: "@executable_path/../Resources/C74/packages/VIDDLL/support/libavcodec.dylib" i didn't noticed first but that's how they find the jitter and audio framework: @executable_path/../Frameworks/MaxAudioAPI.framework/Versions/A/MaxAudioAPI @executable_path/../Frameworks/JitterAPI.framework/Versions/A/JitterAPI
    • Oct 15 2017 | 12:43 pm
      Any news on your experiments? I'm using ffmpeg via shell right now, looking for a more convenient way to reas and re-encode a stream directly in max. Since I'm here, another question, is there a way in max/jitter to play an open video file?(I mean a videofile that is still been encoded). I can open a ts file with jit movie it just lets me watch what has been recorded at the time i ve opened the file. I need to reopen the file everytime I want to so see a new part of the stream. cheers
    • Oct 15 2017 | 4:26 pm
      I have a working prototype that decodes any file into a buffer~ like the "replace" message of buffer. I have not investigated into the video part of ffmpeg but that is probably what viddll and related jit externals do. I got a little bit lost and frustrated trying to implement a clever solution for handling big files, i mean files that exceeds buffers maximum size. Once i can finalize the last 5% of the external i'm happy to share it + source code. But, like i wrote above, it uses a thread to decode an audio stream to buffer~, no video involved.
      Basically I think you can put any ffmpeg feature into in external. What helped a lot was to code the function in an executeable to debug and create a working example before moving it to an external. Even this first step was a lot of struggle as most examples on the web are outdated if you use latest libs.
    • Oct 16 2017 | 10:00 pm
      seems really interesting. I'm looking forward to it, have fun and a nice week ;)
    • Oct 31 2017 | 4:13 pm
      this requires Max 7.3.4
      [beta download removed] scr included. If this works for everybody I'll put this to my site as a download. And HappyHalloween for all you guys ;)
    • Nov 02 2017 | 8:10 pm
      very cool 11OLSEN, thanks much for sharing and congratulations on getting those libraries working for you!
    • Nov 03 2017 | 12:08 pm
      Hi, 11Olsen. Great external. It's particularly useful when simultaneously dealing with audio and video/3D animation. I've done it in the past and there's some pauses in Jitter while audio is being read from disk. It really should be the standard behaviour of the loading process of buffer~ and other similar objects.
    • Nov 03 2017 | 12:23 pm
      Yes, I want to do an audiofile-browser-like thing. And a seemless prelistening function of files is not possible with the blocking behaviour of the default objects.
    • Dec 12 2017 | 5:05 pm
      I removed the beta version download. I fixed many bugs since then, some of them are critical.
      Second, i noticed that when the osx external is frozen into a m4l device the "unable to load object bundle executable" - error is back. The frozen device state seems to isolate the externals from the max app ? Seems this is not finished yet. I have to dive into it again.
    • Dec 13 2017 | 2:41 pm
      As long as the m4l-Editor is not opened, the @executable_path for externals links to the Live app. Where it finds the Max frameworks but of course not the viddll package. Ok didn't know that.
      Maybe that changes with Live 10. For now I see no other way than using @loader_path and including the dylibs in the mxo bundle. sad
    • Jan 12 2018 | 10:06 pm
      Here's version 1.0: http://www.11olsen.de/code/max-objects/11ffload All ffmpeg dependencies are included for now.
    • Mar 15 2022 | 4:54 pm
      what happened to this external? can i test it ? ;)
    • Mar 15 2022 | 5:23 pm
      Hi Klaus, my plan was to put it back online when i managed to recompile for Apple Silicon.
    • Apr 26 2022 | 6:57 pm
      I think that external is really useful especially because it supports many codecs. I keep seeing posts from people who would like to load audio tracks from movie files. It can do that with no problem. But I'm struggling to create a Mac version which supports intel and arm64. I'm on intel Catalina and after installing ffmpeg with homebrew, I find the files that I need: libavcodec.dylib libavformat.dylib libavutil.dylib libswresample.dylib I can use install_name_tool to put these into the external after compiling. Now my idea is to get the arm64 versions of these files and maybe use lipo tool to join them together. But i can not even try without having access to these versions and homebrew doesn't let me install a package of another arch. Maybe someone using an apple silicon maschine can install ffmpeg and send files to me. Or someone has another idea. I'm trying to avoid having to universally compile ffmpeg myself it seems hard to find the files for arm64 online.
    • Apr 27 2022 | 2:51 pm
      Max ships with "Fat" versions of these libs, maybe you can make use of those?
    • Apr 27 2022 | 3:12 pm
      Nice idea! I'm gonna try it. Also I found something on stackoverflow how to install a second arm-homebrew and make it install arm bottles. I'll report back.
    • Apr 28 2022 | 2:34 pm
      Thanks again @Rob. Only thing i had to do was to install homebrew ffmpeg4 instead of 5 to have the correct header files. Would someone with an Apple Silicon machine be so kind as to confirm that it works before I make it an official download again?
    • Apr 28 2022 | 3:31 pm
      i get: 11ffload~: cannot be loaded due to system security policy i am not sure how to get around this. whith my externals i at least get a dialog about it.
    • Apr 28 2022 | 7:48 pm
      Hi Klaus, thanks for testing. Here is a second take on it. This time I had Xcode automatically copy the dylibs to the bundle. If this also doesn't work it's probably a signing problem. Can you try again, please?
    • Apr 28 2022 | 8:55 pm
      sorry, no good news. i still get this same error. even when running xattr -d com.apple.quarantine 11ffload~.mxo the error remains.
    • Apr 28 2022 | 8:58 pm
      with 11strokes eg. i get this dialog, which then solves the issue:
    • Apr 28 2022 | 9:00 pm
      hang on, i missed the NEW link...
    • Apr 28 2022 | 9:04 pm
      yes working now !! including the dialog from above.
    • Apr 28 2022 | 9:14 pm
      Cool. That makes me happy.
    • Apr 28 2022 | 9:25 pm
      The buffer~ size limit seems to be obsolete. I can load complete movie 5.1 audio stream into a buffer.
    • Apr 29 2022 | 8:21 pm
      I fixed another bug with some avi formats and have revived the download.
    • Jun 22 2022 | 6:40 pm
      I've invested a lot of time for another update. I hope it was worth it.
      • added importreplace, import and info messages
      • added resample, metadatadict and import-related attributes
      • added "channel route" argument for all messages
      • added ability to import from another buffer~
      • updated help patcher
      Since it has become quite complex now, I may have overlooked one or the other bug. Don't hesitate to contact me. DOWNLOAD HERE