Export API Reference

This page documents the functions for exporting dynamic network animations to various formats.

Export Functions

NDTV.export_html — Function
export_html(layout::DynamicLayout, filepath::String; config=HTMLConfig())

Export a self-contained HTML animation: positions, edges, and active vertex sets for every frame are embedded as data, and a small JavaScript player draws them on a canvas with play/pause and a frame slider (when config.controls). Open the file in any browser — no dependencies.

Example

using NDTV, DynamicNetworks, Random
dnet = DynamicNetwork(2; observation_start=0.0, observation_end=2.0)
activate!(dnet, 0.0, 2.0; edge=(1, 2))
dl = render_animation(dnet; n_frames=2, rng=Xoshiro(1))
export_html(dl, joinpath(mktempdir(), "anim.html")).n_frames   # 2
source
NDTV.export_movie — Function
export_movie(layout::DynamicLayout, filepath::String; config=VideoConfig())

Render the animation frames to SVG and encode a video with the ffmpeg binary (R ndtv's saveVideo). Throws a MissingToolError (leaving the rendered frames on disk) when ffmpeg is not installed. Returns (filepath, n_frames, fps).

Example

export_movie(layout, "animation.mp4"; config=VideoConfig(fps=10))
source
NDTV.export_gif — Function
export_gif(layout::DynamicLayout, filepath::String; config=GIFConfig())

Render the animation frames to SVG and assemble an animated GIF with ImageMagick (magick, or the older convert), which needs an SVG delegate (librsvg). Throws a MissingToolError (leaving the rendered frames on disk) when ImageMagick is not installed. Returns (filepath, n_frames, fps).

Example

export_gif(layout, "animation.gif"; config=GIFConfig(fps=5))
source
NDTV.export_frames — Function
export_frames(layout::DynamicLayout, dir::String;
              width=800, height=600) -> Vector{String}

Render every frame of the animation to numbered SVG files in dir (created if needed): active edges as lines, active vertices as circles. Returns the file paths. This is the pure-Julia rendering backend used by export_movie/export_gif.

Example

using NDTV, DynamicNetworks, Random
dnet = DynamicNetwork(2; observation_start=0.0, observation_end=2.0)
activate!(dnet, 0.0, 2.0; edge=(1, 2))
dl = render_animation(dnet; n_frames=2, rng=Xoshiro(1))
paths = export_frames(dl, mktempdir(); width=100, height=100)
length(paths)                  # 2
source
NDTV.MissingToolError — Type
MissingToolError(tool, purpose, frames_dir)

Thrown by export_movie and export_gif when the external program they need (ffmpeg, ImageMagick) is not on PATH. The SVG frames already rendered are left in frames_dir, so they can be encoded by hand.

Example

using NDTV
err = MissingToolError("ffmpeg", "export_movie", "/tmp/frames")
sprint(showerror, err)
source

Configuration Types

NDTV.VideoConfig — Type
VideoConfig(; fps=30, width=800, height=600, codec="h264")

Configuration for video export with export_movie. Requires the ffmpeg binary, built with SVG input support (--enable-librsvg, as in the usual distribution builds); codec is passed to ffmpeg -c:v.

Example

using NDTV
cfg = VideoConfig(; fps=12, codec="mpeg4")
cfg.fps, cfg.codec             # (12, "mpeg4")
source
NDTV.GIFConfig — Type
GIFConfig(; fps=10, width=400, height=400, loop=0)

Configuration for GIF export with export_gif. Requires ImageMagick (magick or convert) with an SVG delegate (librsvg: librsvg2-bin on Debian/Ubuntu, librsvg2-tools on Fedora, brew install librsvg on macOS). loop=0 loops forever.

Example

using NDTV
GIFConfig(; fps=5).fps         # 5
source
NDTV.HTMLConfig — Type
HTMLConfig(; width=800, height=600, controls=true)

Configuration for export_html (self-contained; no external dependencies).

Example

using NDTV
HTMLConfig(; controls=false).controls   # false
source