Fork me on GitHub

Here is a simple video encoding library for Clojure: I wrote this as an example of how simple interfacing with C systems can be and to show how nice using the deps.edn pathway is for a clojure library. It sits directly on top of the libavcodec series of shared libraries used by ffmpeg - it loads them dynamically and then you pass frames directly to the library. I have included a simple example of using Skija to render to a native buffer that is then passed directly into the encode-frame! method. Use this if you have a need to render videos of your crazy Clojure pixel art 🙂.

🎉 18
📹 2
👏 1

This is really neat! Would it be possible to make a simple video player using avclj?


Yes it would be possible. The decode pathways in my opinion are much harder than the encode pathways but all the necessary pieces are there. I could provide a function that gives you a sequence of close-able buffer objects or something that had each frame's information such as the image, the microsecond time and duration. The waters are fairly deep with FFmpeg; the encoder took a lot of head scratching before it produced videos that worked on cellphones.


FFmpeg is such a useful library, it's something I've been meaning to dive into myself. I'm familiar with jna and it would probably be good for me to also learn from how you've been using jna based off your excellent work with libpython-clj. I'll check it out and see how it goes.


wow, I did not know about this trick, Very cool. I've been using python-clang to try to get struct info.


🤯 , this stuff is awesome, Is the ffi stuff graalvm compatible?


Not at this time. I am working on it right now. It is JNA and JDK-16 compatible.


Well, either way, there's some really great c interop code here and I look forward to simplifying some of my c interop code in the future. Thanks! :thumbsup:


You are so welcome! I will post of course when I get a graal native pathway working. The target is some clojure code along with some python stuff all wrapped up into a graal native shared library that is then loaded via cython.

metal 1

Eventually, I'd like to be able to spit out apps a shared library that can be loaded and ran on mobile using a prebuilt iOS/android app

metal 2

Dear friends, a new much improved version of BinF, a Clojure/script library for handling any kind of binary formats /protocols in a simple yet powerful way. I've used it with great success for things like MIDI processing and a WebAssembly decompiler. I find it really capable, flexible, and feature-rich. It provides probably more than you need. Hope it will sprout new super use cases:

👍 3
catjam 2

Nice. I have a Node-hosted sysex librarian to finish. This could well be useful.


This looks great! I also nominate your READMEs description of your support for 64-bit integers for the "README Hall of Fame":

It is not the most beautiful experience one will encounter in the course of a lifetime but it works and does the job pretty efficiently.


Then I shall accept the honor!


The award will, of course, be in binary.

😁 3
🔟 2