From 186e18757e074f6c2241db7d0caad920ef14b880 Mon Sep 17 00:00:00 2001 From: Jan Vonka Date: Mon, 27 Jul 2020 19:08:55 +0100 Subject: [PATCH] ATS-812: PoC for FFmpeg T-Engine (WIP) - initial folder skeleton - note: PoC only - limited functionality & no tests yet - see also ATS-793 epic --- .../alfresco-transform-ffmpeg-boot/Dockerfile | 49 +++ .../LICENSES.md | 3 + .../alfresco-transform-ffmpeg-boot/pom.xml | 302 ++++++++++++++++++ .../org/alfresco/transformer/Application.java | 77 +++++ .../transformer/FFmpegController.java | 120 +++++++ .../main/resources/application-default.yaml | 8 + .../resources/templates/transformForm.html | 23 ++ .../alfresco-transform-ffmpeg/LICENSES.md | 3 + .../alfresco-transform-ffmpeg/pom.xml | 38 +++ .../transformer/FFmpegOptionsBuilder.java | 53 +++ .../executors/FFmpegCommandExecutor.java | 114 +++++++ .../main/resources/ffmpeg_engine_config.json | 18 ++ pom.xml | 10 + 13 files changed, 818 insertions(+) create mode 100644 alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/Dockerfile create mode 100644 alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/LICENSES.md create mode 100644 alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/pom.xml create mode 100644 alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/src/main/java/org/alfresco/transformer/Application.java create mode 100644 alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/src/main/java/org/alfresco/transformer/FFmpegController.java create mode 100644 alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/src/main/resources/application-default.yaml create mode 100644 alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/src/main/resources/templates/transformForm.html create mode 100644 alfresco-transform-ffmpeg/alfresco-transform-ffmpeg/LICENSES.md create mode 100644 alfresco-transform-ffmpeg/alfresco-transform-ffmpeg/pom.xml create mode 100644 alfresco-transform-ffmpeg/alfresco-transform-ffmpeg/src/main/java/org/alfresco/transformer/FFmpegOptionsBuilder.java create mode 100644 alfresco-transform-ffmpeg/alfresco-transform-ffmpeg/src/main/java/org/alfresco/transformer/executors/FFmpegCommandExecutor.java create mode 100644 alfresco-transform-ffmpeg/alfresco-transform-ffmpeg/src/main/resources/ffmpeg_engine_config.json diff --git a/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/Dockerfile b/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/Dockerfile new file mode 100644 index 00000000..a958b7bb --- /dev/null +++ b/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/Dockerfile @@ -0,0 +1,49 @@ +# Image provides a container in which to run FFmpeg transformations for Alfresco Content Services. + +# TODO PoC for FFmpeg +# The FFmpeg transformer uses FFmpeg. See license: https://github.com/FFmpeg/FFmpeg/blob/master/LICENSE.md + +FROM alfresco/alfresco-base-java:11.0.7-openjdk-centos-7-9448dd21de19 + +ARG FFMPEG_VERSION=3.4.8-1 + +# TODO PoC for FFmpeg - update & download from Nexus +ENV FFMPEG_RPM_URL=https://download1.rpmfusion.org/free/el/updates/7/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 JAVA_OPTS="" + +# Set default user information +ARG GROUPNAME=Alfresco +ARG GROUPID=1000 + +# TODO PoC for FFmpeg - update w3 page with a specific allocated id in sequence (may not be 33099) +ARG FFMPEGUSERNAME=ffmpeg +ARG USERID=33099 + +COPY target/${env.project_artifactId}-${env.project_version}.jar /usr/bin + +RUN ln /usr/bin/${env.project_artifactId}-${env.project_version}.jar /usr/bin/${env.project_artifactId}.jar && \ +# TODO PoC for FFmpeg - see above +# curl -s -S $FFMPEG_RPM_URL -o ffmpeg-distribution-linux.rpm && \ +# curl -s -S $FFMPEG_LICENSE_FILE -o FFmpeg-license.txt && \ + yum install -y epel-release && \ +# yum localinstall -y ffmpeg-distribution-*linux.rpm && \ + yum localinstall -y --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm && \ + yum install -y ffmpeg && \ +# rm -f ffmpeg-distribution-*.rpm && \ + yum clean all + +ADD target/generated-resources/licenses /licenses +ADD target/generated-resources/licenses.xml /licenses/ +ADD target/generated-sources/license/THIRD-PARTY.txt /licenses/ + +RUN groupadd -g ${GROUPID} ${GROUPNAME} && \ + useradd -u ${USERID} -G ${GROUPNAME} ${FFMPEGUSERNAME} && \ + chgrp -R ${GROUPNAME} /usr/bin/${env.project_artifactId}.jar + +EXPOSE 8090 + +USER ${PDFUSERNAME} + +ENTRYPOINT java $JAVA_OPTS -jar /usr/bin/${env.project_artifactId}.jar + diff --git a/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/LICENSES.md b/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/LICENSES.md new file mode 100644 index 00000000..8798e4e3 --- /dev/null +++ b/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/LICENSES.md @@ -0,0 +1,3 @@ +### Licenses + +* TODO - The FFmpeg transformer uses FFmpeg. See license: https://github.com/FFmpeg/FFmpeg/blob/master/LICENSE.md \ No newline at end of file diff --git a/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/pom.xml b/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/pom.xml new file mode 100644 index 00000000..a4bccc61 --- /dev/null +++ b/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/pom.xml @@ -0,0 +1,302 @@ + + + + 4.0.0 + alfresco-transform-ffmpeg-boot + Alfresco Ffmoeg Spring Boot + jar + + + org.alfresco + alfresco-transform-core + 2.3.3-SNAPSHOT + ../../pom.xml + + + + alfresco/alfresco-ffmpeg + quay.io + ${project.artifactId} + + + + + org.alfresco + alfresco-transformer-base + ${project.version} + + + org.alfresco + alfresco-transformer-base + ${project.version} + tests + test-jar + test + + + org.alfresco + alfresco-transform-ffmpeg + ${project.version} + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + org.springframework.boot + spring-boot-starter-test + test + + + com.vaadin.external.google + android-json + + + + + + org.dom4j + dom4j + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + org.codehaus.mojo + license-maven-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + + org.apache.maven.plugins + maven-failsafe-plugin + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + + + test-jar + + + + + + + + + + + docker-it-setup + + + + + io.fabric8 + docker-maven-plugin + + + + activemq + alfresco/alfresco-activemq:5.15.8 + + activemq + + 8161:8161 + 5672:5672 + 61616:61616 + + + Apache ActiveMQ 5.15.8 .* started + + 500 + 100 + + kill 1 + kill -9 1 + + + + + + + alfresco-ffmpeg + ${image.name}:${image.tag} + + + 8090:8090 + + + + http://localhost:8090/transform/config + GET + 200...299 + + + 500 + 100 + + kill 1 + kill -9 1 + + + + + + + + + + + + + local + + + + io.fabric8 + fabric8-maven-plugin + + + + ${image.name}:${image.tag} + + ${project.basedir}/ + + true + + + + + + + + build-image + package + + build + + + + + + + + + + internal + + + + io.fabric8 + fabric8-maven-plugin + + + + + ${image.name}:${image.tag} + ${image.registry} + + ${project.basedir}/ + + true + + + + + + ${image.name}:${image.tag} + + ${project.basedir}/ + + true + + + + + + + + build-image + package + + build + + + + push-image + install + + push + + + + + + + + + + release + + + + io.fabric8 + fabric8-maven-plugin + + + + + ${image.name}:${project.version} + ${image.registry} + + ${project.basedir}/ + + true + + + + + + ${image.name}:${project.version} + + ${project.basedir}/ + + true + + + + + + + + build-push-image + deploy + + build + push + + + + + + + + + diff --git a/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/src/main/java/org/alfresco/transformer/Application.java b/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/src/main/java/org/alfresco/transformer/Application.java new file mode 100644 index 00000000..efbd674a --- /dev/null +++ b/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/src/main/java/org/alfresco/transformer/Application.java @@ -0,0 +1,77 @@ +/* + * #%L + * Alfresco Transform Core + * %% + * Copyright (C) 2005 - 2020 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * 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 . + * #L% + */ +package org.alfresco.transformer; + +import io.micrometer.core.instrument.MeterRegistry; +import org.alfresco.transformer.executors.FFmpegCommandExecutor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.annotation.Bean; +import org.springframework.context.event.EventListener; + +import java.util.Arrays; + +import static org.alfresco.transformer.logging.StandardMessages.LICENCE; + +@SpringBootApplication +@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class}) +public class Application +{ + private static final Logger logger = LoggerFactory.getLogger(Application.class); + + @Value("${container.name}") + private String containerName; + + @Bean + public MeterRegistryCustomizer metricsCommonTags() + { + return registry -> registry.config().commonTags("containerName", containerName); + } + + public static void main(String[] args) + { + SpringApplication.run(Application.class, args); + } + + @EventListener(ApplicationReadyEvent.class) + public void startup() + { + logger.info("-----------------------------------------------------------------------------------------------------------------------------------------------------------"); + Arrays.stream(LICENCE.split("\\n")).forEach(logger::info); + logger.info(FFmpegCommandExecutor.LICENCE); + logger.info("-----------------------------------------------------------------------------------------------------------------------------------------------------------"); + + logger.info("Starting application components... Done"); + } +} diff --git a/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/src/main/java/org/alfresco/transformer/FFmpegController.java b/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/src/main/java/org/alfresco/transformer/FFmpegController.java new file mode 100644 index 00000000..f00a8d2f --- /dev/null +++ b/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/src/main/java/org/alfresco/transformer/FFmpegController.java @@ -0,0 +1,120 @@ +/* + * #%L + * Alfresco Transform Core + * %% + * Copyright (C) 2005 - 2020 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * 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 . + * #L% + */ +package org.alfresco.transformer; + +import org.alfresco.transformer.executors.FFmpegCommandExecutor; +import org.alfresco.transformer.probes.ProbeTestTransform; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Controller; + +import javax.annotation.PostConstruct; +import java.io.File; +import java.util.Collections; +import java.util.Map; + +/** + * Controller for the Docker based FFmpeg transformer. + * + * Status Codes: + * + * 200 Success + * 400 Bad Request: Request parameter is missing (missing mandatory parameter) + * 400 Bad Request: Request parameter is of the wrong type + * 400 Bad Request: Transformer exit code was not 0 (possible problem with the source file) + * 400 Bad Request: The source filename was not supplied + * 500 Internal Server Error: (no message with low level IO problems) + * 500 Internal Server Error: The target filename was not supplied (should not happen as targetExtension is checked) + * 500 Internal Server Error: Transformer version check exit code was not 0 + * 500 Internal Server Error: Transformer version check failed to create any output + * 500 Internal Server Error: Could not read the target file + * 500 Internal Server Error: The target filename was malformed (should not happen because of other checks) + * 500 Internal Server Error: Transformer failed to create an output file (the exit code was 0, so there should be some content) + * 500 Internal Server Error: Filename encoding error + * 507 Insufficient Storage: Failed to store the source file + */ +@Controller +public class FFmpegController extends AbstractTransformerController +{ + private static final Logger logger = LoggerFactory.getLogger( + FFmpegController + .class); + + @Value("${transform.core.ffmpeg.exe}") + private String execPath; + + FFmpegCommandExecutor commandExecutor; + + @PostConstruct + private void init() + { + commandExecutor = new FFmpegCommandExecutor(execPath); + } + + @Override + public String getTransformerName() + { + return "FFmpeg"; + } + + @Override + public String version() + { + return commandExecutor.version(); + } + + @Override + public ProbeTestTransform getProbeTestTransform() + { + // See the Javadoc on this method and Probes.md for the choice of these values. + // TODO PoC for FFmpeg + return new ProbeTestTransform(this, "quick.mp4", "quick.mp3", + 7455, 1024, 150, 10240, 60 * 20 + 1, 60 * 15 - 15) + { + @Override + protected void executeTransformCommand(File sourceFile, File targetFile) + { + transformImpl(null, null, null, Collections.emptyMap(), sourceFile, targetFile); + } + }; + } + + @Override + protected String getTransformerName(final File sourceFile, final String sourceMimetype, + final String targetMimetype, final Map transformOptions) + { + return null; // does not matter what value is returned, as it is not used because there is only one. + } + + @Override + public void transformImpl(String transformName, String sourceMimetype, String targetMimetype, + Map transformOptions, File sourceFile, File targetFile) + { + commandExecutor.transform(sourceMimetype, targetMimetype, transformOptions, sourceFile, targetFile); + } +} diff --git a/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/src/main/resources/application-default.yaml b/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/src/main/resources/application-default.yaml new file mode 100644 index 00000000..289e6f41 --- /dev/null +++ b/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/src/main/resources/application-default.yaml @@ -0,0 +1,8 @@ +queue: + engineRequestQueue: ${TRANSFORM_ENGINE_REQUEST_QUEUE:org.alfresco.transform.engine.ffmpeg.acs} +transform: + core: + config: + location: classpath:ffmpeg_engine_config.json + ffmpeg: + exe: ${FFMPEG_EXE:/usr/bin/ffmpeg} \ No newline at end of file diff --git a/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/src/main/resources/templates/transformForm.html b/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/src/main/resources/templates/transformForm.html new file mode 100644 index 00000000..1151be1e --- /dev/null +++ b/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot/src/main/resources/templates/transformForm.html @@ -0,0 +1,23 @@ + + + +
+

