From 98ba89bed790892bcf11baa5040284155fe6e0b8 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Fri, 1 Oct 2010 15:13:53 +0000 Subject: [PATCH] Provide example context files for using FFMPEG to provide video -> flv transformations, and video thumbnailing using FFMPEG These are based on the ones used on partners.alfresco.com, but slightly cleaned up Also includes a slightly nicer way to register thumbnail definitions to the thumbnail registry from spring. (A proper fix is detailed in ALF-5051, but that will require a config file tweak) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22817 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../video-thumbnail-context.xml.sample | 245 ++++++++++++ .../video-transformation-context.xml.sample | 376 ++++++++++++++++++ .../ThumbnailDefinitionSpringRegisterer.java | 62 +++ 3 files changed, 683 insertions(+) create mode 100644 config/alfresco/extension/video-thumbnail-context.xml.sample create mode 100644 config/alfresco/extension/video-transformation-context.xml.sample create mode 100644 source/java/org/alfresco/repo/thumbnail/ThumbnailDefinitionSpringRegisterer.java diff --git a/config/alfresco/extension/video-thumbnail-context.xml.sample b/config/alfresco/extension/video-thumbnail-context.xml.sample new file mode 100644 index 0000000000..9f3d04f3f6 --- /dev/null +++ b/config/alfresco/extension/video-thumbnail-context.xml.sample @@ -0,0 +1,245 @@ + + + + + + + + + + + + + + + + + + + + ${ffmpeg.exe} + -version + + + + + + + + + + + cmd + /C + ${ffmpeg.exe} ${opts} ${infile_opts} -i "${source}" ${outfile_opts} "${target}" 2> NUL + + + + + sh + -c + ${ffmpeg.exe} ${opts} ${infile_opts} -i '${source}' ${outfile_opts} '${target}' 2> /dev/null + + + + + + true + + + + -y + -ss 10 + -f image2 -vframes 1 + + + + + + + + + video/x-flv + + + image/jpeg + + + + + video/mpeg + + + image/jpeg + + + + + video/mp4 + + + image/jpeg + + + + + video/mpeg2 + + + image/jpeg + + + + + video/x-sgi-movie + + + image/jpeg + + + + + video/x-msvideo + + + image/jpeg + + + + + video/quicktime + + + image/jpeg + + + + + video/x-ms-asf + + + image/jpeg + + + + + video/x-ms-wmv + + + image/jpeg + + + + + video/x-rad-screenplay + + + image/jpeg + + + + + video/ogg + + + image/jpeg + + + + + + + + + + + + + + + + + + + + + + + + + image/jpeg + + + + + + + + + + + + + + + + + + + -f flv -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 + + + + + + + + + + + + + + + + + + + + + + -f mp4 -ar 44100 -ab 96k -vcodec libx264 -crf 25 -g 250 -r 25 + medium + + + + + + + + + + + + + + + + + + + + + -f mp3 -ar 44100 -ab 128k + + + + + + + + + + diff --git a/config/alfresco/extension/video-transformation-context.xml.sample b/config/alfresco/extension/video-transformation-context.xml.sample new file mode 100644 index 0000000000..9357a224d1 --- /dev/null +++ b/config/alfresco/extension/video-transformation-context.xml.sample @@ -0,0 +1,376 @@ + + + + + + + + + + + + + + + + + + + + + ${ffmpeg.exe} + -version + + + + + + + + + + + cmd + /C + ${ffmpeg.exe} ${opts} ${infile_opts} -i "${source}" ${outfile_opts} "${target}" 2> NUL + + + + + sh + -c + ${ffmpeg.exe} ${opts} ${infile_opts} -i '${source}' ${outfile_opts} '${target}' 2> /dev/null + + + + + + true + + + + -y + + -f flv + + + + + + + + + + + video/mpeg + + + video/x-flv + + + + + video/mp4 + + + video/x-flv + + + + + video/mpeg2 + + + video/x-flv + + + + + video/x-sgi-movie + + + video/x-flv + + + + + video/x-msvideo + + + video/x-flv + + + + + video/quicktime + + + video/x-flv + + + + + video/x-ms-asf + + + video/x-flv + + + + + video/x-ms-wmv + + + video/x-flv + + + + + video/x-rad-screenplay + + + video/x-flv + + + + + video/ogg + + + video/x-flv + + + + + + + + + + + + + + + + ${ffmpeg.exe} + -version + + + + + + + + + + + cmd + /C + + ${ffmpeg.exe} ${opts} ${infile_opts} -i "${source}" ${outfile_opts} -fpre "${ffmpeg.base}\share\ffmpeg\libx264-${vpre}.ffpreset" "${target}" 2> NUL + + + + + sh + -c + ${ffmpeg.exe} ${opts} ${infile_opts} -i '${source}' ${outfile_opts} -vpre ${vpre} '${target}' 2> /dev/null + + + + + + true + + + + -y + + -f mp4 -ar 44100 -ab 96k -vcodec libx264 -crf 25 -g 250 -r 25 + medium + + + + + + + + + + + video/mpeg + + + video/mp4 + + + + + video/mpeg2 + + + video/mp4 + + + + + video/x-sgi-movie + + + video/mp4 + + + + + video/x-msvideo + + + video/mp4 + + + + + video/quicktime + + + video/mp4 + + + + + video/x-ms-asf + + + video/mp4 + + + + + video/x-ms-wmv + + + video/mp4 + + + + + video/x-rad-screenplay + + + video/mp4 + + + + + video/ogg + + + video/mp4 + + + + + + + + + + + + + + + + ${ffmpeg.exe} + -version + + + + + + + + + + + cmd + /C + ${ffmpeg.exe} ${opts} ${infile_opts} -i "${source}" ${outfile_opts} "${target}" 2> NUL + + + + + sh + -c + ${ffmpeg.exe} ${opts} ${infile_opts} -i '${source}' ${outfile_opts} '${target}' 2> /dev/null + + + + + + true + + + + -y + + -f mp3 + + + + + + + + + + audio/x-aiff + + + audio/x-mpeg + + + + + audio/basic + + + audio/x-mpeg + + + + + audio/x-wav + + + audio/x-mpeg + + + + + audio/ogg + + + audio/x-mpeg + + + + + + + + + + + + + + + + + + + + + diff --git a/source/java/org/alfresco/repo/thumbnail/ThumbnailDefinitionSpringRegisterer.java b/source/java/org/alfresco/repo/thumbnail/ThumbnailDefinitionSpringRegisterer.java new file mode 100644 index 0000000000..ec32783b40 --- /dev/null +++ b/source/java/org/alfresco/repo/thumbnail/ThumbnailDefinitionSpringRegisterer.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2005-2010 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.thumbnail; + +import org.alfresco.service.cmr.repository.TransformationOptions; +import org.springframework.beans.factory.InitializingBean; + +/** + * This class provides a way to register a new {@link ThumbnailDefinition} + * with the {@link ThumbnailRegistry} in spring, without needing to + * override the whole of the "thumbnailRegistry" bean. + * This class is a stop-gap until Alfresco 4.0, when ThumbnailDefinitions + * will be able to be registered more cleanly with the registry in + * the same way as other Alfresco beans to their registrys. + * + * @author Nick Burch + */ +public class ThumbnailDefinitionSpringRegisterer implements InitializingBean +{ + private ThumbnailRegistry thumbnailRegistry; + private ThumbnailDefinition thumbnailDefinition; + + /** + * Registers the {@link ThumbnailDefinition} with the + * registry. + */ + @Override + public void afterPropertiesSet() + { + if(thumbnailDefinition == null || thumbnailRegistry == null) + { + throw new IllegalArgumentException("Must specify both a thumbnailRegistry AND a thumbnailDefinition"); + } + thumbnailRegistry.addThumbnailDefinition(thumbnailDefinition); + } + + public void setThumbnailRegistry(ThumbnailRegistry thumbnailRegistry) + { + this.thumbnailRegistry = thumbnailRegistry; + } + + public void setThumbnailDefinition(ThumbnailDefinition thumbnailDefinition) + { + this.thumbnailDefinition = thumbnailDefinition; + } +}