Breadcrumbs

Video transcoding with FFmpeg

Video assets with large or uncompressed video data can be transcoded as small files for the web and other devices.

Introduction

FFmpeg transcoder includes a multi-threading support and support of more than a hundred video codecs.

It is licensed under LGPL (Lesser GPL). Problems arise when using additional codices such as X.264, which brings better results, but is under GPL and therefore cannot be used together with Censhare.

For moderate use cases, FFmpeg is sufficient as the only encoding solution. Depending on size and other characteristics the of video data you must think early enough about scalability and possibly operate FFmpeg on separate machines using one or more Censhare Service Clients. With its default settings, FFMpeg can easily consume over 7 percent of the CPU even on a quad-core i50 CPU.

Additional licensing costs might apply for commercial use depending on the application, for example: MPEG LA. 

Steps

The following configuration will use FFmpeg for any kind of tasks, including video preview, still images, etc.

  1. Download the binaries from the official download area

    1. Alternatively, compile it yourself from the latest source code. Link to the Git repository can be found through the third-party provider website.

  2. Clone Git repo censhare-Product to some place, e.g, your local machine.

  3. Either in the Web or Java Client, find the “Import assets” server action

    Screenshot 2025-06-20 at 16.25.47.png
    Screenshot 2025-06-20 at 16.26.18.png


  4. Import the available FFmpeg presets from the Server installation folder censhare-Server/install/assets/optional/preset-ffmpeg

  5. In the Admin Client, go to Configuration → Services → Video: FFmpeg → General setup

  6. Enable the service

  7. In the Special setup section, specify if you want to use the Service Client to outsource the load to another “physical” server

  8. In the Admin Client, go to Configuration → Modules → Video: FFmpeg → Video conversion (automatic)

  9. Under General setup, select Enabled.

  10. Under Trigger events-> Asset events, select at least Create asset, Rebuild video preview, Rebuild preview, Save and Close.

    Screenshot 2025-06-20 at 16.43.07.png
    1. Optionally, select any other events that should trigger the transcoding.

  11. Under Asset filters → Search, add the following condition to the filter: 
    (Currversion = "0") and (Deletion state = "Not deleted") and (State = "Available") and (Type = "video")

  12. Under Special setup, select the presets and output file types.

  13. Confirm your edits with OK. A custom configuration is created under "Configuration/Module/FFmpeg" below the default configuration.

  14. To activate your edits, click Update server configuration on the toolbar of the censhare Admin Client.

Default FFmpeg presets and possible changes to them

Censhare comes with a few default presets. Those have proven to work well with the Censhare Web. Default presets can (but better should not) be modified and/or used as templates for your custom presets. The first line in each XML file can be used in a CLI tool (e.g., Terminal) for local testing of the new presets.

Please refer to the third-party documentation for the exact meaning of the parameters in the XML configuration.

If you want to adjust the number of simultaneous threads used by FFmpeg, you can add this line to the preset XML:

XML
<parameter key = "-threads" value = "16" />
Default presets

720p height

XML
<?xml version="1.0" encoding="UTF-8"?>

<!-- ffmpeg -i INPUT-FILENAME.mp4 -r 24 -f mp4 -codec:v libx264 -profile:v baseline -level 3.1 -preset slow -crf 1 -maxrate 2500k -bufsize 5000k -vf scale=1280:720 -threads 0 -codec:a aac -b:a 96k -movflags faststart OUTPUT-FILENAME.mp4 -->

<parameters>
  <parameter key="-i" value="@input@"/>
  <parameter key="-ss" value="@start-time@"/>
  <parameter key="-t" value="@duration@"/>
  <parameter key="-r" value="24"/>
  <parameter key="-f" value="mp4"/>
  <parameter key="-codec:v" value="libx264"/>
  <parameter key="-profile:v" value="baseline"/>
  <parameter key="-level" value="3.1"/>
  <parameter key="-preset" value="slow"/>
  <parameter key="-crf" value="1"/>
  <parameter key="-maxrate" value="2500k"/>
  <parameter key="-bufsize" value="5000k"/>
  <parameter key="-vf" value="scale=1280:720"/>
  <parameter key="-threads" value="0"/>
  <parameter key="-codec:a" value="aac"/>
  <parameter key="-b:a" value="96k"/>
  <parameter key="-movflags" value="faststart"/>
  <parameter key="-loglevel" value="error"/>
  <parameter key="-y"/>
  <parameter key="@output@"/>
</parameters>

480p height

XML
<?xml version="1.0" encoding="UTF-8"?>

