mod_video

Adds support for viewing and handling video medium items.

This module converts uploaded videos to h264 and adds a poster (preview) image of the movie.

Note

mod_video uses the command-line utilities ffmpeg and ffprobe. For mod_video to function correctly they must be present in the search path of Zotonic.

Uploading & conversion

The video module hooks into the media model to intercept any video upload. If a video is uploaded the following steps are done:

  • The video is moved to the site’s files/video_queue/ directory.
  • A video conversion task is added to the pivot task queue, this task will restart a video conversion in case of any problems.
  • A video conversion process is started, supervised by the video module.
  • The uploaded medium is replaced by a static lib/images/processing.png image.

Only a single video conversion process is allowed to run at any time. This to prevent overloading the server.

After the video is converted the resource’s medium record is replaced with the converted video. The frame at 10 seconds (at 1 second for movies shorter than 30 seconds) is added as the preview image of the video.

If a video can’t be converted then the video is replaced with the error image, found in lib/images/broken.png.

Viewing

The video module extends the {% media %} tag for viewing video/mp4 videos.

It uses the template _video_viewer.tpl for viewing. For the best viewing results, add css/video.css to your included css files.

Accepted Events

This module handles the following notifier callbacks:

  • observe_media_stillimage: Return the filename of a still image to be used for image tags using supervisor:start_link.
  • observe_media_upload_preprocess: If a video file is uploaded, queue it for conversion to video/mp4 using z_video_info:info.
  • observe_media_upload_props: After a video file is processed, generate a preview image using z_media_archive:abspath.
  • observe_media_viewer: Return the media viewer for the mp4 video using z_template:render.

Edit on GitHub

Observes

Notifications

observe_media_upload_props/3

Notification that a medium file has been uploaded. This is the moment to change properties, modify the file etc. The folded accumulator is the map with updated…

Notifications

observe_media_viewer/2

Request to generate a HTML media viewer for a resource. The HTML data can not contain any Javascript, as it might be serialized. This could happen if the…

Notifications

observe_media_upload_preprocess/2

Notification to translate or map a file after upload, before insertion into the database Used in mod_video to queue movies for conversion to mp4. You can set…

Notifications

observe_media_stillimage/2

See if there is a ‘still’ image preview of a media item. (eg posterframe of a movie) Return:: {ok, ResourceId} or undefined

See also

Modules

mod_video_embed

This module, if activated, checks the pasted URLs in the create media / page dialog of the admin. It will show an embed option for Youtube and Vimeo URLs. It…

Tags

media

Show embed, video or audio media.

Modules

mod_oembed

Makes media resources from embeddable URLs through the OEmbed protocol.

Modules

mod_audio

Adds support for viewing and handling audio medium items.