Git Product home page Git Product logo

Comments (30)

minikomi avatar minikomi commented on June 26, 2024 4

There's a much easier way to do this for people who want to get started without having to patch quil:

  • Download processing, and move Processing.app/Contents/Java/modes/java/libraries/video/library/ into your project.
  • Add the following resource paths into your project.clj:
  :resource-paths [
                   "library/jna.jar"
                   "library/video.jar"
                   "library/gstreamer-java.jar"
                   "library/gstreamer/macosx64"
                   ]
  • You can now use code like the following:
(ns videotest.core
  (:require [quil.core :as q]
            [quil.middleware :as m]
            )
  (:import [processing.video Movie]))

(defn setup []
  (let [mov (Movie. (quil.applet/current-applet) "resources/720.mp4")]
    (.play mov)
    (.loop mov)
    {:movie mov
     :current-frame 0}))

(defn update-state [state]
  (when (and (not (nil? (:movie state)))
                (.available (:movie state)))
    (.read (:movie state)))
  state)

(defn draw-state [state]
  (q/background 240)
  (q/image (:movie state) 0 0))

(q/defsketch videotest
  :size [1280 720]
  :setup setup
  :update update-state
  :draw draw-state
  :features [:keep-on-top]
  :middleware [m/fun-mode])

Note the use of (.available (:movie state)) to see if it's safe to read a new frame.

from quil.

minikomi avatar minikomi commented on June 26, 2024 4

The easiest way I found was to download processing, start a new sketch, select add library from the sketch menu and then do a search for video. The one you want is the gstreamer libary called "video". Now, in your Documents folder should be a Processing/libraries folder with the video plugin there.

from quil.

Norgat avatar Norgat commented on June 26, 2024 2

Little trick.

:resource-paths [
                   "library/jna.jar"
                   "library/video.jar"
                   "library/gstreamer-java.jar"
                   "library/gstreamer/macosx64"
                   ]

You can use this plugin for adding (and more other things) jars to local maven repo: https://github.com/kumarshantanu/lein-localrepo

from quil.

hamoid avatar hamoid commented on June 26, 2024 1

@bmaddy In Processing, go to Preferences and note your sketchbook folder. I think you should find the files you are looking for inside [sketchbook folder]/libraries/video/library

from quil.

nbeloglazov avatar nbeloglazov commented on June 26, 2024 1

Going to close this bug. There is a FAQ entry to using processing plugins with Quil: https://github.com/quil/quil/wiki/FAQ#how-to-use-processing-plugin and according @minikomi that will work.

from quil.

nbeloglazov avatar nbeloglazov commented on June 26, 2024

I haven't worked with processing.video but still can try to help. Is there any particular problems you're facing?

from quil.

phiat avatar phiat commented on June 26, 2024

