Python: captionbob.plugins
captionbob.plugins.audio_waveform_progress_bar
Audio waveform progress bar plugin for the whole video.
A row of bars stands on the bottom edge of the video. The row is the loudness of the whole audio, from the start of the video on the left to the end on the right. Each bar is one part of the video time, and it is tall when that part is loud. The bars do not move. The bars of the part that has played have the full color, and the other bars are dim, so the row fills from the left to the right while the video plays.
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_waveform_progress_bar.py
Settings
The command line and the HTTP API call this plugin audio_waveform_progress_bar. Its settings class is AudioWaveformProgressBarSettings. Each setting has the default below.
| Setting | Type | Default | Description |
|---|---|---|---|
color |
string | "#00E5FF" |
Color of the bars, as "#RRGGBB". |
height |
integer | 200 |
Height of the bar area in pixels. The area stands on the bottom edge of the video. No bar is higher than the area. |
bar_width |
integer | 8 |
Width of one bar in pixels. |
gap |
integer | 4 |
Width of the gap between two bars in pixels. 0 gives bars that touch. |
unplayed_opacity |
number | 0.3 |
How well the bars of the part that has not played show, from 0 to below 1. 0 hides them, so only the played part shows. The bars of the played part always show in full. |
sensitivity |
number | 4.2 |
Gain of the loudness in front of the bars. A higher value gives taller bars. With 1.0, only a sound of the fullest loudness gives a bar as high as the area. It does not change the audio of the video. |
AudioWaveformProgressBarSettings
@dataclass(frozen=True)
class AudioWaveformProgressBarSettings
The look of the audio waveform progress bar.
Args:
color: Color of the bars, as "#RRGGBB".height: Height of the bar area in pixels. The area stands on the bottom edge of the video. No bar is higher than 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.unplayed_opacity: How well the bars of the part that has not played show, from 0 to below 1. 0 hides them, so only the played part shows. The bars of the played part always show in full.sensitivity: Gain of the loudness in front of the bars. A higher value gives taller bars. With 1.0, only a sound of the fullest loudness gives a bar as high as the area. It does not change the audio of the video.
Raises:
ValueError: When a value is outside its range, when the color is not in the form "#RRGGBB", or when the sensitivity is so low that the loudest sound gives a bar of less than one pixel.
AudioWaveformProgressBarPlugin
class AudioWaveformProgressBarPlugin
def __init__(self, settings: AudioWaveformProgressBarSettings) -> None
Builds the ffmpeg filter text that draws the audio waveform progress bar.
Args:
settings: The look of the bars.
AudioWaveformProgressBarPlugin.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 gives the heights of 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, or when no bar fits in the video width.