-
-
Save kikohs/eedc0f48b5d8eab8724e5ccb25e528c1 to your computer and use it in GitHub Desktop.
How to create a video using Gephi + Scripting plugin + ffmpeg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment