For a project, I had to find how to generate thumbnails in Alfresco. My constraint was that it had to be implemented in 4.1.x and I remembered that there was something provided in Alfresco 4.2.x. I checked the ZIP of the installation file of Alfresco 4.2.x and I discovered 2 interesting files in the folder /web-server/shared/classes/alfresco/extension:
- video-thumbnail-context.xml.sample: in charge of generating JPEG images from differents formats including avi, flv, mov, mp4...
- video-transformation-context.xml.sample: in charge of transforming videos between formats.
The first file was really interesting for me, so I just renamed this file to video-thumbnail-context.xml and moved it to the shared folder of my tomcat instance (shared/classes/alfresco/extension). I had to add some information to my alfresco-global.properties file:
ffmpeg.exe=[PATH TO THE EXE OF FFMPEG] 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
I restarted my Alfresco and I uploaded some FLV and MOV files and here is what I get in the document library:
Now, the next thing is to implement the same thing in Alfresco 4.1.x. So, I decided to copy video-thumbnail-context.xml to my Alfresco 4.1.x installation. I just modified a little bit this file. In Alfresco 4.2.x, you have to define supported transformations in a property file (it was the last lines that we added previously). But, previously, it had to be defined at the bean Spring level. First, I just kept these beans:
And I updated the bean transformer.worker.ffmpeg.thumbnail to define explicit transformations. Because I'm only interested by MOV and FLV movies, I added this property:
<property name="explicitTransformations"> <list> <bean class="org.alfresco.repo.content.transform.ExplictTransformationDetails"> <property name="sourceMimetype"> <value>video/quicktime</value> </property> <property name="targetMimetype"> <value>image/jpeg</value> </property> </bean> <bean class="org.alfresco.repo.content.transform.ExplictTransformationDetails"> <property name="sourceMimetype"> <value>video/x-flv</value> </property> <property name="targetMimetype"> <value>image/jpeg</value> </property> </bean> </list> </property>
And I updated as well my alfresco-global.properties to define the executable of ffmpeg:
ffmpeg.exe=[PATH TO THE EXE OF FFMPEG]
I just restarted my instance and I can get video thumbnails in Alfresco 4.1.x:
Because it's defined as a transformation, I can as well extract images from videos. And I had potentially to find a solution to generate more than one thumbnail using different size. Using the rendition service and this transformer, I can just generate different thumbnails from my videos. The only annoying stuff is that the image extracted from the video is always at 10 seconds. But, you can just modify that updating the bean file in this line <prop key="infile_opts">-ss 10</prop>.