# How to display video in PythonMode?

**URL:** <https://discourse.processing.org/t/how-to-display-video-in-pythonmode/485>\
**Category:** Processing.py\
**Created:** [May 29, 2018, 5:54am UTC](https://discourse.processing.org/t/how-to-display-video-in-pythonmode/485 "2018-05-29T05:54:44Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![newton45](https://avatars.discourse-cdn.com/v4/letter/n/ebca7d/32.png) [@newton45](https://discourse.processing.org/u/newton45)\
**Post date:** [May 29, 2018, 5:54am UTC](https://discourse.processing.org/t/how-to-display-video-in-pythonmode/485/1 "2018-05-29T05:54:44Z")

</div>

```auto
add_library('video')

def setup():
    size(640, 360)
    background(0)
    
    movie = Movie(this, "transit.mov")
    movie.loop()
    
def movieEvent(m):
    m.read()
    
def draw():
    image(movie, 0,0,width,height)

```

Error says “processing.app.SketchException: java.lang.RuntimeException: Could not load movie file transit.mov”

How to show video correctly?

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [May 29, 2018, 7:55am UTC](https://discourse.processing.org/t/how-to-display-video-in-pythonmode/485/2 "2018-05-29T07:55:26Z")

</div>

Just dbl checking: your movie is in the data folder?

Kf

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [May 29, 2018, 8:15am UTC](https://discourse.processing.org/t/how-to-display-video-in-pythonmode/485/3 "2018-05-29T08:15:33Z")

</div>

> <https://github.com/jdf/Processing.py-Bugs/issues/229>

---

<div class="post-metadata">

**Author:** ![newton45](https://avatars.discourse-cdn.com/v4/letter/n/ebca7d/32.png) [@newton45](https://discourse.processing.org/u/newton45)\
**Post date:** [May 29, 2018, 10:47am UTC](https://discourse.processing.org/t/how-to-display-video-in-pythonmode/485/4 "2018-05-29T10:47:12Z")

</div>

Yeah, it’s under the data folder.

---

<div class="post-metadata">

**Author:** ![newton45](https://avatars.discourse-cdn.com/v4/letter/n/ebca7d/32.png) [@newton45](https://discourse.processing.org/u/newton45)\
**Post date:** [May 29, 2018, 10:51am UTC](https://discourse.processing.org/t/how-to-display-video-in-pythonmode/485/5 "2018-05-29T10:51:00Z")

</div>

I thought maybe it was a BUG so I raise it to github

---

<div class="post-metadata">

**Author:** ![WakeMeAtThree](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/wakemeatthree/32/38_2.png) [@WakeMeAtThree](https://discourse.processing.org/u/WakeMeAtThree)\
**Post date:** [May 29, 2018, 1:40pm UTC](https://discourse.processing.org/t/how-to-display-video-in-pythonmode/485/6 "2018-05-29T13:40:09Z")

</div>

Make sure `movie` is a global variable and you’re in python mode. 😉

```python
add_library('video')

def setup():
    size(640, 360)
    background(0)

    global movie
    movie = Movie(this, "transit.mov")
    movie.loop()
    
def movieEvent(m):
    m.read()
    
def draw():
    image(movie, 0,0,width,height)

```

---

<div class="post-metadata">

**Author:** ![newton45](https://avatars.discourse-cdn.com/v4/letter/n/ebca7d/32.png) [@newton45](https://discourse.processing.org/u/newton45)\
**Post date:** [May 30, 2018, 3:07am UTC](https://discourse.processing.org/t/how-to-display-video-in-pythonmode/485/7 "2018-05-30T03:07:34Z")

</div>

That’s it!!! Thank you WakeMeAtThree, that really helps me a lot 😉

---

<div class="post-metadata">

**Author:** ![eefneef](https://avatars.discourse-cdn.com/v4/letter/e/82dd89/32.png) [@eefneef](https://discourse.processing.org/u/eefneef)\
**Post date:** [November 29, 2021, 12:39pm UTC](https://discourse.processing.org/t/how-to-display-video-in-pythonmode/485/8 "2021-11-29T12:39:14Z")

</div>

Hi,

I tried the code WakeMeAtThree posted with my own video file which I added in the data folder. In processing I get the error:

ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader ‘bootstrap’)  
at jycessing.LibraryImporter.addJarToClassLoader(Unknown Source)  
at jycessing.LibraryImporter.recursivelyAddJarsToClasspath(Unknown Source)  
at jycessing.LibraryImporter.addLibrary(Unknown Source)  
at jycessing.LibraryImporter$1. **call** (Unknown Source)  
at org.python.core.PyObject. **call** (PyObject.java:480)  
at org.python.core.PyObject. **call** (PyObject.java:484)  
at org.python.pycode.\_pyx95.f$0(Test.pyde:1)  
at org.python.pycode.\_pyx95.call\_function(Test.pyde)  
at org.python.core.PyTableCode.call(PyTableCode.java:171)  
at org.python.core.PyCode.call(PyCode.java:18)  
at org.python.core.Py.runCode(Py.java:1614)  
at org.python.core.Py.exec(Py.java:1658)  
at org.python.pycode.\_pyx94.f$0(/var/folders/13/yzsw53f93c3dd8q0x\_kw33c40000gn/T/Test12641138659274035512/Test.pyde:96)  
at org.python.pycode.\_pyx94.call\_function(/var/folders/13/yzsw53f93c3dd8q0x\_kw33c40000gn/T/Test12641138659274035512/Test.pyde)  
at org.python.core.PyTableCode.call(PyTableCode.java:171)  
at org.python.core.PyCode.call(PyCode.java:18)  
at org.python.core.Py.runCode(Py.java:1614)  
at org.python.core.Py.exec(Py.java:1658)  
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:276)  
at jycessing.PAppletJythonDriver.processSketch(Unknown Source)  
at jycessing.PAppletJythonDriver.findSketchMethods(Unknown Source)  
at jycessing.Runner.runSketchBlocking(Unknown Source)  
at jycessing.mode.run.SketchRunner.lambda$startSketch$3(Unknown Source)  
at java.base/java.lang.Thread.run(Thread.java:829)

When I run this script in the terminal I get the error:  
Exception: This sketch requires the “video” library. at 0:0 in Test.pyde

Does anyone know what I’m doing wrong?

---

<div class="post-metadata">

**Author:** ![tabreturn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tabreturn/32/3697_2.png) [@tabreturn](https://discourse.processing.org/u/tabreturn)\
**Post date:** [November 29, 2021, 8:04pm UTC](https://discourse.processing.org/t/how-to-display-video-in-pythonmode/485/9 "2021-11-29T20:04:30Z")

</div>

Welcome @eefneef. Did you install the Video library? (Sketch \> Import Library \> Add Library)

---

<div class="post-metadata">

**Author:** ![eefneef](https://avatars.discourse-cdn.com/v4/letter/e/82dd89/32.png) [@eefneef](https://discourse.processing.org/u/eefneef)\
**Post date:** [November 29, 2021, 8:17pm UTC](https://discourse.processing.org/t/how-to-display-video-in-pythonmode/485/10 "2021-11-29T20:17:33Z")

</div>

Thanks for your answer! Yes I did and also downloaded the library and manually added it to a subdirectory named libraries in my projectfolder just in case (as stated in these docs: [Processing.py on the command line \ Tutorials](https://py.processing.org/tutorials/command-line/)).  
The Java version works just fine by the way, also tested that out.

---

<div class="post-metadata">

**Author:** ![liun](https://avatars.discourse-cdn.com/v4/letter/l/e19b73/32.png) [@liun](https://discourse.processing.org/u/liun)\
**Post date:** [February 13, 2022, 6:47pm UTC](https://discourse.processing.org/t/how-to-display-video-in-pythonmode/485/11 "2022-02-13T18:47:36Z")

</div>

Hi,

I get a similar error as eefneef when trying to run the code from WakeMeAtThree even though I installed and added the library.  
Also when I try to add libraries in other projects in python mode I get the same error:

java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader ‘bootstrap’)  
at jycessing.LibraryImporter.addJarToClassLoader(LibraryImporter.java:315)  
at jycessing.LibraryImporter.recursivelyAddJarsToClasspath(LibraryImporter.java:164)  
at jycessing.LibraryImporter.addLibrary(LibraryImporter.java:140)  
at jycessing.LibraryImporter$1. **call** (LibraryImporter.java:82)  
at org.python.core.PyObject. **call** (PyObject.java:480)  
at org.python.core.PyObject. **call** (PyObject.java:484)  
at org.python.pycode.\_pyx35.f$0(sketch\_220213b.pyde:1)  
at org.python.pycode.\_pyx35.call\_function(sketch\_220213b.pyde)  
at org.python.core.PyTableCode.call(PyTableCode.java:171)  
at org.python.core.PyCode.call(PyCode.java:18)  
at org.python.core.Py.runCode(Py.java:1614)  
at org.python.core.Py.exec(Py.java:1658)  
at org.python.pycode.\_pyx34.f$0(/Users/leonwoltermann/Documents/Processing/Projects/5/2/sketch\_220213b/sketch\_220213b.pyde:96)  
at org.python.pycode.\_pyx34.call\_function(/Users/leonwoltermann/Documents/Processing/Projects/5/2/sketch\_220213b/sketch\_220213b.pyde)  
at org.python.core.PyTableCode.call(PyTableCode.java:171)  
at org.python.core.PyCode.call(PyCode.java:18)  
at org.python.core.Py.runCode(Py.java:1614)  
at org.python.core.Py.exec(Py.java:1658)  
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:276)  
at jycessing.PAppletJythonDriver.processSketch(PAppletJythonDriver.java:233)  
at jycessing.PAppletJythonDriver.findSketchMethods(PAppletJythonDriver.java:613)  
at jycessing.Runner.runSketchBlocking(Runner.java:399)  
at jycessing.mode.run.SketchRunner.lambda$2(SketchRunner.java:112)  
at java.base/java.lang.Thread.run(Thread.java:829)

Can somebody help me?

---

<div class="post-metadata">

**Author:** ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)\
**Post date:** [February 28, 2022, 9:06pm UTC](https://discourse.processing.org/t/how-to-display-video-in-pythonmode/485/12 "2022-02-28T21:06:27Z")

</div>

Python mode from the command line has not been actively maintained for some time now, unfortunately.  
Have you tried to use the video library from the Processing IDE?

---

<div class="post-metadata">

**Author:** ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)\
**Post date:** [February 28, 2022, 9:09pm UTC](https://discourse.processing.org/t/how-to-display-video-in-pythonmode/485/13 "2022-02-28T21:09:20Z")

</div>

Are you using Processing 3.5.4?

Processing 4.0 betas and Python mode are still a bit rough.

There are also some issues on loading Python mode libraries in different platforms (I had trouble with Serial and Video on Windows and Mac a few years ago) ☹
