We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
I created this library to export video directly from Processing.
http://funprogramming.org/VideoExport-for-Processing/
Does it look alright? First time I try publishing a library.
Now that I think about it... I could easily add the option to add sound to the produced movie. Ok, next version :)
Comments
hello Hamoid, I tried your library today and after a lot of trouble installing ffmpeg. I produced my first video, your basic example. The video is created, but the mediaplayer does not recognize the codex. I'm using a windows 64-bits computer. Can you give me a hint, how I can solve this problem?
gr. Ria
Hi! I haven't used Windows in a very long time, but as I remember the media player always had trouble playing lots of formats.
I recommend VLC https://www.videolan.org/ which plays hundreds of video formats, is open source and works in Windows, Linux and Mac.
If you want to still use mediaplayer, I think there's a way to install codecs, but someone more experienced with Windows should explain how that works. Maybe this helps: https://answers.microsoft.com/en-us/windows/forum/windows_vista-pictures/playing-mp4-in-windows-media-player-11/4251e823-32b5-4aee-be64-1f57a62f16d5
BTW. Can you describe the trouble installing ffmpeg? Then I could share the instructions with others :)
I installed VLC but no result, only a black screen.
Trouble installing ffmpeg: At the end I downloaded an build from ffmpeg.zeranoe.com. After a zip download. you can click a batch file, wich creates the ffmpeg.exe
hamoid,
this is the result txt file:
ffmpeg version N-72598-gaede1a1 Copyright (c) 2000-2015 the FFmpeg developers built with gcc 4.9.2 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmfx --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib libavutil 54. 26.101 / 54. 26.101 libavcodec 56. 41.101 / 56. 41.101 libavformat 56. 34.100 / 56. 34.100 libavdevice 56. 4.100 / 56. 4.100 libavfilter 5. 16.101 / 5. 16.101 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 1.100 / 1. 1.100 libpostproc 53. 3.100 / 53. 3.100 Input #0, rawvideo, from 'pipe:': Duration: N/A, start: 0.000000, bitrate: 259200 kb/s Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 600x600, 259200 kb/s, 30 tbr, 30 tbn, 30 tbc No pixel format specified, yuv444p for H.264 encoding chosen. Use -pix_fmt yuv420p for compatibility with outdated media players. [libx264 @ 000000000303cd80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX [libx264 @ 000000000303cd80] profile High 4:4:4 Predictive, level 3.1, 4:4:4 8-bit [libx264 @ 000000000303cd80] 264 - core 146 r2538 121396c - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=15.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00 Output #0, mp4, to 'C:\Users\RIia\Mijn Projecten\processing-3.0a5\modes\java\libraries\VideoExport\examples\basic\basic.mp4': Metadata: comment : Exported using VideoExport for Processing - https://github.com/hamoid/VideoExport-for-Processing encoder : Lavf56.34.100 Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv444p, 600x600, q=-1--1, 30 fps, 15360 tbn, 30 tbc Metadata: encoder : Lavc56.41.101 libx264 Stream mapping: Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264)) [swscaler @ 000000000301b120] Warning: data is not aligned! This can lead to a speedloss frame= 33 fps=0.0 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A
frame= 64 fps= 62 q=21.0 size= 2kB time=00:00:00.20 bitrate= 67.6kbits/s
frame= 95 fps= 62 q=21.0 size= 7kB time=00:00:01.23 bitrate= 44.4kbits/s
frame= 125 fps= 61 q=21.0 size= 12kB time=00:00:02.23 bitrate= 45.0kbits/s
frame= 155 fps= 61 q=21.0 size= 18kB time=00:00:03.23 bitrate= 45.4kbits/s #:-S
That's odd. What's the video file size? Is it more than zero bytes?
Did it not work to download a ready to use static ffmpeg from http://ffmpeg.zeranoe.com/builds/ ?
Could you share the video so I can try play it myself? (dropbox link, your own server link, or something else...)
Thanks for testing! :)
riastroes.nl/2015/test
Hamoid, thank you for your help!! you can find the basic.mp4 file in this test directory
Did it not work to download a ready to use static ffmpeg from http://ffmpeg.zeranoe.com/builds/ ? That's what I used now to make this basic.mp4
gr. Ria
Thanks. That mp4 is for some reason not valid. I'm going to try the library with some of my colleagues using Windows and I hope we find a way to make it work. I'll be back :)
Thanks man! I will wait ...
Does this file play fine? http://filebin.ca/23rkQE33zQqH/basic.mp4 I produced that one on my computer (Arch Linux) with ffmpeg 2.6.3.
I released version 0.0.6 that I hope fixes the playback issues in Mac and Windows. Does it work any better?
No, just a black screen.
Strange there are missing a some posts. I wrote earlier that your http://filebin.ca/23rkQE33zQqH/basic.mp4 was playing well in VLC, but not in Media player.
Hi hamoid! I'm very excited to use test your library. I've tried the 'basic' example and failed. I'm on ubuntu 14.04 and when i'vewas prompted to locate the ffmpeg i didn't know what to do. Then i downloaded the ffmpeg most recent release, unziped and when the prompt asked for the ffmpeg i gave the location of some ffmpeg.c file. Then it crashed and didn't even asked for the ffmpeg location again. Any thoughts on that? Looking forward to render some animations :D
Hi! ffmpeg.c is the c language source code of ffmpeg. That's not an executable program. So first thing you should do is tell the video export library to forget the ffmpeg location. You can do that by calling videoExport.forgetFfmpegPath().
In Ubuntu you don't need to manually download ffmpeg. You can use the Ubuntu software center to install ffmpeg (if it's not already installed). You can test on a terminal by typing ffmpeg and pressing enter. Does it complain that ffmpeg is not found? In some Linux distributions it might be located at /usr/bin/ffmpeg
Cheers!
Brilliant! I've called the videoExport.forgetFfmpegPath() on the void setup() first but it didn't worked, then called in the void draw() and worked. WIth the ffmpeg package installed from this ppa i could generate the mp4. Thanks a lot hamoid. Soon i'm posting some results
Hello hamoid!
I'm on a Mac (Yosemite 10.10.3) and have installed ffmpeg. But when I run the examples I get these errors:
java.io.IOException: Cannot run program "/Users/andreasrefsgaard/Downloads/ffmpeg-73211-g30e9ebb.7z": error=13, Permission denied
Do you know how to fix this?
Hi, 7z files are compressed files. Similar to zip files. So that file is not a program you can run, you have to uncompress the 7z file first. I'll try to write detailed install instructions for ffmpeg during the following days (I need to try the process on different operating systems).
Okay, thanks :). Please provide a link to the install instructions if you find the time
http://7-zip.org/
hey. thanks for the nice library. i have the problem that the colors in the exported are less saturated. any idea how to change that?
is use these settings: videoExport.setFrameRate(30); videoExport.setQuality(100);
running uner windows 7.
screenshot processing application
screenshot video
I found this link possible solution: https://stackoverflow.com/questions/33403492/ffmpeg-converted-x264-video-shows-sharply-reduced-color-saturation
I'll create an issue on GitHub and try it when I get some time.
thanks
Hi Hamoid! I'm new to this forum(not to processing), so forgive me if this comment is pointless/too late. I tried your library. It does not work on windows PC. The video it exports cannot be opened. If i use other video players, a blank screen appears for the correct amount of time(i think). Any ideas why? Thanks
Hi! Could you please try to close the sketch in these three different ways and tell me if the resulting video is in all three cases broken? 1. Press ESC 2. Click STOP button on the IDE. 3. Click close icon on the sketch window. Also, which version of Processing? If not the latest, could you try on 3.0.2?
Hi @hamoid, did you add the sound-export option in the end? In order to export video files with working sound to it. Thanks
i have been trying to export the video and then set it again together with the sound in an external software, but it is not working, as I can't set up the frameRate right. It seems it needs to be exported together...
Didn't add that yet, sorry. Here two links that may help you do that: https://superuser.com/questions/277642/how-to-merge-audio-and-video-file-in-ffmpeg https://davidwalsh.name/combine-audio-video
hi hamoid, I tried to combine audio and video via cmd. but it gives the same result then with adobe premiere (I tried before). I can't manage to bring the frameRate of the video together with the Hz of the audio. i manage to almost have it synchronized, but not really. i guess that processing has some delay... probably it needs to done in processing, frame per frame?
I see, so you're not just adding some background music, but you need it to be tightly in sync. Does this help? https://wjwoodrow.wordpress.com/2013/02/04/correcting-for-audiovideo-sync-issues-with-the-ffmpeg-programs-itsoffset-switch/ You could do some experiments, for instance by creating a clock video. Every second you have an audible and visible click, and render 1 minute of this. Then you could see if there's just a constant offset, or if the offset increases over time.
thanks i will try it, for better understanding: I load some music file, analyze it via "sound". and then make some visualization triggered by the sound spectrum. the result is a sound visualizer. then when I export the visual, it doesn't fit with the audio if I try to link it in some external software.
I managed to adjust the frameRate, it looks like it produces a constant offset. But still, I have to test it. and then what happens, if the visual is a bit heavy and processing can't calculate the fps right? then every visual will have a different offset and delay...impossible to control.
I now understand the problem, but that's not an issue of the video export library. You should probably split the process in two parts (that's what I've done in the past). One, analyze the video without drawing anything. Just export the audio analysis data to a file on disk, including timing information. Second, in a different program, you use that data to draw frames matching the right times from your data. That way your graphics will be in sync with your audio. It's very unlikely that it will work if you analyze, render and save video frames on real time, because the time it takes to do these 3 steps is unpredictable, and it won't happen exactly at 30.000 fps.
You mean something like this https://vimeo.com/27642353 Or do you have any other hints/or code pieces? It seams a good idea, i will try it. thanks
Yes, something like that. I would use createWriter(), which did not exist when she made that video. It would be nice to create a Processing Tool for this purpose, for creating a CSV file at a specific FPS including amplitude and FFT from an audio file. Some day when I have time...
Hello hamoid!
First of all congratulations for this nice and useful library.
Said that, I have a problem when I try to export a video and I am using pixelDensity(displayDensity());
The error message is: ArrayIndexOutBoundsException:2832392
How could I fix it? Thank you
Hi & thanks. I've never used that function, so I'm not sure. Could you post a link to your code?
I just realized I am also following your tutorials on Youtube! I appreciate so much your help in every channel!
Your library works perfectly without pixelDensity() function so I guess the problem is about pixel rendering for retina.
Sorry again for late response. I use processing 3.0. I'm not sure what u mean by "close sketch in three different ways". I always use a button in the sketch to close, using the "exit()" function. I'll try by using the close and stop buttons.
Surprising result:
It works occasionally now, but only if i use the stop button in IDE.
Thanks!
It works about 2 times in every 3 tests.
But why?
Why doesn't it work if i use
exit()
function, after all, that's supposed to do the same thing?Pls Note that since it only works with IDE stop button, one cant export applications made using the library - a major setback.
This is the error it throws all the time:
Apr 24, 2016 1:46:46 PM java.util.prefs.WindowsPreferences <init> WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root
0x80000002. Windows RegCreateKeyEx(...) returned error code 5
It works if i use IDE STOP button, even though it throws the same error.
I just realized I learned most of my basics of processing from your channel, thanks for that too.
It could help if u made a video on this library too.
Thanks!
@alexdontsurf I'll try on a retina computer when I see one :)
@Lord_of_the_Galaxy Are you using the latest version of the library? This used to be a error before. But it's unrelated to the exit() issue. I don't know why that happens. I will ask and do some tests.
Good idea about making a video about this library :) Cheers!
Nope. It still doesn't work.
Thanks anyway!
@Lord_of_the_Galaxy It seems to be an issue in Processing. You can try a workaround as I suggested here: https://github.com/hamoid/video_export_processing/issues/6#issuecomment-217820288 (basically, call videoExport.dispose() before closing your sketch to make sure all the data is saved to disk).
Um, yeah. I tried that too.
But it still does the same thing(even though I exit after calling dispose( ) )
Any ideas why that might be happening?
Any workarounds to this?
Thanks!
@Lord_of_the_Galaxy What is "the same thing"? It still produces a broken video file? If that's the case I'm going to need to test it on a Windows computer.
If you know how to use the command line, it might help me if you run this command on the folder where the video is found: "ffmpeg.exe -i YOURVIDEO.mp4" (replace YOURVIDEO with the right filename). It will output some text, which you can copy by selecting and right clicking the mouse. Finally paste it here. I hope that reveals something useful.
By same thing I mean it still produces same old broken video file.
The sample code I use:
import com.hamoid.*;
I always exit using a key Press, yet it fails to produce any usable movie files. Also note that it still works if i use the stop button pin the IDE.
That is what it says after doing what you told on command line. I understand nothing of what it says, though. I hope it can reveal something good.
It is useful. I see there "moov atom not found" which according to http://muzso.hu/2012/11/14/how-to-fix-a-broken-mp4-mov-video-ffmpeg-reports-moov-atom-not-found means that the end of the file is missing. So for some reason, they keyPressed + dispose trick is not working. I'll investigate.
According to exit()'s web reference: https://processing.org/reference/exit_.html
System's exit() should not be used in Processing: :-SS