Ah thanks for the reply - but I actually got it working! I will post a repo with an example in a bit. I thought I had to use a 'newer' quil (but that one had a few other dependencies that didn't work on my machine - namely glue-rt )... I'll post a link here. Can't wait to do some clojure + video + 3d work!

from quil.

phiat avatar phiat commented on June 26, 2024

I jumped the gun... Still too many errors. How would I go about bringing in this video library to work with quil?

from quil.

nbeloglazov avatar nbeloglazov commented on June 26, 2024

Hi Patrick
Are you still up to this task? I can help you if you want.

from quil.

tangrammer avatar tangrammer commented on June 26, 2024

Hi Nikita,
I've been struggling with this video integration too.
My last solution was work with quil-processing2 and extend quil/applet.clj
to integrate the movieEvent register methods into the defsketch macro
definition. And still i have to declare my video library resources in
project.clj as resource-paths

2014-04-09 23:10 GMT+02:00 Nikita Beloglazov [email protected]:

Hi Patrick
Are you still up to this task? I can help you if you want.

Reply to this email directly or view it on GitHubhttps://github.com//issues/75#issuecomment-40016937
.

from quil.

phiat avatar phiat commented on June 26, 2024

Hi Nikita,
I haven't attempted looking at it in a few months, but would love to get this going! I'll get back to you soon after I get refreshed with it.

Patrick

On Apr 9, 2014, at 5:11 PM, Nikita Beloglazov [email protected] wrote:

Hi Patrick
Are you still up to this task? I can help you if you want.


Reply to this email directly or view it on GitHub.

from quil.

nbeloglazov avatar nbeloglazov commented on June 26, 2024

@tangrammer, @phiat can you give link to any working example, no matter how hacky and ugly it looks like?

from quil.

tangrammer avatar tangrammer commented on June 26, 2024

@nbeloglazov here https://gist.github.com/tangrammer/10405691 you can see my
changes on quil2.0 to extend video support
I've only added the functions modified

and here https://dl.dropboxusercontent.com/u/8688858/lib.zip the libs you
need as :resource-paths (until we can pack the video deps as clojar lib)

The same issue I've done to extend quil for using oscp5 lib

Thanks!

2014-04-10 18:04 GMT+02:00 Nikita Beloglazov [email protected]:

@tangrammer https://github.com/tangrammer, @phiathttps://github.com/phiatcan you give link to any working example, no matter how hacky and ugly it
looks like?

Reply to this email directly or view it on GitHubhttps://github.com//issues/75#issuecomment-40104412
.

from quil.

nbeloglazov avatar nbeloglazov commented on June 26, 2024

As I see, the main problem here is this native libs that need to added to resources folder. But we want to pack them into jars so they can be easily included in project.clj...
@tangrammer, did you try to pack all this lib/macosx64 resources into a jar, install it into local lein repo and include it as dependency?
I suppose it should be possible to do something like this. Though I'm not sure how. Could you check it, if you have time for it?

from quil.

tangrammer avatar tangrammer commented on June 26, 2024

@nbeloglazov , Ok, I'll give a try to
this "did you try to pack all this lib/macosx64 resources into a jar,
install it into local lein repo and include it as dependency?"

2014-04-11 0:58 GMT+02:00 Nikita Beloglazov [email protected]:

As I see, the main problem here is this native libs that need to added to
resources folder. But we want to pack them into jars so they can be easily
included in project.clj...
@tangrammer https://github.com/tangrammer, did you try to pack all this
lib/macosx64 resources into a jar, install it into local lein repo and
include it as dependency?
I suppose it should be possible to do something like this. Though I'm not
sure how. Could you check it, if you have time for it?

Reply to this email directly or view it on GitHubhttps://github.com//issues/75#issuecomment-40152773
.

from quil.

tangrammer avatar tangrammer commented on June 26, 2024

@nbeloglazov I already have the macosx64 dir resources packaged into a jar in my maven local repo and using it from project.clj [quil-video/macosx64 "1"]

the lib https://dl.dropboxusercontent.com/u/8688858/macosx64-1.jar

from quil.

nbeloglazov avatar nbeloglazov commented on June 26, 2024

Cool. So it does work from jar, right?

from quil.

tangrammer avatar tangrammer commented on June 26, 2024

yes it does

2014-04-11 13:14 GMT+02:00 Nikita Beloglazov [email protected]:

Cool. So it does work from jar, right?

Reply to this email directly or view it on GitHubhttps://github.com//issues/75#issuecomment-40193181
.

from quil.

tangrammer avatar tangrammer commented on June 26, 2024

@nbeloglazov following the same way i have all the necessaries libs in my local maven repo and now my project dependencies are these

(defproject dat00 "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [quil/quil "2.0.1-SNAPSHOT"]
                 [org.clojure/data.json "0.2.4"]
                 [quil-video/macosx64 "1"]
                 [quil-video/jna "1"]
                 [quil-video/video "1"]
                 [quil-video/gstreamer-java "1"]
                 ]
  )

But i suspect there is a better way to group all these quil-video resources in one line, dont you think the same?

And I still have a question about the better way to extend quil applet.
It seems that with each library (video, oscp5 ...) that uses the event listener approach we have to modify the applet.clj file and include this library as dependency on parent project.

(gen-interface
 :name quil.MovieI
 :methods [
           [movieEvent
            [processing.video.Movie] Object]
           ])
(gen-interface
 :name quil.OscP5
 :methods [
           [oscEvent
            [oscP5.OscMessage] Object]
           ])
