Alfresco Tip: Enable video thumbnail and transformations with FFMPEG

This is a quick tip to enable video thumbnail and transformations in Alfresco thanks to FFMPEG integration.  This feature can be integrated easily since Alfresco 4.X (for both Enterprise and Community).  The result on the thumbnail creation is something like this: Screen Shot 2014-02-14 at 3.13.19 PM Video format supported for the JPG thumbnail creation are: 3g2, 3gp, asf, avi, avx, flv, mov, movie, mp4, mpeg2, mpg, ogv and wmv. Other than that you will be able to create folder rules to transform between video formats, this is a sample rule to transform from MP4 to FLV: Screen Shot 2014-02-14 at 3.14.25 PM Thanks to the ffmpeg integration we will be able to transform video formats as shows below:

  • from 3g2 to flv
  • from 3gp to flv
  • from asf to flv
  • from avi to flv
  • from avx to flv
  • from mov to flv
  • from movie to flv
  • from mp4 to flv
  • from mpeg2 to flv
  • from mpg to flv
  • from ogv to flv
  • from wmv to flv
  • from 3g2 to mp4
  • from 3gp to mp4
  • from asf to mp4
  • from avx to mp4
  • from mov to mp4
  • from movie to mp4
  • from mpeg2 to mp4
  • from mpg to mp4
  • from wmv to mp4

By default in Alfresco, ffmpeg also supports next audio transformations:

  • from aiff to mp3
  • from au to mp3
  • from m4a to mp3
  • from oga to mp3
  • from wav to mp3

Now you may are wondering “does ffmpeg support mov to wmv video transformation?” No, it doesn’t do it by default with the out-of-the-box configuration. It only supports conversions TO mp4 and flv. You may add more formats using other tool than ffmpeg or customizing the existing transformers (see last paragraph of this post).

Installation: You already should have an Alfresco 4.2 up and running (it may works with 4.X and pretty similar for Windows and Linux). This procedure is very easy, just install ffmpeg, add some config lines to alfresco-global.properties, rename a couple of files and restart Alfresco:

  • Install ffmpeg on your server. I have installed the static binary for 64 bits from http://www.ffmpeg.org/download.html
  • Copy the ffmpeg binary (if static) to a place like  /opt/alfresco/common/bin/
  • Once you have this, run the command from the command line to see if it works correctly: ./ffmpeg
  • Edit your alfresco-global.properties and add next lines:
ffmpeg.exe=/opt/alfresco/common/bin/ffmpeg

### Needed for video thumbnails ###
# ffmpeg.thumbnail
# ================
content.transformer.ffmpeg.thumbnail.priority=50
content.transformer.ffmpeg.thumbnail.extensions.3g2.jpg.supported=true
content.transformer.ffmpeg.thumbnail.extensions.3gp.jpg.supported=true
content.transformer.ffmpeg.thumbnail.extensions.asf.jpg.supported=true
content.transformer.ffmpeg.thumbnail.extensions.avi.jpg.supported=true
content.transformer.ffmpeg.thumbnail.extensions.avx.jpg.supported=true
content.transformer.ffmpeg.thumbnail.extensions.flv.jpg.supported=true
content.transformer.ffmpeg.thumbnail.extensions.mov.jpg.supported=true
content.transformer.ffmpeg.thumbnail.extensions.movie.jpg.supported=true
content.transformer.ffmpeg.thumbnail.extensions.mp4.jpg.supported=true
content.transformer.ffmpeg.thumbnail.extensions.mpeg2.jpg.supported=true
content.transformer.ffmpeg.thumbnail.extensions.mpg.jpg.supported=true
content.transformer.ffmpeg.thumbnail.extensions.ogv.jpg.supported=true
content.transformer.ffmpeg.thumbnail.extensions.wmv.jpg.supported=true

### Needed for video transformations ###
# ffmpeg.flv
# ==========
content.transformer.ffmpeg.flv.priority=50
content.transformer.ffmpeg.flv.extensions.3g2.flv.supported=true
content.transformer.ffmpeg.flv.extensions.3gp.flv.supported=true
content.transformer.ffmpeg.flv.extensions.asf.flv.supported=true
content.transformer.ffmpeg.flv.extensions.avi.flv.supported=true
content.transformer.ffmpeg.flv.extensions.avx.flv.supported=true
content.transformer.ffmpeg.flv.extensions.mov.flv.supported=true
content.transformer.ffmpeg.flv.extensions.movie.flv.supported=true
content.transformer.ffmpeg.flv.extensions.mp4.flv.supported=true
content.transformer.ffmpeg.flv.extensions.mpeg2.flv.supported=true
content.transformer.ffmpeg.flv.extensions.mpg.flv.supported=true
content.transformer.ffmpeg.flv.extensions.ogv.flv.supported=true
content.transformer.ffmpeg.flv.extensions.wmv.flv.supported=true

