Python: captionbob.plugins
captionbob.plugins.audio_line_waveform
Audio line waveform plugin for the whole video.
One line goes across the whole width of the video, in an area on the bottom edge. The line is the wave of the sound. Each frame shows the sound of its own frame time, from the start on the left to the end on the right. Silence gives a flat line in the middle of the area, and loud sound gives tall waves.
The plugin draws nothing itself. It builds the text of an ffmpeg filter graph, and ffmpeg draws the line in the same pass that encodes the video.
Source file: captionbob/plugins/audio_line_waveform.py
Settings
The command line and the HTTP API call this plugin audio_line_waveform. Its settings class is AudioLineWaveformSettings. Each setting has the default below.
| Setting | Type | Default | Description |
|---|---|---|---|
color |
string | "#00E5FF" |
Color of the line and of its glow, as "#RRGGBB". |
thickness |
integer | 4 |
Thickness of the line in pixels. |
height |
integer | 200 |
Height of the line area in pixels. The area stands on the bottom edge of the video. The tallest wave is as high as the area. |
glow_radius |
number | 6.0 |
Size of the glow in pixels, from 0 to 6.0. 0 gives a line with no glow. |
glow_strength |
number | 1.5 |
How strong the glow is, from above 0 to 1.5. 1.0 is the plain blur, and a higher value makes the glow brighter. |
smoothing_hz |
number | 600.0 |
Sound above this pitch, in Hz, is removed before the line is drawn. A lower value gives a smoother line. With a high value, a hiss such as the letter "s" gives a thick rough band. |
sensitivity |
number | 2.0 |
Gain of the audio in front of the line. A higher value gives taller waves. A soft limit keeps the tallest wave inside the area. It does not change the audio of the video. |
AudioLineWaveformSettings
@dataclass(frozen=True)
class AudioLineWaveformSettings
The look of the audio line waveform.
Args:
color: Color of the line and of its glow, as "#RRGGBB".thickness: Thickness of the line in pixels.height: Height of the line area in pixels. The area stands on the bottom edge of the video. The tallest wave is as high as the area.glow_radius: Size of the glow in pixels, from 0 to 6.0. 0 gives a line with no glow.glow_strength: How strong the glow is, from above 0 to 1.5. 1.0 is the plain blur, and a higher value makes the glow brighter.smoothing_hz: Sound above this pitch, in Hz, is removed before the line is drawn. A lower value gives a smoother line. With a high value, a hiss such as the letter "s" gives a thick rough band.sensitivity: Gain of the audio in front of the line. A higher value gives taller waves. A soft limit keeps the tallest wave inside the area. 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".
AudioLineWaveformPlugin
class AudioLineWaveformPlugin
def __init__(self, settings: AudioLineWaveformSettings) -> None
Builds the ffmpeg filter text that draws the audio line waveform.
Args:
settings: The look of the line.
AudioLineWaveformPlugin.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 line 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 line, 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, or when the line area is not lower than the video.