Skip to content

avgen

AV Counter Generator

Register name used to load filter: avgen
This is a JavaScript filter, not checked during graph resolution and needs explicit loading.
Author: GPAC Team

This filter generates AV streams representing a counter. Streams can be enabled or disabled using type.
The filter is software-based and does not use GPU.

When adjust is set, the first video frame is adjusted such that a full circle happens at each exact second according to the system UTC clock.
By default, video UTC and date are computed at each frame generation from current clock and not from frame number.
This will result in broken timing when playing at speeds other than 1.0.
This can be changed using lock.

Audio beep is generated every second, with octave (2xfreq) of even beep used every 10 seconds.
When video is generated, beep is synchronized to video at each exact second.

If NTP injection is used, each video packet (but not audio ones) has a SenderNTP property set; if video is not used, each audio packet has a SenderNTP property set.

Multiple output stream generation

More than one output size can be specified. This will result in multiple sources being generated, one per size.
A size can be specified more than once, resulting in packet references when copy is not set, or full copies otherwise.
Target encoding bitrates can be assigned to each output using rates. This can be useful when generating dash:
Example

gpac avgen:sizes=1280x720,1920x1080:rates=2M,5M c=aac:FID=1 c=264:FID=2:clone -o live.mpd:SID=1,2

Multiview generation

In multiview mode, only the animated counter will move in depth backward and forward, as indicated by the disparity value.
When pack is set, a packed stereo couple is generated for each video packet.
Otherwise, when views is greater than 2, each view is generated on a dedicated output PID with the property ViewIdx set in [1, views].
Multi-view output forces usage of copy mode.

PID Naming

The audio PID is assigned the name audio and ID 1.
If a single video PID is produced, it is assigned the name video and ID 2.
If multiple video PIDs are produced, they are assigned the names videoN and ID N+1, N in [1, sizes].
If multiple views are generated, they are assigned the names videoN_vK and ID N*views+K-1, N in [1, sizes], K in [1, views].

Options

type (enum, default: av): output selection
a: audio only
v: video only
* av: audio and video

freq (uint, default: 440): frequency of beep
freq2 (uint, default: 659): frequency of odd beep
sr (uint, default: 44100): output samplerate
flen (uint, default: 1024): output frame length in samples
ch (uint, default: 1): number of channels
alter (bool, default: false): beep alternatively on each channel
blen (uint, default: 50): length of beep in milliseconds
fps (frac, default: 25): video frame rate
sizes (v2il, default: 1280x720): video size in pixels
pfmt (pfmt, default: yuv): output pixel format
lock (bool, default: false): lock timing to video generation
dyn (bool, default: true): move bottom banner
ntp (bool, default: true): send NTP along with packets
copy (bool, default: false): copy the framebuffer into each video packet instead of using packet references
dur (frac, default: 0/0): run for the given time in second
adjust (bool, default: true): adjust start time to synchronize counter and UTC
pack (enum, default: no): packing mode for stereo views
* no: no packing
* ss: side by side packing, forces views to 2
* tb: top-bottom packing, forces views to 2

disparity (uint, default: 20): disparity in pixels between left-most and right-most views
views (uint, default: 1): number of views
rates (strl): number of target bitrates to assign, one per size
logt (bool): log frame time to console