<!-- ffmpeg -i INPUT-FILENAME.mp4 -r 24 -f mp4 -codec:v libx264 -profile:v baseline -level 3.0 -preset slow -crf 1 -maxrate 1200k -bufsize 2400k -vf scale=854:480 -threads 0 -codec:a aac -b:a 96k -movflags faststart OUTPUT-FILENAME.mp4 -->

<parameters>
  <parameter key="-i" value="@input@"/>
  <parameter key="-ss" value="@start-time@"/>
  <parameter key="-t" value="@duration@"/>
  <parameter key="-r" value="24"/>
  <parameter key="-f" value="mp4"/>
  <parameter key="-codec:v" value="libx264"/>
  <parameter key="-profile:v" value="baseline"/>
  <parameter key="-level" value="3.0"/>
  <parameter key="-preset" value="slow"/>
  <parameter key="-crf" value="1"/>
  <parameter key="-maxrate" value="1200k"/>
  <parameter key="-bufsize" value="2400k"/>
  <parameter key="-vf" value="scale=854:480"/>
  <parameter key="-threads" value="0"/>
  <parameter key="-codec:a" value="aac"/>
  <parameter key="-b:a" value="96k"/>
  <parameter key="-movflags" value="faststart"/>
  <parameter key="-loglevel" value="error"/>
  <parameter key="-y"/>
  <parameter key="@output@"/>
</parameters>

360p height

XML
<?xml version="1.0" encoding="UTF-8"?>

<!-- ffmpeg -i INPUT-FILENAME.mp4 -r 24 -f mp4 -codec:v libx264 -profile:v baseline -level 3.0 -preset slow -crf 1 -maxrate 650k -bufsize 1300k -vf scale=640:360 -threads 0 -codec:a aac -b:a 96k -movflags faststart OUTPUT-FILENAME.mp4 -->

<parameters>
  <parameter key="-i" value="@input@"/>
  <parameter key="-ss" value="@start-time@"/>
  <parameter key="-t" value="@duration@"/>
  <parameter key="-r" value="24"/>
  <parameter key="-f" value="mp4"/>
  <parameter key="-codec:v" value="libx264"/>
  <parameter key="-profile:v" value="baseline"/>
  <parameter key="-level" value="3.0"/>
  <parameter key="-preset" value="slow"/>
  <parameter key="-crf" value="1"/>
  <parameter key="-maxrate" value="650k"/>
  <parameter key="-bufsize" value="1300k"/>
  <parameter key="-vf" value="scale=640:360"/>
  <parameter key="-threads" value="0"/>
  <parameter key="-codec:a" value="aac"/>
  <parameter key="-b:a" value="96k"/>
  <parameter key="-movflags" value="faststart"/>
  <parameter key="-loglevel" value="error"/>
  <parameter key="-y"/>
  <parameter key="@output@"/>
</parameters>

240p height

XML
<?xml version="1.0" encoding="UTF-8"?>

<!-- ffmpeg -i INPUT-FILENAME.mp4 -r 24 -f mp4 -codec:v libx264 -profile:v baseline -level 1.3 -preset slow -crf 1 -maxrate 650k -bufsize 1300k -vf scale=428:240 -threads 0 -codec:a aac -b:a 96k -movflags faststart OUTPUT-FILENAME.mp4 -->

<parameters>
  <parameter key="-i" value="@input@"/>
  <parameter key="-ss" value="@start-time@"/>
  <parameter key="-t" value="@duration@"/>
  <parameter key="-r" value="24"/>
  <parameter key="-f" value="mp4"/>
  <parameter key="-codec:v" value="libx264"/>
  <parameter key="-profile:v" value="baseline"/>
  <parameter key="-level" value="3.0"/>
  <parameter key="-preset" value="slow"/>
  <parameter key="-crf" value="1"/>
  <parameter key="-maxrate" value="650k"/>
  <parameter key="-bufsize" value="1300k"/>
  <parameter key="-vf" value="scale=428:240"/>
  <parameter key="-threads" value="0"/>
  <parameter key="-codec:a" value="aac"/>
  <parameter key="-b:a" value="96k"/>
  <parameter key="-movflags" value="faststart"/>
  <parameter key="-loglevel" value="error"/>
  <parameter key="-y"/>
  <parameter key="@output@"/>
</parameters>


Using multiple configurations

If you want to use another transcoder in parallel (e.g., for still images), this can be achieved by using a stricter asset filter (e.g., by adding a domain to it) and/or by combining this filter with only specific events. You will need to create separate configurations for each use case.

The same can be done if you want to use one transcoder for different use cases as you can only apply one filter per configuration.