(gen-class
  :name "quil.Applet"
  :implements [clojure.lang.IMeta quil.MovieI quil.OscP5]
  :extends processing.core.PApplet
  ;:methods [[movieEvent [processing.video.Movie] Object]]

Do you know a better approach to achieve this?

from quil.

tangrammer avatar tangrammer commented on June 26, 2024

Hi @nbeloglazov again!
It seems that I've found another way (maybe better) to extend "quil.Applet" without modifying the base file applet.clj. As you can see in the code attached the new solution uses proxy to extend the processing.core.PApplet class

what does it sounds?

thanks!

(ns dat00.juan
  (:import (processing.video Movie))
  (:use quil.core
        [quil.helpers.drawing :only [line-join-points]]
        [quil.helpers.seqs :only [range-incl steps]]))
(declare mov)

(defn setup[]
  (println "setup completed!")
)

(defn draw []
  (image mov 0 0 ))

(defsketch juan
    :setup setup
    :draw draw
    :size [500 500]
    )

(gen-interface
 :name quil.MovieI
 :methods [
           [movieEvent
            [processing.video.Movie] Object]
           ])

(def other (proxy [processing.core.PApplet quil.MovieI] []
             (dataPath [filename]
               (println filename)
               (.dataPath juan filename))
             (registerDispose [o]
               (println "register dispose " o )
               (.registerDispose juan o))
             (registerMethod [o #^Movie m]
               (println "register method " o m)
               (.registerMethod juan o m))
             (unregisterMethod [o #^Movie m]
               (println "unregister method " o m)
               (.unregisterMethod juan o m))
             (die [m]
               (.die juan m))
             (movieEvent [#^Movie movie]
                 (.read movie))
             (dispose []
               (.dispose juan))
             ))
(set! (.-g other) (.-g juan))

(def mov (Movie. other "data/transit.mov"))
(.play mov)

from quil.

tangrammer avatar tangrammer commented on June 26, 2024

updated defsketch definition

(defsketch juan
    :setup setup
    :draw draw
    :size [500 500])

without :movie-event

from quil.

tangrammer avatar tangrammer commented on June 26, 2024

@nbeloglazov bad news! The resources "macosx64" or video libraries were not actually working

My example project was using the resources of quil parent project through checkouts simlink, and in this parent project there was the resources attached :(

But, the way for extending video support with proxy is working anyway :)

I'll try to get deeper on package clojure resources

from quil.

nbeloglazov avatar nbeloglazov commented on June 26, 2024

Few other points:

  1. I saw you created IMovie interface and quil.Applet implemented it. Why not just add movieEvent directly to quil.Applet?
  2. Once we figure out how to pack native libs into jars so they work, we could use other libs jna.jar and gstreamer-java.jar from maven. I hope jar available on maven has same version which is used by Processing.
  3. The only thing left is video.jar. I think we can uppload video.jar along with video-native.jar to clojars under quil group.

from quil.

jackrusher avatar jackrusher commented on June 26, 2024

I've just started looking at this same problem. Any progress since April?

from quil.

nbeloglazov avatar nbeloglazov commented on June 26, 2024

I haven't worked on it since then. Would be happy if someone continued working on it. I can help with native resources if needed, as I had fun while preparing opengl deps for Quil so my experience might be useful.

from quil.

ahdinosaur avatar ahdinosaur commented on June 26, 2024

i'm interested in using processing.video within quil, what can i do to help push this along?

from quil.

nbeloglazov avatar nbeloglazov commented on June 26, 2024

Michael, I'd suggest to try and make it work for you setup using whatever hacks you might need and then we can have a look and see how to make it general and compatible. I you already have a setup which does it - please post a link here.

from quil.

bmaddy avatar bmaddy commented on June 26, 2024

I'm also trying to get this to work.
Those .jar files from @minikomi's comment seem to not exist in Processing.app/Contents/Java/modes/java/libraries/video/library/ anymore. Does anyone know where I could find them? I installed the Video library in the Processing.app gui and thought that would make them appear.

from quil.

tripaces avatar tripaces commented on June 26, 2024

Pulling together several elements from this thread and others, I put together a sketch using a webcam and Raspberry Pi 2 using the newer Processing video libraries (as pointed out by @hamoid).

That sketch, which is inspired by one of the Processing Video Capture examples is at https://github.com/LifeInLights/twyla-opus/blob/master/spectacles/src/spectacles/mirror_camera.clj and is quite reliable.

The associated project (https://github.com/LifeInLights/twyla-opus/blob/master/spectacles/project.clj) indicates how to reference the necessary jars. Since the time of writing, it is possible that those libraries may have been made available in a public repo, but at the time they had to be directly embedded for reliable availability (https://github.com/LifeInLights/twyla-opus/tree/master/spectacles/resources/processing-video).

from quil.

nbeloglazov avatar nbeloglazov commented on June 26, 2024

Took a look at processing.video. I think a jar to clojars is pretty straightforward. The hard part is how to serve libraries (non-java libraries). In my Processing/libraries/video folder I see 97mb of libraries for Windows and MacOS. Uploading them to clojars doesn't seem like a good solution. Ideally there should be something like a script that downloads them to your computer when you "enable" video for quil. If lein had something like post-dependency-included-hook that would do it. But I don't know how to do it.

from quil.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.