# Can I Use Processing to Make An MP4?

**URL:** <https://discourse.processing.org/t/can-i-use-processing-to-make-an-mp4/28788>\
**Category:** Processing.py\
**Created:** [March 24, 2021, 3:19am UTC](https://discourse.processing.org/t/can-i-use-processing-to-make-an-mp4/28788 "2021-03-24T03:19:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![PatrickPowers](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@PatrickPowers](https://discourse.processing.org/u/PatrickPowers)\
**Post date:** [March 24, 2021, 3:19am UTC](https://discourse.processing.org/t/can-i-use-processing-to-make-an-mp4/28788/1 "2021-03-24T03:19:53Z")

</div>

I have a program written in Python geometric algebra that produces animations as mp4s. It is quite crude and I’m looking for something better. The requirements are:

Geometric algebra  
Ability to draw ellipses.  
Can produce standard MP4s.

I’ll translate from Python to some other language if I must.

---

<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:** [March 24, 2021, 3:36am UTC](https://discourse.processing.org/t/can-i-use-processing-to-make-an-mp4/28788/2 "2021-03-24T03:36:38Z")

</div>

Welcome @PatrickPowers

You can do this with Processing’s [Python mode](https://py.processing.org) –

- for geometric algebra, there’s the [PVector](https://py.processing.org/reference/PVector.html) class;
- for ellipses, there’s the [ellipse()](https://py.processing.org/reference/ellipse.html) function;
- for MP4s, I’d probably just use the [saveFrame()](https://py.processing.org/reference/saveFrame.html) function to generate an image of each frame, then combine them into a video (using FFmpeg or some video editing software).

Your Python script may require some adaption; you’re using the Processing environment, possibly the PVector class, and Processing’s Python mode has some differences (it’s using Jython).

[p5 for Python](https://github.com/p5py/p5) is another (pure Python) option.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [March 24, 2021, 6:56am UTC](https://discourse.processing.org/t/can-i-use-processing-to-make-an-mp4/28788/3 "2021-03-24T06:56:12Z")

</div>

> [@tabreturn](#):
>
> using FFmpeg or some video editing software

There is even one in the menu tools for movie making

---

<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:** [March 24, 2021, 11:17am UTC](https://discourse.processing.org/t/can-i-use-processing-to-make-an-mp4/28788/4 "2021-03-24T11:17:27Z")

</div>

Also relying on ffmpeg there is Hamoid’s VideoExport library you can install from the IDE

```python
add_library('VideoExport')
recording = False

def setup():
    global video_export
    size(600, 600)
    noStroke()
    frameRate(30)

    println(u"Press 'r' to start recording")
    println(u"Press 'q' to quit and close recording file")

    video_export = VideoExport(this, "animation.mp4")
    video_export.setFrameRate(30) # optional (reduce frame rate)
    frameRate(30)
    # Quality: 100. Audio very good: 256 / good: 192
    video_export.setQuality(70, 128) # default de video & audio
    video_export.startMovie()

def draw():
    background(0)
    t = frameCount * 0.03
    sz = 100 + 50 * cos(t * 1.33) * cos(t * 1.84)
    ellipse(300 + 200 * cos(t * 1.13) * cos(t * 0.21),
            300 + 200 * cos(t * 1.71) * cos(t * 0.47),
            sz, sz)
    if recording:
        video_export.saveFrame()

def keyPressed():
    global recording
    if key == 'r' or key == 'R':
        recording = not recording
        println(u"Recording is {}".format(
            "ON" if video_export else "OFF"))

    if key == 'q' or key == 'Q':
        video_export.endMovie()
        exit()

```
