logo

MMBase tips

Streams app: upload and transcode video

tip #22 / Sat 5 May 2012 / André / 0 comments

The MMBase Streams applications converts uploaded video (and audio and images) to different other formats, like webm, ogg or h.264. It is developed as an extension to the mmbase media application used by a few Dutch broadcasters.

Streams adds the ability to upload and transcode video and audio to different formats using open source encoding tools like FFmpeg and FFmpeg2Theora. Streams was especially developed for Open Images, a project by the Netherlands Institute for Sound and Vision and partners. 
It converts uploaded streams to different, open formats like: Ogg or WebM but also MP4/H.264. It make use of the open source tools FFmpeg, FFmpeg2Theora and ImageMagick to transcode media. It handles all video, audio and image formats FFMpeg can recognize and was especially developed for Open Images, an open source media platform.

Streams can be configured to handle the mime types 'image/*', 'video/*' and 'audio/*'. It depends on FFmpeg to recognize media. Users upload media and it gets automatically converted to more or less "open" formats most browsers can handle: video to WebM, OGV or MP4/H.264, audio to OGA, AAC or MP3 and images to PNG. It even contains a transcoder to create segmented TS streams of video's that can be viewed on mobile phones using celular networks. Our latest version of the stream app adds the ability to create thumbnails from movie stills.

Short configuration example for audio

The strength of the streams application can best be illustrated with a short example. The following FFmpeg command generates an Ogg audio file 'audio.ogg' from a source file 'audio.wav':

ffmpeg -i audio.wav -acodec libvorbis -aq 32 -ab 192k audio.ogg 

It is reflected in the mmbase streams configuration file 'createcaches.xml' like this:

<transcoder mimetype="audio/*" id="v3" in="intermediate">
<class name="org.mmbase.streams.transcoders.FFMpeg">
<param name="format">ogg</param>
<param name="acodec">libvorbis</param>
<param name="aq">32</param>
<param name="ab">192k</param>
</class>
<loganalyzer name="org.mmbase.streams.transcoders.FFMpegAnalyzer" />
</transcoder>

Input s a file of mimetype 'audio/*' and it is transcodes with FFmpeg to an 192 Kb Ogg Vorbis audio file.

Install FFmpeg and other tools

Like the mmbase resources application that converts image files, and depends on a correctly configured ImageMagick installation. You will need at least FFMpeg to convert video and audio, the applications uses it for recognition and transcoding of media.
If you have not configured and run FFmpeg previousely it is now the moment to do so.

Besides FFmpeg you may want to use FFmpeg2Theora to encode OGV and OGA. Installing and configuring FFmpeg2Theora may be a bit easier then FFmpeg.

When you have at least ffmpeg runnig you can start configuring mmbase. You can confirm if ffmpeg is installed by typing 'ffmpeg -version'.

$ ffmpeg -version
FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers
  built on Mar 17 2011 21:12:03 with gcc 4.2.1 (Apple Inc. build 5666) (dot 3)
  configuration: --prefix=/usr/local --enable-gpl --enable-nonfree --enable-shared 
    --enable-postproc --enable-avfilter --enable-pthreads --enable-x11grab 
    --enable-bzlib --enable-libmp3lame --enable-libtheora --enable-libvorbis 
    --enable-libx264 --enable-zlib --enable-libfaac --disable-yasm
  libavutil 50.36. 0 / 50.36. 0
  libavcore 0.16. 1 / 0.16. 1
  libavcodec 52.108. 0 / 52.108. 0
  libavformat 52.93. 0 / 52.93. 0
  libavdevice 52. 2. 3 / 52. 2. 3
  libavfilter 1.74. 0 / 1.74. 0
  libswscale 0.12. 0 / 0.12. 0
  libpostproc 51. 2. 0 / 51. 2. 0

Installation of streams

The streams application depends on two mmbase applications: media and resources. The first media handles media descriptions, the second resources handles file upload and file serving, f.e. all files in Open Images are saved http://www.openimages.eu/files. Streams itself is responsible for recognition and transcoding of all media. When you use Maven to build your projects you will at least need these mmbase applications.

  • mmbase-media
  • mmbase-resources.jar
  • mmbase-streams.jar

See for example the Maven project file for Open Images.

0 comments

RSS feed

Tweet this article

Most mentioned links:

MMBase documentation
MMBase API
MMBase SVN
Bugtracker
MMBase Taglib reference
The reference for all tags mm