mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-08-14 17:58:27 +00:00
ATS-812: PoC FFmpeg - minor: add extra (internal) check for src/tgt media types
This commit is contained in:
@@ -1,15 +1,16 @@
|
|||||||
# Image provides a container in which to run FFmpeg transformations for Alfresco Content Services.
|
# Image provides a container in which to run FFmpeg transformations
|
||||||
|
|
||||||
# TODO PoC for FFmpeg
|
# TODO PoC for FFmpeg
|
||||||
# The FFmpeg transformer uses FFmpeg. See license: https://github.com/FFmpeg/FFmpeg/blob/master/LICENSE.md
|
# The FFmpeg transformer uses FFmpeg. See license: https://github.com/FFmpeg/FFmpeg/blob/master/LICENSE.md
|
||||||
|
|
||||||
|
# TODO PoC for FFmpeg - "migrate" from CentOS 8 to most recent supported CentoOS 7 (note: may mean using FFmpeg 3.x instead of 4.x)
|
||||||
FROM alfresco/alfresco-base-java:11.0.10-openjdk-centos-8@sha256:343c8f63cf80c7af51785b93d6972b0c00087a1c0b995098cb8285c4d9db74b5
|
FROM alfresco/alfresco-base-java:11.0.10-openjdk-centos-8@sha256:343c8f63cf80c7af51785b93d6972b0c00087a1c0b995098cb8285c4d9db74b5
|
||||||
|
|
||||||
ARG FFMPEG_VERSION=4.2.4
|
|
||||||
|
|
||||||
# TODO PoC for FFmpeg - update & download from Nexus
|
# TODO PoC for FFmpeg - update & download from Nexus
|
||||||
ENV FFMPEG_RPM_URL=https://download1.rpmfusion.org/free/el/updates/8/x86_64/f/ffmpeg-${FFMPEG_VERSION}.el7.x86_64.rpm
|
#ARG FFMPEG_VERSION=4.2.5-2
|
||||||
|
#ENV FFMPEG_RPM_URL=https://download1.rpmfusion.org/free/el/updates/8/x86_64/f/ffmpeg-${FFMPEG_VERSION}.el7.x86_64.rpm
|
||||||
#ENV FFMPEG_LICENSE_FILE=https://github.com/Alfresco/acs-community-packaging/blob/master/distribution/src/main/resources/licenses/3rd-party/TODO-license.txt
|
#ENV FFMPEG_LICENSE_FILE=https://github.com/Alfresco/acs-community-packaging/blob/master/distribution/src/main/resources/licenses/3rd-party/TODO-license.txt
|
||||||
|
|
||||||
ENV JAVA_OPTS=""
|
ENV JAVA_OPTS=""
|
||||||
|
|
||||||
# Set default user information
|
# Set default user information
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Transform Core
|
* Alfresco Transform Core
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2020 Alfresco Software Limited
|
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* -
|
* -
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Transform Core
|
* Alfresco Transform Core
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2020 Alfresco Software Limited
|
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* -
|
* -
|
||||||
@@ -65,6 +65,16 @@ public class FFmpegController extends AbstractTransformerController
|
|||||||
FFmpegController
|
FFmpegController
|
||||||
.class);
|
.class);
|
||||||
|
|
||||||
|
// note: subset from Gytheio
|
||||||
|
|
||||||
|
public static final String PREFIX_AUDIO = "audio/";
|
||||||
|
public static final String PREFIX_IMAGE = "image/";
|
||||||
|
public static final String PREFIX_VIDEO = "video/";
|
||||||
|
|
||||||
|
public static final String MEDIATYPE_IMAGE_SVG = "image/svg+xml";
|
||||||
|
public static final String MEDIATYPE_APPLICATION_PHOTOSHOP = "image/vnd.adobe.photoshop";
|
||||||
|
public static final String MEDIATYPE_IMG_DWG = "image/vnd.dwg";
|
||||||
|
|
||||||
@Value("${transform.core.ffmpeg.exe}")
|
@Value("${transform.core.ffmpeg.exe}")
|
||||||
private String execPath;
|
private String execPath;
|
||||||
|
|
||||||
@@ -115,6 +125,67 @@ public class FFmpegController extends AbstractTransformerController
|
|||||||
public void transformImpl(String transformName, String sourceMimetype, String targetMimetype,
|
public void transformImpl(String transformName, String sourceMimetype, String targetMimetype,
|
||||||
Map<String, String> transformOptions, File sourceFile, File targetFile)
|
Map<String, String> transformOptions, File sourceFile, File targetFile)
|
||||||
{
|
{
|
||||||
|
// note: actual supported transforms are defined by FFmpeg engine config - this is an extra sanity check
|
||||||
|
if (! isTransformable(sourceMimetype, targetMimetype))
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException("Unsupported combinations of source/target media types: "+sourceMimetype+","+targetMimetype);
|
||||||
|
}
|
||||||
|
|
||||||
commandExecutor.transform(sourceMimetype, targetMimetype, transformOptions, sourceFile, targetFile);
|
commandExecutor.transform(sourceMimetype, targetMimetype, transformOptions, sourceFile, targetFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if the source mimetype is supported by ffmpeg
|
||||||
|
*
|
||||||
|
* @param mediaType the mimetype to check
|
||||||
|
* @return Returns true if ffmpeg can handle the given mimetype format
|
||||||
|
*/
|
||||||
|
private static boolean isSupportedSource(String mediaType)
|
||||||
|
{
|
||||||
|
return ((mediaType.startsWith(PREFIX_VIDEO) && !(
|
||||||
|
mediaType.equals("video/x-rad-screenplay") ||
|
||||||
|
mediaType.equals("video/x-sgi-movie") ||
|
||||||
|
mediaType.equals("video/mpeg2"))) ||
|
||||||
|
(mediaType.startsWith(PREFIX_AUDIO) && !(
|
||||||
|
mediaType.equals("audio/vnd.adobe.soundbooth"))) ||
|
||||||
|
mediaType.equals("application/mxf"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if FFmpeg can be made to support the given target mimetype.
|
||||||
|
*
|
||||||
|
* @param mimetype the mimetype to check
|
||||||
|
* @return Returns true if ffmpeg can handle the given mimetype format
|
||||||
|
*/
|
||||||
|
private static boolean isSupportedTarget(String mimetype)
|
||||||
|
{
|
||||||
|
return ((mimetype.startsWith(PREFIX_VIDEO) && !(
|
||||||
|
mimetype.equals("video/x-rad-screenplay") ||
|
||||||
|
mimetype.equals("video/x-sgi-movie") ||
|
||||||
|
mimetype.equals("video/mpeg2"))) ||
|
||||||
|
(mimetype.startsWith(PREFIX_IMAGE) && !(
|
||||||
|
mimetype.equals(MEDIATYPE_IMAGE_SVG) ||
|
||||||
|
mimetype.equals(MEDIATYPE_APPLICATION_PHOTOSHOP) ||
|
||||||
|
mimetype.equals(MEDIATYPE_IMG_DWG) ||
|
||||||
|
mimetype.equals("image/vnd.adobe.premiere") ||
|
||||||
|
mimetype.equals("image/x-portable-anymap") ||
|
||||||
|
mimetype.equals("image/x-xpixmap") ||
|
||||||
|
mimetype.equals("image/x-dwt") ||
|
||||||
|
mimetype.equals("image/cgm") ||
|
||||||
|
mimetype.equals("image/ief"))) ||
|
||||||
|
(mimetype.startsWith(PREFIX_AUDIO) && !(
|
||||||
|
mimetype.equals("audio/vnd.adobe.soundbooth"))));
|
||||||
|
}
|
||||||
|
|
||||||
|
// note: based on Gytheio
|
||||||
|
private boolean isTransformable(String sourceMediaType, String targetMediaType)
|
||||||
|
{
|
||||||
|
if (sourceMediaType.startsWith(PREFIX_AUDIO) &&
|
||||||
|
targetMediaType.startsWith(PREFIX_IMAGE))
|
||||||
|
{
|
||||||
|
// Might be able to support audio to waveform image in the future, but for now...
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return (isSupportedSource(sourceMediaType) && isSupportedTarget(targetMediaType));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -39,7 +39,7 @@ public final class FFmpegOptionsBuilder
|
|||||||
private String timeOffset;
|
private String timeOffset;
|
||||||
private Integer framesNum;
|
private Integer framesNum;
|
||||||
|
|
||||||
// TODO PoC - add FFmpeg options ...
|
// TODO PoC - add other FFmpeg transform options ...
|
||||||
private FFmpegOptionsBuilder() {}
|
private FFmpegOptionsBuilder() {}
|
||||||
|
|
||||||
public FFmpegOptionsBuilder withTimeOffset(final String timeOffset)
|
public FFmpegOptionsBuilder withTimeOffset(final String timeOffset)
|
||||||
|
Reference in New Issue
Block a user