# mod\_audio

Source: https://zotonic.com/docs/2188/mod_audio

URI: https://zotonic.com/id/2188

Language: en



Adds support for viewing and handling audio medium items.

This module parses audio files and extracts tags and an optional image from the audio file.

::: {.note title="Note"}
mod\_audio uses the command-line utilities `ffmpeg` and `ffprobe`. For mod\_audio to function correctly they must be present in the search path of Zotonic.
:::

Uploading
---------

The audio module hooks into the media model to intercept any audio file upload.

If an audio file is uploaded then the file is parsed using `ffprobe` to fetch:

- The bitrate
- Audio duration
- Tags, like artist, album
- Album art image, extracted as png using `ffmpeg`

The optional album art is used as the preview image. This image is visible when the audio media item is rendered using a `{% image ... %}` tag.

Viewing
-------

The audio module extends the `{% media %}` tag for viewing `audio/*` videos.

It uses the template `_audio_viewer.tpl` for viewing.

Editing
-------

The following properties are extracted from the audio file, and can be edited in the admin:

- artist
- album
- album\_artist
- composer
- genre
- track
- copyright
- is\_compilation (boolean flag)
- org\_pubdate, this is extracted form the `creation_time` tag

If there is no resource title given when creating the audio page then the title from the tags is used. If that one is empty then the file’s basename is used.

Accepted Events
---------------

This module handles the following notifier callbacks:

- `observe_media_upload_props`: Set medium properties from the uploaded file using `z_media_archive:abspath`.
- `observe_media_upload_rsc_props`: Set resource properties from the medium properties using `z_datetime:to_datetime`.
- `observe_media_viewer`: Return the media viewer for the audio using `z_template:render`.

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/2188?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/2188?language=en>)