# ffmpeg.mp4
# ==========
content.transformer.ffmpeg.mp4.priority=50
content.transformer.ffmpeg.mp4.extensions.3g2.mp4.supported=true
content.transformer.ffmpeg.mp4.extensions.3gp.mp4.supported=true
content.transformer.ffmpeg.mp4.extensions.asf.mp4.supported=true
content.transformer.ffmpeg.mp4.extensions.avx.mp4.supported=true
content.transformer.ffmpeg.mp4.extensions.mov.mp4.supported=true
content.transformer.ffmpeg.mp4.extensions.movie.mp4.supported=true
content.transformer.ffmpeg.mp4.extensions.mpeg2.mp4.supported=true
content.transformer.ffmpeg.mp4.extensions.mpg.mp4.supported=true
content.transformer.ffmpeg.mp4.extensions.wmv.mp4.supported=true
# The avi and ogv to mp4 transformations did not work with ffmpeg 0.8.6
# Please check the latest ffmpeg documentation for the latest information
# content.transformer.avi.mp4.extensions.mpg.mp4.supported=true
# content.transformer.ogv.mp4.extensions.wmv.mp4.supported=true

# ffmpeg.mp3
# ==========
content.transformer.ffmpeg.mp3.priority=50
content.transformer.ffmpeg.mp3.extensions.aiff.mp3.supported=true
content.transformer.ffmpeg.mp3.extensions.au.mp3.supported=true
content.transformer.ffmpeg.mp3.extensions.m4a.mp3.supported=true
content.transformer.ffmpeg.mp3.extensions.oga.mp3.supported=true
content.transformer.ffmpeg.mp3.extensions.wav.mp3.supported=true

  • Find two files in your extension directory (tomcat/shared/clases/alfresco/extension) and rename them without the .sample extension: video-thumbnail-context.xml and video-transformation-context.xml
  • Restart the application server and done!

And what about if I want to do conversions to other formats? How can I do  transformation for changing resolution, size, quality and so forth? Just take a look to “video-transformation-context.xml” you will se how easy is to create a new commands using different options in the ffmpeg command.

This forum thread could be also helpful for you.

5 thoughts to “Alfresco Tip: Enable video thumbnail and transformations with FFMPEG”

  1. Hi Toni,

    one additional thing to mention: The default configuration for MP4 requires that a ffpreset named “default” is available. Depending on how you have installed FFmpeg, that may not be the case. To solve this it suffices to copy & rename one of the libx264 presets in the FFmpeg installation directory – choose the one you consider as “medium” quality / resolution.

  2. Hi Axel, thanks for your comment. Do you mean the config file libx264-medium.ffpreset? I downloaded the static compiled binary (doing a strings I have seen something like this inside), I have tried and I don’t think this is required with the static binary but anyways, in case of it is needed, a file called libx264-medium.ffpreset can be added to the ffmpeg directory with content like below:
    coder=1
    flags=+loop
    cmp=+chroma
    partitions=+parti8x8+parti4x4+partp8x8+partb8x8
    me_method=hex
    subq=7
    me_range=16
    g=250
    keyint_min=25
    sc_threshold=40
    i_qfactor=0.71
    b_strategy=1
    qcomp=0.6
    qmin=10
    qmax=51
    qdiff=4
    bf=3
    refs=3
    directpred=1
    trellis=1
    flags2=+bpyramid+mixed_refs+wpred+dct8x8+fastpskip
    wpredp=2.

  3. In case you use the Alfresco bundle installer, you may find problems running “ffmpeg” because of library conflicts.

    The Alfresco bundle start scripts overwrite the global Library PATH during startup to priorize the use of libraries found on:

    {alfresco-install}/common/lib

    Either if you built or installed ffmpeg from a distro package, it could had been linked to different library versions, and this error raises during a transformation:

    err: /usr/local/bin/ffmpeg: /opt/alfresco/common/lib/libz.so.1: no version information available (required by /usr/lib/x86_64-linux-gnu/libavcodec.so.54)
    /usr/local/bin/ffmpeg: /opt/alfresco/common/lib/libstdc++.so.6: version `GLIBCXX_3.4.15′ not found

    How to solve it?

    I’m unable to make it work yet :-(

    What have I tried?

    I tried adjusting the library loading path on built-setenv.sh and setenv.sh scripts, by lowering order of {alfresco-install}/common/lib. Not it looks like:

    LD_LIBRARY_PATH=”/opt/alfresco/postgresql/lib:$LD_LIBRARY_PATH:/opt/alfresco/common/lib”

    and

    LDFLAGS=”$LDFLAGS -L/opt/alfresco/common/lib”

    But no luck. Same error. This only happens when ffmpeg is ran by Alfresco, if you tried from a shell, it will work as expected.

    Any idea?

  4. At the end I decided to stop searching and used the static ffmpeg version, which works as expected.

  5. Hi Jonathan,

    yes it looks like is a dependencies problem, to see exactly what is missing you can run “ldd /usr/local/bin/ffmpeg” but using the static binary is the best way to solve it.

    Regards.

Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.