Alfresco FFmpeg Test Transformation

+
+ + + + + + + +
file *
targetExtension *
timeout
testDelay
+
+
+ + + + + diff --git a/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg/LICENSES.md b/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg/LICENSES.md new file mode 100644 index 00000000..8798e4e3 --- /dev/null +++ b/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg/LICENSES.md @@ -0,0 +1,3 @@ +### Licenses + +* TODO - The FFmpeg transformer uses FFmpeg. See license: https://github.com/FFmpeg/FFmpeg/blob/master/LICENSE.md \ No newline at end of file diff --git a/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg/pom.xml b/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg/pom.xml new file mode 100644 index 00000000..a80073cf --- /dev/null +++ b/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg/pom.xml @@ -0,0 +1,38 @@ + + 4.0.0 + alfresco-transform-ffmpeg + Alfresco FFmpeg Transformer + jar + + + org.alfresco + alfresco-transform-core + 2.3.3-SNAPSHOT + ../../pom.xml + + + + + org.alfresco + alfresco-transformer-base + ${project.version} + + + + + + + org.codehaus.mojo + license-maven-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + + org.apache.maven.plugins + maven-failsafe-plugin + + + + diff --git a/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg/src/main/java/org/alfresco/transformer/FFmpegOptionsBuilder.java b/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg/src/main/java/org/alfresco/transformer/FFmpegOptionsBuilder.java new file mode 100644 index 00000000..e06ce878 --- /dev/null +++ b/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg/src/main/java/org/alfresco/transformer/FFmpegOptionsBuilder.java @@ -0,0 +1,53 @@ +/* + * #%L + * Alfresco Transform Core + * %% + * Copyright (C) 2005 - 2020 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * 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 . + * #L% + */ +package org.alfresco.transformer; + +import java.util.StringJoiner; + +/** + * FFmpeg options builder. + * + * @author janv + */ +// TODO PoC for FFmpeg +public final class FFmpegOptionsBuilder +{ + // TODO PoC - add FFmpeg options ... + private FFmpegOptionsBuilder() {} + + public String build() + { + StringJoiner args = new StringJoiner(" "); + + return args.toString(); + } + + public static FFmpegOptionsBuilder builder() + { + return new FFmpegOptionsBuilder(); + } +} diff --git a/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg/src/main/java/org/alfresco/transformer/executors/FFmpegCommandExecutor.java b/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg/src/main/java/org/alfresco/transformer/executors/FFmpegCommandExecutor.java new file mode 100644 index 00000000..3dcaffb4 --- /dev/null +++ b/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg/src/main/java/org/alfresco/transformer/executors/FFmpegCommandExecutor.java @@ -0,0 +1,114 @@ +/* + * #%L + * Alfresco Transform Core + * %% + * Copyright (C) 2005 - 2020 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * 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 . + * #L% + */ +package org.alfresco.transformer.executors; + +import org.alfresco.transform.exceptions.TransformException; +import org.alfresco.transformer.FFmpegOptionsBuilder; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; + +import static org.alfresco.transformer.util.RequestParamMap.TIMEOUT; +import static org.alfresco.transformer.util.Util.stringToLong; + +/** + * CommandExecutor implementation for running FFmpeg transformations. It runs the + * transformation logic as a separate Shell process. + */ +// TODO PoC for FFmpeg +public class FFmpegCommandExecutor extends AbstractCommandExecutor +{ + private static String ID = "ffmpeg"; + + // TODO PoC for FFmpeg + public static final String LICENCE = "TODO: This transformer uses Ffmpeg. See the license at ..."; + + private final String EXE; + + public FFmpegCommandExecutor(String exe) + { + if (exe == null || exe.isEmpty()) + { + throw new IllegalArgumentException("FfmpegCommandExecutor EXE variable cannot be null or empty"); + } + this.EXE = exe; + super.transformCommand = createTransformCommand(); + super.checkCommand = createCheckCommand(); + } + + @Override + public String getTransformerId() + { + return ID; + } + + @Override + protected RuntimeExec createTransformCommand() + { + RuntimeExec runtimeExec = new RuntimeExec(); + Map commandsAndArguments = new HashMap<>(); + + // TODO PoC for FFmpeg - check against Gytheio: -y SPLIT:${sourceOptions} -i ${source} SPLIT:${targetOptions} ${target} + commandsAndArguments.put(".*", + new String[]{EXE, "-y", "-i", "SPLIT:${options}", "${source}", "${target}"}); + + runtimeExec.setCommandsAndArguments(commandsAndArguments); + + Map defaultProperties = new HashMap<>(); + defaultProperties.put("key", null); + runtimeExec.setDefaultProperties(defaultProperties); + + runtimeExec.setErrorCodes("1"); + + return runtimeExec; + } + + @Override + protected RuntimeExec createCheckCommand() + { + RuntimeExec runtimeExec = new RuntimeExec(); + Map commandsAndArguments = new HashMap<>(); + commandsAndArguments.put(".*", new String[]{EXE, "--version"}); + runtimeExec.setCommandsAndArguments(commandsAndArguments); + return runtimeExec; + } + + @Override + public void transform(String transformName, String sourceMimetype, String targetMimetype, + Map transformOptions, + File sourceFile, File targetFile) throws TransformException + { + final String options = FFmpegOptionsBuilder + .builder() + .build(); + + Long timeout = stringToLong(transformOptions.get(TIMEOUT)); + + run(options, sourceFile, targetFile, timeout); + } +} diff --git a/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg/src/main/resources/ffmpeg_engine_config.json b/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg/src/main/resources/ffmpeg_engine_config.json new file mode 100644 index 00000000..1d1cec34 --- /dev/null +++ b/alfresco-transform-ffmpeg/alfresco-transform-ffmpeg/src/main/resources/ffmpeg_engine_config.json @@ -0,0 +1,18 @@ +{ + "transformOptions": { + "ffmpegOptions": [ + ] + }, + "transformers": [ + { + "transformerName": "ffmpeg", + "supportedSourceAndTargetList": [ + {"sourceMediaType": "video/mp4", "targetMediaType": "video/avi" }, + {"sourceMediaType": "video/mp4", "targetMediaType": "audio/mp3" } + ], + "transformOptions": [ + "ffmpegOptions" + ] + } + ] +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index e4ef83cb..60d3ed02 100644 --- a/pom.xml +++ b/pom.xml @@ -45,6 +45,8 @@ alfresco-transformer-base alfresco-transform-imagemagick/alfresco-transform-imagemagick alfresco-transform-imagemagick/alfresco-transform-imagemagick-boot + alfresco-transform-ffmpeg/alfresco-transform-ffmpeg + alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot alfresco-transform-libreoffice/alfresco-transform-libreoffice alfresco-transform-libreoffice/alfresco-transform-libreoffice-boot alfresco-transform-misc/alfresco-transform-misc @@ -71,6 +73,14 @@ alfresco-transform-imagemagick/alfresco-transform-imagemagick-boot + + ffmpeg + + alfresco-transformer-base + alfresco-transform-ffmpeg/alfresco-transform-ffmpeg + alfresco-transform-ffmpeg/alfresco-transform-ffmpeg-boot + + libreoffice