Python: captionbob.plugins
captionbob.plugins.audio_bar_waveform
Audio bar waveform plugin for the whole video.
A row of bars stands on the bottom edge of the video. Each bar is one pitch range of the audio, from the lowest pitch on the left to the highest pitch on the right. A bar is tall while its pitch range is strong, so quiet sound gives low bars and loud sound gives tall bars.
The plugin draws nothing itself. It builds the text of an ffmpeg filter graph, and ffmpeg draws the bars in the same pass that encodes the video.
Source file: captionbob/plugins/audio_bar_waveform.py
Settings
The command line and the HTTP API call this plugin audio_bar_waveform. Its settings class is AudioBarWaveformSettings. Each setting has the default below.
| Setting | Type | Default | Description |
|---|---|---|---|
color |
string | "#00E5FF" |
Color of the bars and of their glow, as "#RRGGBB". |
height |
integer | 200 |
Height of the bar area in pixels. The tallest bar is as high as the area. |
bar_width |
integer | 12 |
Width of one bar in pixels. |
gap |
integer | 6 |
Width of the gap between two bars in pixels. 0 gives bars that touch. |
glow_radius |
number | 4.0 |
Size of the glow in pixels, from 0 to 4.0. 0 gives bars with no glow. A glow that is larger than the gap fills the gap. |
glow_strength |
number | 1.0 |
How strong the glow is, from above 0 to 1.0. 1.0 is the plain blur, and a lower value makes the glow weaker. |
sensitivity |
number | 3.2 |
Gain of the audio in front of the bars. A higher value gives taller bars. It does not change the audio of the video. |
AudioBarWaveformSettings
@dataclass(frozen=True)
class AudioBarWaveformSettings
The look of the audio bar waveform.
Args:
color: Color of the bars and of their glow, as "#RRGGBB".height: Height of the bar area in pixels. The tallest bar is as high as the area.bar_width: Width of one bar in pixels.gap: Width of the gap between two bars in pixels. 0 gives bars that touch.glow_radius: Size of the glow in pixels, from 0 to 4.0. 0 gives bars with no glow. A glow that is larger than the gap fills the gap.glow_strength: How strong the glow is, from above 0 to 1.0. 1.0 is the plain blur, and a lower value makes the glow weaker.sensitivity: Gain of the audio in front of the bars. A higher value gives taller bars. It does not change the audio of the video.
Raises:
ValueError: When a value is outside its range or the color is not in the form "#RRGGBB".
AudioBarWaveformPlugin
class AudioBarWaveformPlugin
def __init__(self, settings: AudioBarWaveformSettings) -> None
Builds the ffmpeg filter text that draws the audio bar waveform.
Args:
settings: The look of the bars.
AudioBarWaveformPlugin.build_filter_graph
def build_filter_graph(self, video: VideoInfo, input_label: str,
output_label: str, audio_label: str) -> str
Build the ffmpeg filter graph text that draws the bars on one video.
Args:
video: The frame size, the frame rate and the duration of the video.input_label: Label of the video stream to draw on, without brackets. Example: "0:v".output_label: Label that the result gets, without brackets.audio_label: Label of the audio stream that moves the bars, without brackets. Example: "0:a". The graph only reads this audio and gives no audio back.
Returns:
The filter graph text for the ffmpeg option -filter_complex.
Raises:
ValueError: When a label is empty, when the bar area is not lower than the video, when no bar fits in the video width, or when the row has more bars than the most that it can show.