Class TimelinePreviewsServiceImpl

java.lang.Object
org.opencastproject.job.api.AbstractJobProducer
org.opencastproject.timelinepreviews.ffmpeg.TimelinePreviewsServiceImpl
All Implemented Interfaces:
org.opencastproject.job.api.JobProducer, org.opencastproject.timelinepreviews.api.TimelinePreviewsService, org.osgi.service.cm.ManagedService

public class TimelinePreviewsServiceImpl extends org.opencastproject.job.api.AbstractJobProducer implements org.opencastproject.timelinepreviews.api.TimelinePreviewsService, org.osgi.service.cm.ManagedService
Media analysis plugin that takes a video stream and generates preview images that can be shown on the timeline. This will be done using FFmpeg.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static enum 
    List of available operations on jobs
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected String
    Path to the executable
    static final String
    Resulting collection in the working file repository
    static final String
    Default value for the mimetype of the generated image
    static final String
    Default value for the format of the output image file
    static final int
    Default value for the horizontal resolution
    static final int
    Default value for the vertical resolution
    static final float
    The default job load of a timeline previews job
    static final String
    The key to look for in the service configuration file to override the DEFAULT_FFMPEG_BINARY
    static final String
    The default path to the FFmpeg binary
    protected static final org.slf4j.Logger
    The logging facility
    protected String
    The mimetype that will be set for the generated Attachment containing the timeline previews image
    static final String
    Name of the constant used to retrieve the mimetype
    static final String
    Name of the constant used to retrieve the output file format
    static final String
    Name of the constant used to retrieve the horizontal resolution
    static final String
    Name of the constant used to retrieve the vertical resolution
    protected org.opencastproject.security.api.OrganizationDirectoryService
    The organization directory service
    protected String
    The file format of the generated preview images file
    protected int
    The horizontal resolution of a single preview image
    protected int
    The vertical resolution of a single preview image
    protected org.opencastproject.security.api.SecurityService
    The security service
    protected org.opencastproject.serviceregistry.api.ServiceRegistry
    Reference to the receipt service
    static final String
    The key to look for in the service configuration file to override the DEFAULT_TIMELINEPREVIEWS_JOB_LOAD
    protected org.opencastproject.security.api.UserDirectoryService
    The user directory service
    protected org.opencastproject.workspace.api.Workspace
    The workspace to use when retrieving remote media files

    Fields inherited from class org.opencastproject.job.api.AbstractJobProducer

    ACCEPT_JOB_LOADS_EXCEEDING_PROPERTY, acceptJobLoadsExeedingMaxLoad, DEFAULT_ACCEPT_JOB_LOADS_EXCEEDING, executor, jobType

    Fields inherited from interface org.opencastproject.timelinepreviews.api.TimelinePreviewsService

    JOB_TYPE
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance of the timeline previews service.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    activate(org.osgi.service.component.ComponentContext cc)
     
    protected org.opencastproject.mediapackage.Attachment
    createPreviewsFFmpeg(org.opencastproject.mediapackage.Track track, double seconds, int width, int height, int tileX, int tileY, double duration)
    Executes the FFmpeg command to generate a timeline previews image
    org.opencastproject.job.api.Job
    createTimelinePreviewImages(org.opencastproject.mediapackage.Track track, int imageCount)
     
    protected org.opencastproject.mediapackage.Attachment
    generatePreviewImages(org.opencastproject.job.api.Job job, org.opencastproject.mediapackage.Track track, int imageCount)
    Starts generation of timeline preview images for the given video track and returns an attachment containing one image that contains all the timeline preview images.
    protected org.opencastproject.security.api.OrganizationDirectoryService
    protected org.opencastproject.security.api.SecurityService
    protected org.opencastproject.serviceregistry.api.ServiceRegistry
    protected org.opencastproject.security.api.UserDirectoryService
    protected String
    process(org.opencastproject.job.api.Job job)
    void
    setOrganizationDirectoryService(org.opencastproject.security.api.OrganizationDirectoryService organizationDirectory)
    Sets a reference to the organization directory service.
    void
    setSecurityService(org.opencastproject.security.api.SecurityService securityService)
    Callback for setting the security service.
    protected void
    setServiceRegistry(org.opencastproject.serviceregistry.api.ServiceRegistry serviceRegistry)
    Sets the receipt service
    void
    setUserDirectoryService(org.opencastproject.security.api.UserDirectoryService userDirectoryService)
    Callback for setting the user directory service.
    protected void
    setWorkspace(org.opencastproject.workspace.api.Workspace workspace)
    Sets the workspace
    void
    updated(Dictionary<String,?> properties)

    Methods inherited from class org.opencastproject.job.api.AbstractJobProducer

    acceptJob, countJobs, finallyUpdateJob, getJobType, incident, isReadyToAccept, isReadyToAcceptJobs

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • COLLECTION_ID

      public static final String COLLECTION_ID
      Resulting collection in the working file repository
      See Also:
    • binary

      protected String binary
      Path to the executable
    • FFMPEG_BINARY_CONFIG

      public static final String FFMPEG_BINARY_CONFIG
      The key to look for in the service configuration file to override the DEFAULT_FFMPEG_BINARY
      See Also:
    • FFMPEG_BINARY_DEFAULT

      public static final String FFMPEG_BINARY_DEFAULT
      The default path to the FFmpeg binary
      See Also:
    • OPT_RESOLUTION_X

      public static final String OPT_RESOLUTION_X
      Name of the constant used to retrieve the horizontal resolution
      See Also:
    • DEFAULT_RESOLUTION_X

      public static final int DEFAULT_RESOLUTION_X
      Default value for the horizontal resolution
      See Also:
    • OPT_RESOLUTION_Y

      public static final String OPT_RESOLUTION_Y
      Name of the constant used to retrieve the vertical resolution
      See Also:
    • DEFAULT_RESOLUTION_Y

      public static final int DEFAULT_RESOLUTION_Y
      Default value for the vertical resolution
      See Also:
    • OPT_OUTPUT_FORMAT

      public static final String OPT_OUTPUT_FORMAT
      Name of the constant used to retrieve the output file format
      See Also:
    • DEFAULT_OUTPUT_FORMAT

      public static final String DEFAULT_OUTPUT_FORMAT
      Default value for the format of the output image file
      See Also:
    • OPT_MIMETYPE

      public static final String OPT_MIMETYPE
      Name of the constant used to retrieve the mimetype
      See Also:
    • DEFAULT_MIMETYPE

      public static final String DEFAULT_MIMETYPE
      Default value for the mimetype of the generated image
      See Also:
    • DEFAULT_TIMELINEPREVIEWS_JOB_LOAD

      public static final float DEFAULT_TIMELINEPREVIEWS_JOB_LOAD
      The default job load of a timeline previews job
      See Also:
    • TIMELINEPREVIEWS_JOB_LOAD_KEY

      public static final String TIMELINEPREVIEWS_JOB_LOAD_KEY
      The key to look for in the service configuration file to override the DEFAULT_TIMELINEPREVIEWS_JOB_LOAD
      See Also:
    • logger

      protected static final org.slf4j.Logger logger
      The logging facility
    • resolutionX

      protected int resolutionX
      The horizontal resolution of a single preview image
    • resolutionY

      protected int resolutionY
      The vertical resolution of a single preview image
    • outputFormat

      protected String outputFormat
      The file format of the generated preview images file
    • mimetype

      protected String mimetype
      The mimetype that will be set for the generated Attachment containing the timeline previews image
    • serviceRegistry

      protected org.opencastproject.serviceregistry.api.ServiceRegistry serviceRegistry
      Reference to the receipt service
    • workspace

      protected org.opencastproject.workspace.api.Workspace workspace
      The workspace to use when retrieving remote media files
    • securityService

      protected org.opencastproject.security.api.SecurityService securityService
      The security service
    • userDirectoryService

      protected org.opencastproject.security.api.UserDirectoryService userDirectoryService
      The user directory service
    • organizationDirectoryService

      protected org.opencastproject.security.api.OrganizationDirectoryService organizationDirectoryService
      The organization directory service
  • Constructor Details

    • TimelinePreviewsServiceImpl

      public TimelinePreviewsServiceImpl()
      Creates a new instance of the timeline previews service.
  • Method Details

    • activate

      public void activate(org.osgi.service.component.ComponentContext cc)
      Overrides:
      activate in class org.opencastproject.job.api.AbstractJobProducer
    • updated

      public void updated(Dictionary<String,?> properties) throws org.osgi.service.cm.ConfigurationException
      Specified by:
      updated in interface org.osgi.service.cm.ManagedService
      Throws:
      org.osgi.service.cm.ConfigurationException
      See Also:
      • ManagedService.updated(java.util.Dictionary)
    • createTimelinePreviewImages

      public org.opencastproject.job.api.Job createTimelinePreviewImages(org.opencastproject.mediapackage.Track track, int imageCount) throws org.opencastproject.timelinepreviews.api.TimelinePreviewsException, org.opencastproject.mediapackage.MediaPackageException
      Specified by:
      createTimelinePreviewImages in interface org.opencastproject.timelinepreviews.api.TimelinePreviewsService
      Throws:
      org.opencastproject.timelinepreviews.api.TimelinePreviewsException
      org.opencastproject.mediapackage.MediaPackageException
    • generatePreviewImages

      protected org.opencastproject.mediapackage.Attachment generatePreviewImages(org.opencastproject.job.api.Job job, org.opencastproject.mediapackage.Track track, int imageCount) throws org.opencastproject.timelinepreviews.api.TimelinePreviewsException, org.opencastproject.mediapackage.MediaPackageException
      Starts generation of timeline preview images for the given video track and returns an attachment containing one image that contains all the timeline preview images.
      Parameters:
      job -
      track - the element to analyze
      imageCount - number of preview images that will be generated
      Returns:
      an attachment containing the resulting timeline previews image
      Throws:
      org.opencastproject.timelinepreviews.api.TimelinePreviewsException
      org.opencastproject.mediapackage.MediaPackageException
    • process

      protected String process(org.opencastproject.job.api.Job job) throws Exception
      Specified by:
      process in class org.opencastproject.job.api.AbstractJobProducer
      Throws:
      Exception
      See Also:
      • AbstractJobProducer.process(org.opencastproject.job.api.Job)
    • createPreviewsFFmpeg

      protected org.opencastproject.mediapackage.Attachment createPreviewsFFmpeg(org.opencastproject.mediapackage.Track track, double seconds, int width, int height, int tileX, int tileY, double duration) throws org.opencastproject.timelinepreviews.api.TimelinePreviewsException
      Executes the FFmpeg command to generate a timeline previews image
      Parameters:
      track - the track to generate the timeline previews image for
      seconds - the length of a segment that one preview image should represent
      width - the width of a single preview image
      height - the height of a single preview image
      tileX - the horizontal number of preview images that are stored in the timeline previews image
      tileY - the vertical number of preview images that are stored in the timeline previews image
      duration - the duration for which preview images should be generated
      Returns:
      an attachment containing the timeline previews image
      Throws:
      org.opencastproject.timelinepreviews.api.TimelinePreviewsException
    • setWorkspace

      protected void setWorkspace(org.opencastproject.workspace.api.Workspace workspace)
      Sets the workspace
      Parameters:
      workspace - an instance of the workspace
    • setServiceRegistry

      protected void setServiceRegistry(org.opencastproject.serviceregistry.api.ServiceRegistry serviceRegistry)
      Sets the receipt service
      Parameters:
      serviceRegistry - the service registry
    • getServiceRegistry

      protected org.opencastproject.serviceregistry.api.ServiceRegistry getServiceRegistry()
      Specified by:
      getServiceRegistry in class org.opencastproject.job.api.AbstractJobProducer
      See Also:
      • AbstractJobProducer.getServiceRegistry()
    • setSecurityService

      public void setSecurityService(org.opencastproject.security.api.SecurityService securityService)
      Callback for setting the security service.
      Parameters:
      securityService - the securityService to set
    • setUserDirectoryService

      public void setUserDirectoryService(org.opencastproject.security.api.UserDirectoryService userDirectoryService)
      Callback for setting the user directory service.
      Parameters:
      userDirectoryService - the userDirectoryService to set
    • setOrganizationDirectoryService

      public void setOrganizationDirectoryService(org.opencastproject.security.api.OrganizationDirectoryService organizationDirectory)
      Sets a reference to the organization directory service.
      Parameters:
      organizationDirectory - the organization directory
    • getSecurityService

      protected org.opencastproject.security.api.SecurityService getSecurityService()
      Specified by:
      getSecurityService in class org.opencastproject.job.api.AbstractJobProducer
      See Also:
      • AbstractJobProducer.getSecurityService()
    • getUserDirectoryService

      protected org.opencastproject.security.api.UserDirectoryService getUserDirectoryService()
      Specified by:
      getUserDirectoryService in class org.opencastproject.job.api.AbstractJobProducer
      See Also:
      • AbstractJobProducer.getUserDirectoryService()
    • getOrganizationDirectoryService

      protected org.opencastproject.security.api.OrganizationDirectoryService getOrganizationDirectoryService()
      Specified by:
      getOrganizationDirectoryService in class org.opencastproject.job.api.AbstractJobProducer
      See Also:
      • AbstractJobProducer.getOrganizationDirectoryService()