Skip to main content
Pixeltable UDFs for AudioType. View source on GitHub

udf get_metadata()

get_metadata(audio: Audio) -> Json
Gets various metadata associated with an audio file and returns it as a dictionary. Parameters:
  • audio (Audio): The audio to get metadata for.
Returns:
  • Json: A dict such as the following:
    {
        'size': 2568827,
        'streams': [
            {
                'type': 'audio',
                'frames': 0,
                'duration': 2646000,
                'metadata': {},
                'time_base': 2.2675736961451248e-05,
                'codec_context': {
                    'name': 'flac',
                    'profile': None,
                    'channels': 1,
                    'codec_tag': '\x00\x00\x00\x00',
                },
                'duration_seconds': 60.0,
            }
        ],
        'bit_rate': 342510,
        'metadata': {'encoder': 'Lavf61.1.100'},
        'bit_exact': False,
    }
    
Example: Extract metadata for files in the audio_col column of the table tbl:
tbl.select(tbl.audio_col.get_metadata()).collect()