Ctrl+K
Logo image Logo image

Site Navigation

  • API Reference
  • Examples

Site Navigation

  • API Reference
  • Examples

Section Navigation

  • PyFlink DataFrame
  • PyFlink Multimodal
    • Image
    • Video
    • Audio
    • Utilities
  • PyFlink Table
  • PyFlink DataStream
  • PyFlink Common

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 as WAV.

  • codec: best-effort media codec short name, such as pcm_s16le.

  • bit_rate: encoded bit rate when available.

  • size: encoded object byte size when available.

Decoded AUDIO_WAVEFORM values do not retain original container fields, so format, codec, bit_rate, and size may be None. This info operator treats corrupt supported media data as row-level dirty data: corrupt BYTES/encoded inputs return NULL. 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. None uses 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>, or NULL for corrupt supported boundary inputs.

Raises

ValueError – If a row value is not BYTES, URI STRING, AUDIO_CLIP_REF, or AUDIO_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")),
... )

previous

pyflink.multimodal.operators.is_valid_audio

next

pyflink.multimodal.operators.audio_duration

Show Source

Created using Sphinx 4.5.0.