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_convert_format#

audio_convert_format(*columns, format='wav', on_error='raise', max_decoded_bytes=1073741824, concurrency=None)[source]#

Convert encoded audio to another encoded format.

This is a boundary conversion for encoded inputs. It decodes the input and immediately re-encodes it to the requested format; it does not expose an intermediate AUDIO_WAVEFORM column.

Parameters
  • *columns – Optional audio columns. Supported inputs are BYTES and URI STRING.

  • format – Encoded output format. Common values are "wav", "flac", "ogg", "aiff", and "mp3". Actual availability depends on the worker’s soundfile/libsndfile runtime. PyFlink writes a stable default subtype for each supported format; if the current libsndfile runtime does not support that subtype, the operator fails instead of silently choosing an environment-dependent subtype.

  • on_error – Handling strategy for corrupt supported audio inputs. "raise" propagates conversion failures. "null" returns NULL for rows that cannot be decoded. URI access errors, encoding errors, and unsupported input kinds still raise.

  • max_decoded_bytes – Maximum decoded PCM payload allowed during the decode-then-encode conversion. The default is 1 GiB.

  • concurrency – UDF concurrency. None uses the framework default.

Returns

A UDF producing encoded BYTES in the requested format.

Raises

ValueError – If on_error is unsupported, the input is not BYTES or URI STRING, if the format is unsupported, or if max_decoded_bytes is invalid. Encoding errors, including an unavailable default output subtype, fail fast even when on_error="null".

Examples::
>>> # Usage 1: create a reusable UDF and apply it to a column.
>>> convert = audio_convert_format(
...     format="wav",
...     on_error="null",
...     max_decoded_bytes=1024 * 1024 * 1024,
... )
>>> df = df.with_column("wav", convert(col("uri")))
>>>
>>> # Usage 2: pass the column directly when building the expression.
>>> df = df.with_column(
...     "wav",
...     audio_convert_format(
...         col("uri"),
...         format="wav",
...         on_error="null",
...         max_decoded_bytes=1024 * 1024 * 1024,
...     ),
... )

previous

pyflink.multimodal.operators.audio_encode

next

pyflink.multimodal.operators.audio_standardize

Show Source

Created using Sphinx 4.5.0.