Class AudioAttributes

  • All Implemented Interfaces:
    java.io.Serializable

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

      Fields 
      Modifier and Type Field Description
      private java.lang.Integer bitRate
      The bitrate value for the encoding process.
      private java.lang.Integer channels
      The channels value (1=mono, 2=stereo) for the encoding process.
      private java.lang.String codec
      The codec name for the encoding process.
      static java.lang.String DIRECT_STREAM_COPY
      This value can be setted in the codec field to perform a direct stream copy, without re-encoding of the audio stream.
      private java.lang.Integer quality
      The audio quality value for the encoding process.
      private java.lang.Integer samplingRate
      The samplingRate value for the encoding process.
      private static long serialVersionUID  
      private java.lang.Integer volume
      The volume value for the encoding process.
    • Constructor Summary

      Constructors 
      Constructor Description
      AudioAttributes()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Optional<java.lang.Integer> getBitRate()
      Returns the bitrate value for the encoding process.
      java.util.Optional<java.lang.Integer> getChannels()
      Returns the channels value (1=mono, 2=stereo, 4=quad) for the encoding process.
      java.util.Optional<java.lang.String> getCodec()
      Returns the codec name for the encoding process.
      java.util.Optional<java.lang.Integer> getQuality()  
      java.util.Optional<java.lang.Integer> getSamplingRate()
      Returns the samplingRate value for the encoding process.
      java.util.Optional<java.lang.Integer> getVolume()
      Returns the volume value for the encoding process.
      AudioAttributes setBitRate​(java.lang.Integer bitRate)
      Sets the bitrate value for the encoding process.
      AudioAttributes setChannels​(java.lang.Integer channels)
      Sets the channels value (1=mono, 2=stereo, 4=quad) for the encoding process.
      AudioAttributes setCodec​(java.lang.String codec)
      Sets the codec name for the encoding process.If null or not specified the encoder will perform a direct stream copy.
      AudioAttributes setQuality​(java.lang.Integer quality)
      The audio quality value for the encoding process.
      AudioAttributes setSamplingRate​(java.lang.Integer samplingRate)
      Sets the samplingRate value for the encoding process.
      AudioAttributes setVolume​(java.lang.Integer volume)
      Sets the volume value for the encoding process.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • DIRECT_STREAM_COPY

        public static final java.lang.String DIRECT_STREAM_COPY
        This value can be setted in the codec field to perform a direct stream copy, without re-encoding of the audio stream.
        See Also:
        Constant Field Values
      • codec

        private java.lang.String codec
        The codec name for the encoding process. If null or not specified the encoder will perform a direct stream copy.
      • bitRate

        private java.lang.Integer bitRate
        The bitrate value for the encoding process. If null or not specified a default value will be picked.
      • samplingRate

        private java.lang.Integer samplingRate
        The samplingRate value for the encoding process. If null or not specified a default value will be picked.
      • channels

        private java.lang.Integer channels
        The channels value (1=mono, 2=stereo) for the encoding process. If null or not specified a default value will be picked.
      • volume

        private java.lang.Integer volume
        The volume value for the encoding process. If null or not specified a default value will be picked. If 256 no volume change will be performed.
      • quality

        private java.lang.Integer quality
        The audio quality value for the encoding process. If null or not specified the ffmpeg default will be used
    • Constructor Detail

      • AudioAttributes

        public AudioAttributes()
    • Method Detail

      • getCodec

        public java.util.Optional<java.lang.String> getCodec()
        Returns the codec name for the encoding process.
        Returns:
        The codec name for the encoding process.
      • setCodec

        public AudioAttributes setCodec​(java.lang.String codec)
        Sets the codec name for the encoding process.If null or not specified the encoder will perform a direct stream copy. Be sure the supplied codec name is in the list returned by Encoder.getAudioEncoders().

        A special value can be picked from DIRECT_STREAM_COPY.

        Parameters:
        codec - The codec name for the encoding process.
        Returns:
        this instance
      • getBitRate

        public java.util.Optional<java.lang.Integer> getBitRate()
        Returns the bitrate value for the encoding process.
        Returns:
        The bitrate value for the encoding process.
      • setBitRate

        public AudioAttributes setBitRate​(java.lang.Integer bitRate)
        Sets the bitrate value for the encoding process. If null or not specified a default value will be picked.
        Parameters:
        bitRate - The bitrate value for the encoding process.
        Returns:
        this instance
      • getSamplingRate

        public java.util.Optional<java.lang.Integer> getSamplingRate()
        Returns the samplingRate value for the encoding process.
        Returns:
        the samplingRate The samplingRate value for the encoding process.
      • setSamplingRate

        public AudioAttributes setSamplingRate​(java.lang.Integer samplingRate)
        Sets the samplingRate value for the encoding process. If null or not specified a default value will be picked.
        Parameters:
        samplingRate - The samplingRate value for the encoding process.
        Returns:
        this instance
      • getChannels

        public java.util.Optional<java.lang.Integer> getChannels()
        Returns the channels value (1=mono, 2=stereo, 4=quad) for the encoding process.
        Returns:
        The channels value (1=mono, 2=stereo, 4=quad) for the encoding process.
      • setChannels

        public AudioAttributes setChannels​(java.lang.Integer channels)
        Sets the channels value (1=mono, 2=stereo, 4=quad) for the encoding process. If null or not specified a default value will be picked.
        Parameters:
        channels - The channels value (1=mono, 2=stereo, 4=quad) for the encoding process.
        Returns:
        this instance
      • getVolume

        public java.util.Optional<java.lang.Integer> getVolume()
        Returns the volume value for the encoding process.
        Returns:
        The volume value for the encoding process.
      • setVolume

        public AudioAttributes setVolume​(java.lang.Integer volume)
        Sets the volume value for the encoding process. If null or not specified a default value will be picked. If 256 no volume change will be performed.

        volume is the "amplitude ratio" or "sound pressure level" ratio 2560 is volume=20dB The formula is dBnumber=20*lg(amplitude ratio) 128 means reducing by 50% 512 means doubling the volume

        Parameters:
        volume - The volume value for the encoding process.
        Returns:
        this instance
      • getQuality

        public java.util.Optional<java.lang.Integer> getQuality()
        Returns:
        the audio conversion quality
      • setQuality

        public AudioAttributes setQuality​(java.lang.Integer quality)
        The audio quality value for the encoding process. If null or not specified the ffmpeg default will be used

        The value depends on the choosen codec

        For mp3 you can see here: https://trac.ffmpeg.org/wiki/Encode/MP3

        Or more general https://ffmpeg.org/ffmpeg-codecs.html

        Parameters:
        quality - the audio conversion quality to set
        Returns:
        this instance
      • toString

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