Video export library 0.1.9

The latest version is at https://www.funprogramming.org/VideoExport-for-Processing/

For now it can only be installed manually, until the URL is used by the IDE library manager.

I fixed a small bug: in Ubuntu (maybe others) the examples with audio would fail, because the AAC audio codec is experimental. I added -strict -2 to the ffmpeg command to enable AAC.

And I added a geeky advanced "feature": the ffmpeg commands that the library executes can now be tweaked by the user (you). They are found in the settings.json file in the library folder after running the library once. What does this mean? Well, ffmpeg allows all kinds of crazy filters. If you tweak the command that gets executed by the library, you could apply blur, vignetting, color tints, adjust the contrast and brightness, fade your logo in and out on top of the video, etc. Warning: those commands are not so easy to get right. If it stops working just delete settings.json and it will be created again.

I'll post an example so you get an idea.

Comments

  • Two thumbs Up! I am looking fwd to trying them.

    Kf

  • Here my modified ffmpeg setting:

    "encode_video": "[ffmpeg] -y -f rawvideo -vcodec rawvideo -s [width]x[height] -pix_fmt rgb24 -r [fps] -i - -vf vignette,gblur=sigma=1,noise=alls=10:allf=t+u,drawtext=fontfile=/usr/share/fonts/TTF/OpenSans-SemiboldItalic.ttf:text='Made.With.Processing':x=50:y=(h-text_h-50):fontsize=24:fontcolor=white@0.8 -an -vcodec h264 -pix_fmt yuv420p -crf [crf] -metadata comment=[comment] [output]"

    Hidden in that monster, there's vignette, blur, noise, and some text written on top of the video. The syntax is very strict. Every character counts.

    This is what you see in Processing: 2017-04-22-192149_600x600_scrot

    And this is what you see in the video: vlcsnap-2017-04-22-19h21m13s584

    The noise is animated, which gives a bit of cinematic effect.

    When I have time I'll make an improvement, because currently you can't have any spaces in the string. That's why I wrote "made with Processing" with periods instead of spaces.

    I hope you get the idea.

    Here's the endless list of filters you could apply: https://ffmpeg.org/ffmpeg-filters.html#Video-Filters

  • @hamoid

    the ffmpeg commands that the library executes can now be tweaked by the user (you)

    This is extremely exciting. In addition to applying filters, I could imagine using ffmpeg capabilities such as (untested):

    1. compositing a sketch video side by side with a pre-existing video file
    2. appending each sketch run video to the end of a long running video file
    3. overlaying each sketch video recording on top of a video of previous recording(s).
  • I wonder... Would it be possible to "dynamically" change these settings right in the code?

  • Interesting ideas @jeremydouglass! I'm looking forward to see some results from the community :)

    And also interesting idea @Lord_of_the_Galaxy! That would be trivial to implement. I'll add an issue to GitHub and do that next weekend :)

  • Great! Looking forward to it.

  • edited April 2017

    Other ideas that might be applied:

    filter examples: https://trac.ffmpeg.org/wiki/FancyFilteringExamples

    glitch: https://github.com/ramiropolla/ffglitch/tree/master/pix_fmt

    datamosh: http://forum.glitchet.com/t/tutorial-make-video-glitch-art-how-to-datamosh-in-plain-english/36/1

    more glitches: https://tschoepler.net/2015/03/ffmpeg-glitches/

    cheatsheet for glitching: https://gist.github.com/NeuroWinter/e557bfc555118ed68df88e8e51f03177

    I haven't tested these. I don't know if it even makes sense. You could achieve similar results by using a shader... But I just let these here in case they are useful.

  • This is amazing, thanks so much.

  • edited May 2017

    Hello everybody and thanks a lot Hamoid for this very useful lib', which I really needed to sample video flows to my Millumin app, through Syphon. Thanks too to Jeremy who drived me on the forum to this work and that page.

    • Could someone indicate me the way to choose a better codec than mp4 ? (Pro Res, Hap, Photo Jpeg, H.264, Apple ProRes-4444 ...).

    • Silly writing question : how could I avoid a first unuseful "Camera" clip called in the setup by : videoExport = new VideoExport(this, "camera.mp4", camichel); ... when I further call in the draw : videoExport.setMovieFileName(frameCount + ".mp4"); ?

    • How to simply avoid a first black frame in each created clip ?

    Thank you for any answer !

  • You're welcome, Michel.

    1. mp4 is not a codec but a container. The library uses h264 by default. You could try a different codec by modifying the executed ffmpeg command in settings.json. Note the -vcodec h264 part. I don't know which codecs are available, please check the ffmpeg reference.

    2. You can do videoExport = new VideoExport(this);

    3. There should be no initial black frame. Is maybe the webcam not ready when trying to save the first frame? You could maybe ignore the first frame? Are you saving the frame first and then drawing on the screen?

    Cheers!

  • edited May 2017

    Thank you Hamoid for your answer.

    1. Of course mp4 is a container, this is a commun mistake we make :-/ ffmpeg is a little bit beyond my skills (better saying it’s a mess for me) … but I will so learn further. In case not, h264 should match.

    2. I think I must specify any 2nd argument to reach the 3rd one which is the variable of the choosen camera (otherwise a wrong camera will run). Anyway something magical happened : this works today perfectly fine (some fairy godmother ? maybe I am a sleepworker ?)

    3. This too works fine today (maybe my computer doesn’t like mondays ?) In case, yes, I will write a line to ignore the 1st frame.

    So begins my draw :

    void draw() {
      if (camichel.available()) {
        camichel.read();
      }
      background(bgcolor);
      // Here we don't save what we see on the display,
      // but the webcam input.
    if (recording) {
          text("Enregistrement en cours", 300, 300);
          videoExport.saveFrame();
      }
    }
    

    Thank you again !

  • edited December 2017

    How can we change the directory where the video is stored?

  • Maybe videoExport = new VideoExport(this, "/something/like/this.mp4"); ?

  • @nikos_nt is this in Windows, Linux or Mac? Let us know if hamoid suggestion works for you.

    Kf

  • @kfrajer @hamoid Yes! It does work, on Windows 7, 64-bit. Thank you!

  • This library seems just what I needed :) Any tips on how to generate a video with alpha channel? I have tried using a PGraphics buffer (JAVA2D) but the output still has a black background.

    Thank you :)

  • how to generate a video with alpha channel

    Please clarify. If I get to run this video on any system, what should the background be?

    Or do you want a transparent background so to merge it with another video?

    Kf

  • If it is for video editing purposes, could you export two videos? One color and one with the alpha channel? I have not yet worked with videos with transparency, but I assume it should be doable. So far the library streams RGB data into ffmpeg. If there is a setting to enable transparency, it might work to stream RGBA data into ffmpeg and produce a video with alpha. Anyone wants to try? :)

  • I did work in a project in which other people used videos with alpha, and it was quite tricky. If I remember right many video players and formats do not support the option.

  • I wonder... Would it be possible to "dynamically" change these settings right in the code?

    Version 0.2.3 is out. Now it's possible to adjust the ffmpeg settings from your sketch. But you have to be friends with ffmpeg :) Here an example with the same effect I posted above (vignetting, blur, noise and text).

    I also tested doing real time streaming from Processing to VLC. Not sure what that could be used for, but it seems to work :)

  • Not available as yet in the PDE's lib manager :-?? 8-X

    Looking fwd to it. Thxs!

    Kf

  • edited March 2018

    @kfrajer -- Video Export v0.2.3 is now available in PDE's Contribution Manager > Libraries.

  • Thank you for the update @jeremydouglass :)

  • Not yet on my side @jeremydouglass... I will learn to be patient and I will just wait. Thxs anyways...

    @hamoid Thxs for the update. Looking fwd to it.

    Kf

  • So weird. It went back to 0.2.2! :)

    Using wireshark I discovered that this is the URL where it checks for library versions: http://download.processing.org/contribs . It was showing 0.2.3 yesterday, 0.2.2 today.

  • Maybe report it to the devs on github issues? That is indeed the library list -- if that file was reverted it might have been a mistake.

Sign In or Register to comment.