• Stars
    star
    113
  • Rank 309,168 (Top 7 %)
  • Language
    Java
  • License
    GNU General Publi...
  • Created over 9 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Processing library that interfaces with ffmpeg to export video files

ℹ Notes:

Video Export for Processing

This library interfaces with FFmpeg and makes it easy to export video files out of Processing.

Example

import com.hamoid.*;

VideoExport videoExport;

void setup() {
  size(600, 600);
  videoExport = new VideoExport(this, "hello.mp4");
  videoExport.startMovie();
}
void draw() {
  background(#224488);
  rect(frameCount * frameCount % width, 0, 40, height);
  videoExport.saveFrame();
}
void keyPressed() {
  if (key == 'q') {
    videoExport.endMovie();
    exit();
  }
}

FFmpeg

You need to download and install FFmpeg on your system before you can use this library. Note that you might already have it installed! You can find out by typing ffmpeg or ffmpeg.exe in the terminal. If the program is not found:

For more details and download links, check the official FFmpeg website: http://ffmpeg.org

When you start a Processing sketch that uses this library you may be asked to indicate the location of your FFmpeg executable.

Frequent issues and questions

What if I change the location of FFmpeg?

The library should notice and ask you for its location again. The location information is saved in a json file which you can find in the library location. If you delete this json file the library will ask you for the location of FFmpeg and create the file again with the updated information.

Sometimes the resulting mp4 video files are not working. Why?

mp4 files contain essential metadata at the end of the file. The video export library saves this metadata when you call the endMovie() method. If you don't call it, the movie may be incomplete. The endMovie() method was added in version 0.1.5.

I see an FFmpeg error related to "crf". Why?

This happens if your copy of FFmpeg does not include the h264 encoder. Not all FFmpeg binaries are equal, some include more features than others. Try downloading a different or more recent binary. Let me know if that doesn't work.

Odd widths and heights not allowed

The exported video is compressed using the h264 codec. This codec does not allow odd image sizes like 111 x 113. Some computer screens actually have odd sizes like 1920 x 1059. If you use fullScreen() with such a screen, exporting will fail with an error like height not divisible by 2 (1920x1059). This will be fixed in future versions by auto correcting the requested size to an even number and notifying the user.

How can I tweak the FFmpeg command the library runs?

The first time the library runs it will produce a settings.json file, which will be placed in the library folder. This file can be carefully edited to adjust the FFmpeg parameters used during the video creation. Why would you do this? FFmpeg accepts hundreds of parametrs to define which codec to use, how the codec should behave, etc. FFmpeg also includes hundreds of audio and video filters that can be used and configured. It would not make sense for me to create hundreds of methods in the video export library to let you access all those features. If you are and advanced user, you can tweak those settings yourself by editing settings.json to change the codec settings or apply special effects to the resulting video files. See this example.

NoSuchMethodError when calling endMovie()

There seems to be a conflict between the Video Export library and the Video library. Both use different versions of the JNA library. See this discussion: #38

change log

  • 0.2.3 - February 28th, 2018
    • Allow spaces in the FFmpeg command (#37)
    • Allow setting the FFmpeg command settings from code, not just in the json file (#36)
  • 0.2.2 - February 11th, 2018
    • Re-add jna.jar and jna-platform.jar, fixing broken exported applications (issue 47 ) and the Windows version.
  • 0.2.1 - November 8th, 2017
  • 0.2.0 - October 22nd, 2017
    • Minor change: when calling nf(), replace ',' with '.'. Some systems may use ',' due to localization, which fails later when parsing the csv file.
  • 0.1.9 - April 22nd, 2017
    • https URL is now known by the IDE, so it's possible to install again without leaving the IDE.
    • Solve issue when attaching sound. In Ubuntu, the AAC codec inside FFmpeg is experimental, and had to be enabled in the command line.
    • Allow user customization of the FFmpeg commands that the library runs by including them inside settings.json, found in the library folder. This enables the user to tweak the commands to enable filters like blur, vignette, add noise, crop, etc. In future versions space characters should be allowed in those filter arguments.
  • 0.1.8 - April 17th, 2017
    • Switch server url to https (attempt to solve broken installation inside the IDE)
  • 0.1.7 - April 1st, 2017
    • Setting are now saved in the libray folder. Using the Java Preferences was giving errors on some Windows versions.
    • New example added to produce a video based on FFT data and making sure audio and video stay in sync.
    • In Windows, when ending a video, CTRL+C is sent to FFmpeg to terminate properly. This seems to fix corrupted videos on Windows.
    • The library now notices if FFmpeg is not found (maybe because it was moved) and asks again for its location.
  • 0.1.6 - December 8th, 2016
    • Fix for high dpi screens (Thanks to @LodenRietveld)
  • 0.1.5 - December 2nd, 2016
    • Refactoring. Clean up code.
    • Add .startMovie() and .endMovie() to prevent possible "missing-end-of-movie corruption".
    • Allow attaching a sound file to the produced movie.
    • Allow exporting multiple video files using the same videoExport object.
  • 0.1.4 - August 4th, 2016
    • Attempt to fix randomly corrupted videos on Windows
  • 0.1.3 - July 24th, 2016
    • Add webcam saving example.
    • Add getFfmpegPath() public method (requested by @ffd8).
    • Replace PGraphics with PImage, enables webcam/movie saving (requested by @transfluxus).
  • 0.1.1 - June 15th, 2016
    • Use .waitFor() to reduce chances of video corruption.
  • ...
  • 0.0.1 - January 25th, 2015

Download

http://funprogramming.org/VideoExport-for-Processing/

More Repositories

1

Fun-Programming

Code from the Fun Programming creative coding tutorials and my own random sketches
JavaScript
181
star
2

long-hugo-doc

The documentation of the Hugo static site generator in one long page. LOOKING FOR MAINTAINER. Look at forks for improvements.
Python
54
star
3

Joukkue

Collaborative creative coding
JavaScript
37
star
4

Processing-Workshop-Tool

Multiuser web application for Processing workshops
CoffeeScript
22
star
5

ableton-live-preset-report

A python script that prints out details from preset files
Python
6
star
6

workshop

Code from creative coding workshops
Processing
5
star
7

balconylab

Almost creative coding
Processing
4
star
8

TabletArduinoMidiProcessing

Processing program to perform visuals for a 3 minute song
Processing
3
star
9

UdK

Processing sketches - UdK course - Berlin
3
star
10

charlotte

Code for Thomas OReilly's 3 legged Arduino controlled robot
CMake
2
star
11

p5liveCoding

JavaScript code for live coding using the LightTable code editor
JavaScript
2
star
12

code-pong-1

Coding game. Two people. Processing. First try.
Processing
2
star
13

RemakeSession

Remaking early generative artworks in OPENRNDR
Kotlin
2
star
14

robogarden

Creative Code Jam project
Processing
1
star
15

tonegrid

Grid synth
JavaScript
1
star
16

idea-thumbnails

An WIP IntelliJ Idea plugin for showing thumbnails representing each OPENRNDR .kt file
Kotlin
1
star
17

TM-Spektrum-SCS-Perf-2016

Local multiuser web based application for musical performance
JavaScript
1
star
18

popcorn-decay

Code from Science Hack Day 2014 Berlin
Processing
1
star
19

FarbeShan

Processing Code Jam experiment
Processing
1
star
20

creative-creative-coding-exercises

Creative creative-coding exercises. Not only what you do, but how you do it.
1
star