pyflink.multimodal.operators.audio_metadata#
- audio_metadata(*columns, concurrency=None)[source]#
Extract audio metadata.
The result is a row with the following fields:
sample_rate: samples per second, e.g.16000.channels: number of audio channels.frames: number of frames per channel.duration_ms: duration in milliseconds.format: encoded container format when known, such asWAV.codec: best-effort media codec short name, such aspcm_s16le.bit_rate: encoded bit rate when available.size: encoded object byte size when available.
Decoded
AUDIO_WAVEFORMvalues do not retain original container fields, soformat,codec,bit_rate, andsizemay beNone. This info operator treats corrupt supported media data as row-level dirty data: corruptBYTES/encoded inputs returnNULL. URI access errors, dependency errors, unsupported input kinds, and unexpected internal errors still fail fast.- Parameters
*columns – Optional audio columns. When provided, the UDF is applied directly.
concurrency – UDF concurrency.
Noneuses the framework default.
- Returns
A UDF producing
ROW<sample_rate INT, channels INT, frames BIGINT, duration_ms BIGINT, format STRING, codec STRING, bit_rate BIGINT, size BIGINT>, orNULLfor corrupt supported boundary inputs.- Raises
ValueError – If a row value is not
BYTES, URISTRING,AUDIO_CLIP_REF, orAUDIO_WAVEFORM.
- Examples::
>>> # Usage 1: create a reusable UDF and apply it to a column. >>> metadata = audio_metadata() >>> df = df.with_column("meta", metadata(col("audio_bytes"))) >>> >>> # Usage 2: pass the column directly when building the expression. >>> df = df.with_column( ... "meta", ... audio_metadata(col("audio_bytes")), ... )