Processing Video With A GLSL Shader And Saving The Video

edited January 2017 in GLSL / Shaders

How do you do the following with Processing?

  1. Load a video file.
  2. Apply a GLSL Shader to each frame.
  3. Save the processed video as a new file, complete with audio track?

Is Processing suitable for this? Can GLSL in processing use GPU acceleration?

Can anybody point me to an example project where video is loaded, GLSL processed and saved again?

Thanks!

Answers

  • Answer ✓

    i think you'll struggle to do it in realtime, because getting data back from the video card is slow. and saving it is also slow.

    but you can do it in non-realtime easily enough - just save the processed frames as numbered files and combine them (and the audio) using one of the external methods (ffmpeg for example)

    any of the video examples will show you how to read the file. use image() to process it. saveFrame() to save it.

    (i also think the 'shaders' part of this q is a bit spurious, it's the least important part.)

  • A quick question - do the GLSL shaders take effect each time something is draw to the canvas, or only at the end of draw()?

  • I have written 4 HLSL pixel shaders totalling about 2000 lines of code that run in realtime on GPU inside media players like MPC and Potplayer.

    But these media players cannot save out a video file.

    So I thought:

    1. Port the HLSL pixel shaders to GLSL
    2. Use Processing to load video file, apply GLSL pixel shaders, save new video file

    Realtime performance would be nice, but is not crucial in this case.

    I have never programmed touched Processing before, so I wanted to know whether this is easy or hard.

    Also, can Processing create a standalone executable if I manage to get this working?

    Could I give someone else a small video processing application written in Processing that they can then run like a standard Windows GUI app?

    Again, I'm totally new to Processing, so pardon my ignorance.

    It is the ability to use GLSL shaders in Processing that attracted my attention.

  • There's an Expert Application menu option that will produce an executable but typically you'll have to bundle a directory into a zip file to include extras like your shader code files or any images.

  • @koogs that depends on the answer to my earlier question (this post).

Sign In or Register to comment.