001/*
002 * (C) Copyright 2016 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Ricardo Dias
018 */
019package org.nuxeo.ecm.platform.video.tools;
020
021import org.nuxeo.ecm.core.api.Blob;
022import java.util.List;
023
024/**
025 * Service that allows the execution of different operations in video blobs through the execution of {@link VideoTool}.
026 *
027 * @since 8.4
028 */
029public interface VideoToolsService {
030
031    /**
032     * Extracts the closed captions from a video blob.
033     *
034     * @param video the input blob
035     * @param outputFormat the outformat of the captions (srt, txt, ttxt is the default)
036     * @param startAt the start time in format "xx:xx"
037     * @param endAt the end time in format "xx:xx"
038     * @return the closed captions if any were found
039     */
040    Blob extractClosedCaptions(Blob video, String outputFormat, String startAt, String endAt);
041
042    /**
043     * Concat the input video blobs into a single video blob.
044     *
045     * @return video blob with the videos concatenated
046     */
047    Blob concat(List<Blob> videos);
048
049    /**
050     * Slices a video blob from a start time and the input duration.
051     * If start it empty, the blob will be sliced in n-parts with similar duration.
052     * If duration is empty, the video blob will be sliced from startAt until the end.
053     *
054     * @param video the input blob
055     * @param startAt the start time in "xx:xx" format
056     * @param duration the duration of the sliced blob in seconds
057     * @param encode option to re-encode the ouptut video blob
058     * @return video blobs generated by the slicer
059     */
060    List<Blob> slice(Blob video, String startAt, String duration, boolean encode);
061
062    /**
063     * Add a watermark to a video blob.
064     *
065     * @param video the input blob
066     * @param picture the picture blob to be used as the watermark
067     * @param x the x offset starting from the left
068     * @param y the y offset starting from the top
069     * @return a video blob with a watermark at the position specified
070     */
071    Blob watermark(Blob video, Blob picture, String x, String y);
072
073    /**
074     * Checks if a determined tool is available.
075     *
076     * @param toolName the name of the tool
077     * @return true if the tool is available or false otherwise
078     */
079    boolean isToolAvailable(String toolName);
080}