-
-
Save jbilcke/5405777 to your computer and use it in GitHub Desktop.
execfile("/your/path/to/videomaker.py") | |
videomaker( | |
ts_min=1352261778000, # "from" timestamp.. | |
ts_max=1352262378000, # .."to" timestamp | |
frames=20, # number of images in the video. eg 200 frames for a video at 20 frames per seconds = 10 seconds of video | |
output_prefix="/path/to/output/dir/frame_", # path where to write the png. images will be prefixed with "frame_" | |
output_format=".png" # you probably want to leave png here | |
) |
# not tested - of course you need to change this to your settings | |
# here this will generate a 20 frame/sec video of 1024x1024 pixels. Not standard for a video, but computers can deal with it :) | |
# the duration of the video is controlled by the number of images. ffmpeg will automatically stop when it reaches the end. | |
# tip: | |
# frame_%d.png will count from 1 to N | |
# frame_%02d.png will count from 01 to N | |
# frame_%03d.png will count from 001 to N.. you get the point | |
ffmpeg -r 20 -f image2 -i /path/to/output/dir/frame_%d.png -y -s 1024x1024 out.mp4 |
# videomaker assumes each node has a "timestamp" numeric that can be compared | |
def videomaker(ts_min, ts_max, frames, output_prefix, output_format): | |
length = ts_max - ts_min # duration between min and max. these can Integers or Double - just use the same unit everywhere | |
interval = length / float(frames) # time interval between each frame | |
t = ts_min # set the cursor to the beginning | |
for i in range(0, frames): # let's start to count from image 0 to image FRAMES | |
t += i * interval | |
setVisible(g.filter(timestamp < t)) # filter using the "timestamp" node attribute. We keep nodes *before* the time cursor | |
exportGraph("%s%s%s" % (output_prefix, i, output_format)) # export. maybe put more parameters here? |
Hi there. I've been looking for this for a while, thanks for pulling it together!
Sadly, having followed these instructions I get what appears to be a JS error -- I realise this post is coming nearly 4 years after development of this script, so wholly expect that updates to both Gephi (using 0.9.2) and JS (v8u144) on macOS 12.6.
I get the following error when running the script:
TypeError: unsupported operator for attribute type 'class java.lang.Integer'
Any thoughts? help appreciated
Hi!
in the script videomaker.py, timestamp is an attribute of the nodes, right? Which attribute is g in g.filter? I'm trying to use this code, but in my graph, the time parameter belongs to the edges (the animation shows the edges being added..), not to the nodes...How can I edit this code to that?
Thanks in advance!
Thanks for sharing this, Julian! Much appreciated!