Jun 18, 2012

Integrating FFmpeg with CQ DAM

Posted by Sneh Arora

Communiqué Digital Asset Management (CQ DAM) provides enterprise-wide sharing and distribution of an organization’s key digital assets. Users across an organization can store, manage, and access digital assets such as images, graphics, audio, video, and documents through a Web interface (or a CIFS or WebDAV folder). As soon as an asset is uploaded to DAM, a number of asynchronous workflows get triggered in the background which extract metadata information from the asset and generated renditions of different size/format/resolution for the uploaded image. For any video asset, 3 image renditions and 3 video renditions get generated by default .CQ DAM relies on ffmpeg executable for producing video renditions of the uploaded file. This executable is not shipped along with CQ and user needs to install it manually on his system. The following section covers installation of ffmpeg on Red Hat Server.

Installing FFmpeg on RHEL [Red Hat Enterprise 5.5]

1.       Download and install packages for ffmpeg and its transitive dependencies . Install them in the following sequence

1.       libavutil51-0.10.2-54.el5.x86_64.rpm

2.       libtheoradec1-1.1.1-13.el5.x86_64.rpm

3.       libtheora-1.1.1-1.fu14.x86_64.rpm

4.       libtheoraenc1-1.1.1-13.el5.x86_64.rpm

5.       libx264_118-0.118-17_20111111.2245.el5.x86_64.rpm

6.       libopencore-amrnb0-0.1.3-1.el5.x86_64.rpm

7.       libopencore-amrwb0-0.1.3-1.el5.x86_64.rpm

8.       libva-

9.       libswscale2-0.10.2-54.el5.x86_64.rpm

10.   libswresample0-0.10.2-54.el5.x86_64.rpm

11.   libpostproc52-0.10.2-54.el5.x86_64.rpm

12.   libdc1394_22-2.0.2-11.el5.x86_64.rpm

13.   libxavs1-0.1.51-2.el5.x86_64.rpm

14.   libmp3lame0-3.99.3-23.el5.x86_64.rpm

15.   libxvidcore4-1.2.2-14.el5.x86_64.rpm

16.   libgsm1-1.0.13-2.el5.x86_64.rpm

17.   libavcodec53-0.10.2-54.el5.x86_64.rpm

18.   librtmp0-2.3-1.el5.x86_64.rpm

19.   libavformat53-0.10.2-54.el5.x86_64.rpm

20.   libavfilter2-0.10.2-54.el5.x86_64.rpm

21.   SDL-1.2.14-2rt.x86_64.rpm

22.   libavdevice53-0.10.2-54.el5.x86_64.rpm

23.   ffmpeg-0.10.2-54.el5.x86_64.rpm

*Please check for the latest version of each of the above dependencies

2.       Modify the audio codec and video codec according to the server platform and ffmpeg build used.

             For example for ffmpeg-0.10.2-54.el5.x86_64.rpmto work on RHEL 5.5, audio codec needs to be changed to alac.

Follow the steps below to make the above change:

1.       Go to url http://<server>:<port>/etc/dam/video/hq.html

2.       Click Edit

3.       Go to Audio tab

4.       Set Codec to alac

Video Profile Settings

Tuning ffmpeg for best performance

Media encoding is a CPU intensive process and hence may result in very high CPU usage on server machine. This might result in ffmpeg hogging all the CPU and slowing down of CQ instance.

Limit the number of renditions produced for each video

By default for each video file DAM generates renditions in 3 file formats namely ogg,m4v and flv .You might want to limit the number of renditions depending upon your use case. This can be achieved via following steps.

1.       Go To workflow console http://<server>:<port>/libs/cq/workflow/content/console.html

2.       Edit DAM Update Asset workflow

3.       Double click on workflow step Ffmpeg transcoding

4.       Go to Process tab

5.       Edit arguments to set the required profile. Default value is set to profile:firefoxhq,profile:hq,profile:flv for generating ogg,m4v and flv renditions respectively.

6.       Click OK.

7.       Click Save

The following snapshot shows the setting for limiting rendition to flv.

Limiting Renditions to flv

Limit the number of threads spawned by ffmpeg process

By default, the maximum number of threads spawned by each ffmpeg process is equal to the number of cpu cores available on the server. To limit the number of threads launched by each ffmpeg process, follow the below steps:

1.       Go to url http://<server>:<port>/etc/dam/video/hq.html

2.       Click Edit

3.       Go to Advanced tab under Video Profile Settings

4.       Add argument –threads X in the Custom ffmpeg arguments text box where X is number of threads launched by ffmpeg.

Limiting threads spawn by ffmpeg

*For details on FFmpeg, please refer to