Class EncodingAttributes

  • All Implemented Interfaces:
    java.io.Serializable

    public class EncodingAttributes
    extends java.lang.Object
    implements java.io.Serializable
    Attributes controlling the encoding process.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private AudioAttributes audioAttributes
      The attributes for the encoding of the audio stream in the target multimedia file.
      private java.lang.Integer decodingThreads
      Number of threads to use for decoding (if supported by codec)
      private java.lang.Float duration
      The duration (seconds) of the re-encoded stream.
      private java.lang.Integer encodingThreads
      Number of threads to use for encoding (if supported by codec)
      private java.util.HashMap<java.lang.String,​java.lang.String> extraContext
      Additional context for custom encoder options.
      private java.lang.Integer filterThreads
      Maximum number of cores/cpus to use for conversion.
      Not set means we use ffmpeg's default.
      private java.lang.String inputFormat
      The format name for the incoming multimedia file.
      private boolean loop
      Should the input be treated as a loop
      private boolean mapMetaData
      Should we try to copy over the meta data?
      private java.lang.Float offset
      The start offset time (seconds).
      private java.lang.String outputFormat
      The format name for the encoded target multimedia file.
      private java.lang.Integer safe
      Are the file paths considered "safe"
      private static long serialVersionUID  
      private VideoAttributes videoAttributes
      The attributes for the encoding of the video stream in the target multimedia file.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Optional<AudioAttributes> getAudioAttributes()
      Returns the attributes for the encoding of the audio stream in the target multimedia file.
      java.util.Optional<java.lang.Integer> getDecodingThreads()
      Number of threads to use for decoding (if supported by codec) -1 means use default of ffmpeg
      java.util.Optional<java.lang.Float> getDuration()
      Returns the duration (seconds) of the re-encoded stream.
      java.util.Optional<java.lang.Integer> getEncodingThreads()
      Number of threads to use for encoding (if supported by codec) No value (Optional.empty()) means use default of ffmpeg
      java.util.Map<java.lang.String,​java.lang.String> getExtraContext()
      Returns any additional user supplied context.
      java.util.Optional<java.lang.Integer> getFilterThreads()  
      java.util.Optional<java.lang.String> getInputFormat()
      Returns the format name for the incoming multimedia file.
      boolean getLoop()
      Returns if the input is to be considered for looping.
      java.util.Optional<java.lang.Float> getOffset()
      Returns the start offset time (seconds).
      java.util.Optional<java.lang.String> getOutputFormat()
      Returns the format name for the encoded target multimedia file.
      java.util.Optional<java.lang.Integer> getSafe()
      Returns whether or not the encoder will consider file paths "safe".
      java.util.Optional<VideoAttributes> getVideoAttributes()
      Returns the attributes for the encoding of the video stream in the target multimedia file.
      boolean isMapMetaData()  
      EncodingAttributes setAudioAttributes​(AudioAttributes audioAttributes)
      Sets the attributes for the encoding of the audio stream in the target multimedia file.
      EncodingAttributes setDecodingThreads​(int decodingThreads)
      Number of threads to use for decoding (if supported by codec) -1 means use default of ffmpeg
      EncodingAttributes setDuration​(java.lang.Float duration)
      Sets the duration (seconds) of the re-encoded stream.
      EncodingAttributes setEncodingThreads​(java.lang.Integer encodingThreads)
      Number of threads to use for encoding (if supported by codec) null means use default of ffmpeg
      EncodingAttributes setExtraContext​(java.util.Map<java.lang.String,​java.lang.String> context)
      Adds all key/value pairs from context to the extraContext private variable.Meant to be used in conjunction with Encoder.addOptionAtIndex(EncodingArgument, Integer).Add context here and retrieve the context via an EncodingArgument.
      EncodingAttributes setFilterThreads​(int filterThreads)
      ffmpeg uses multiple cores for filtering
      EncodingAttributes setInputFormat​(java.lang.String inputFormat)
      Sets the format name for the source multimedia file.
      EncodingAttributes setLoop​(boolean loop)
      Sets if the inputs will be looped or not.
      EncodingAttributes setMapMetaData​(boolean mapMetaData)
      Copy over meta data from original file to new output if possible
      EncodingAttributes setOffset​(java.lang.Float offset)
      Sets the start offset time (seconds).
      EncodingAttributes setOutputFormat​(java.lang.String format)
      Sets the format name for the encoded target multimedia file.
      EncodingAttributes setSafe​(java.lang.Integer safe)
      Are the file paths considered "safe": A file path is considered safe if it does not contain a protocol specification and is relative and all components only contain characters from the portable character set (letters, digits, period, underscore and hyphen) and have no period at the beginning of a component.
      EncodingAttributes setVideoAttributes​(VideoAttributes videoAttributes)
      Sets the attributes for the encoding of the video stream in the target multimedia file.
      java.lang.String toString()  
      void validate()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • inputFormat

        private java.lang.String inputFormat
        The format name for the incoming multimedia file.
      • outputFormat

        private java.lang.String outputFormat
        The format name for the encoded target multimedia file. Be sure this format is supported (see Encoder.getSupportedEncodingFormats().
      • offset

        private java.lang.Float offset
        The start offset time (seconds). If null or not specified no start offset will be applied.
      • duration

        private java.lang.Float duration
        The duration (seconds) of the re-encoded stream. If null or not specified the source stream, starting from the offset, will be completely re-encoded in the target stream.
      • audioAttributes

        private AudioAttributes audioAttributes
        The attributes for the encoding of the audio stream in the target multimedia file. If null of not specified no audio stream will be encoded. It cannot be null if also the video field is null.
      • videoAttributes

        private VideoAttributes videoAttributes
        The attributes for the encoding of the video stream in the target multimedia file. If null of not specified no video stream will be encoded. It cannot be null if also the audio field is null.
      • mapMetaData

        private boolean mapMetaData
        Should we try to copy over the meta data?
      • filterThreads

        private java.lang.Integer filterThreads
        Maximum number of cores/cpus to use for conversion.
        Not set means we use ffmpeg's default.
      • decodingThreads

        private java.lang.Integer decodingThreads
        Number of threads to use for decoding (if supported by codec)
      • encodingThreads

        private java.lang.Integer encodingThreads
        Number of threads to use for encoding (if supported by codec)
      • loop

        private boolean loop
        Should the input be treated as a loop
      • safe

        private java.lang.Integer safe
        Are the file paths considered "safe"
        See Also:
        FFMPEG Documentation
      • extraContext

        private final java.util.HashMap<java.lang.String,​java.lang.String> extraContext
        Additional context for custom encoder options. Add context here and retrieve/use it by adding an EncodingArgument to your Encoder class via Encoder.addOptionAtIndex(EncodingArgument, Integer)
    • Constructor Detail

      • EncodingAttributes

        public EncodingAttributes()
    • Method Detail

      • setExtraContext

        public EncodingAttributes setExtraContext​(java.util.Map<java.lang.String,​java.lang.String> context)
        Adds all key/value pairs from context to the extraContext private variable.Meant to be used in conjunction with Encoder.addOptionAtIndex(EncodingArgument, Integer).Add context here and retrieve the context via an EncodingArgument.
        Parameters:
        context - extra context
        Returns:
        the EncodingAttributes
      • getInputFormat

        public java.util.Optional<java.lang.String> getInputFormat()
        Returns the format name for the incoming multimedia file.
        Returns:
        The format name for the incoming multimedia file.
      • setInputFormat

        public EncodingAttributes setInputFormat​(java.lang.String inputFormat)
        Sets the format name for the source multimedia file.
        Parameters:
        inputFormat - the format name for the incoming multimedia file.
        Returns:
        this instance
      • getOutputFormat

        public java.util.Optional<java.lang.String> getOutputFormat()
        Returns the format name for the encoded target multimedia file.
        Returns:
        The format name for the encoded target multimedia file.
      • setOutputFormat

        public EncodingAttributes setOutputFormat​(java.lang.String format)
        Sets the format name for the encoded target multimedia file. Be sure this format is supported (see Encoder.getSupportedEncodingFormats().
        Parameters:
        format - The format name for the encoded target multimedia file.
        Returns:
        this instance
      • getOffset

        public java.util.Optional<java.lang.Float> getOffset()
        Returns the start offset time (seconds).
        Returns:
        The start offset time (seconds).
      • setOffset

        public EncodingAttributes setOffset​(java.lang.Float offset)
        Sets the start offset time (seconds). If null or not specified no start offset will be applied.
        Parameters:
        offset - The start offset time (seconds).
        Returns:
        this instance
      • getDuration

        public java.util.Optional<java.lang.Float> getDuration()
        Returns the duration (seconds) of the re-encoded stream.
        Returns:
        The duration (seconds) of the re-encoded stream.
      • setDuration

        public EncodingAttributes setDuration​(java.lang.Float duration)
        Sets the duration (seconds) of the re-encoded stream. If null or not specified the source stream, starting from the offset, will be completely re-encoded in the target stream.
        Parameters:
        duration - The duration (seconds) of the re-encoded stream.
        Returns:
        this instance
      • getLoop

        public boolean getLoop()
        Returns if the input is to be considered for looping.
        Returns:
        if the input will be looped.
      • setLoop

        public EncodingAttributes setLoop​(boolean loop)
        Sets if the inputs will be looped or not.
        Parameters:
        loop - if the input should be looped.
        Returns:
        this instance
      • getSafe

        public java.util.Optional<java.lang.Integer> getSafe()
        Returns whether or not the encoder will consider file paths "safe".
        Returns:
        Whether or not the encoder will consider file paths "safe".
        See Also:
        FFMPEG Documentation
      • setSafe

        public EncodingAttributes setSafe​(java.lang.Integer safe)
        Are the file paths considered "safe": A file path is considered safe if it does not contain a protocol specification and is relative and all components only contain characters from the portable character set (letters, digits, period, underscore and hyphen) and have no period at the beginning of a component.
        Parameters:
        safe - 0 for not safe; 1 for safe; is equivalent to 1 if the format was automatically probed and 0 otherwise. 1 is the default
        Returns:
        The EncodingAttributes
        See Also:
        FFMPEG Documentation
      • getAudioAttributes

        public java.util.Optional<AudioAttributes> getAudioAttributes()
        Returns the attributes for the encoding of the audio stream in the target multimedia file.
        Returns:
        The attributes for the encoding of the audio stream in the target multimedia file.
      • setAudioAttributes

        public EncodingAttributes setAudioAttributes​(AudioAttributes audioAttributes)
        Sets the attributes for the encoding of the audio stream in the target multimedia file. If null of not specified no audio stream will be encoded. It cannot be null if also the video field is null.
        Parameters:
        audioAttributes - The attributes for the encoding of the audio stream in the target multimedia file.
        Returns:
        this instance
      • getVideoAttributes

        public java.util.Optional<VideoAttributes> getVideoAttributes()
        Returns the attributes for the encoding of the video stream in the target multimedia file.
        Returns:
        The attributes for the encoding of the video stream in the target multimedia file.
      • setVideoAttributes

        public EncodingAttributes setVideoAttributes​(VideoAttributes videoAttributes)
        Sets the attributes for the encoding of the video stream in the target multimedia file. If null of not specified no video stream will be encoded. It cannot be null if also the audio field is null.
        Parameters:
        videoAttributes - The attributes for the encoding of the video stream in the target multimedia file.
        Returns:
        this instance
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isMapMetaData

        public boolean isMapMetaData()
        Returns:
        the mapMetaData
      • setMapMetaData

        public EncodingAttributes setMapMetaData​(boolean mapMetaData)
        Copy over meta data from original file to new output if possible
        Parameters:
        mapMetaData - the mapMetaData to set
        Returns:
        this instance
      • getFilterThreads

        public java.util.Optional<java.lang.Integer> getFilterThreads()
        Returns:
        Maximum number of cores/cpus to use for filtering -1 means use default of ffmpeg
      • setFilterThreads

        public EncodingAttributes setFilterThreads​(int filterThreads)
        ffmpeg uses multiple cores for filtering
        Parameters:
        filterThreads - Maximum number of cores/cpus to use -1 means use default of ffmpeg
        Returns:
        this instance
      • getDecodingThreads

        public java.util.Optional<java.lang.Integer> getDecodingThreads()
        Number of threads to use for decoding (if supported by codec) -1 means use default of ffmpeg
        Returns:
        the decodingThreads
      • setDecodingThreads

        public EncodingAttributes setDecodingThreads​(int decodingThreads)
        Number of threads to use for decoding (if supported by codec) -1 means use default of ffmpeg
        Parameters:
        decodingThreads - the decodingThreads to set
        Returns:
        this instance
      • getEncodingThreads

        public java.util.Optional<java.lang.Integer> getEncodingThreads()
        Number of threads to use for encoding (if supported by codec) No value (Optional.empty()) means use default of ffmpeg
        Returns:
        the encodingThreads
      • setEncodingThreads

        public EncodingAttributes setEncodingThreads​(java.lang.Integer encodingThreads)
        Number of threads to use for encoding (if supported by codec) null means use default of ffmpeg
        Parameters:
        encodingThreads - the encodingThreads to set
        Returns:
        this instance
      • validate

        public void validate()