Class FfmpegCensor

  • All Implemented Interfaces:
    MediaCensor

    public class FfmpegCensor
    extends Object
    implements MediaCensor
    MediaCensor implemented by executing ffmpeg.
    Author:
    Robert Fromont robert@fromont.net.nz
    • Constructor Detail

      • FfmpegCensor

        public FfmpegCensor()
        Default constructor.
    • Method Detail

      • getFfmpeg

        public File getFfmpeg()
        Getter for ffmpeg: Executable file for ffmpeg.
        Returns:
        Executable file for ffmpeg.
      • setFfmpeg

        public void setFfmpeg​(File newFfmpeg)
        Setter for ffmpeg: Executable file for ffmpeg.
        Parameters:
        newFfmpeg - Executable file for ffmpeg.
      • getAudioFilter

        public String getAudioFilter()
        Getter for audioFilter: Filter for obfuscating audio.
        Returns:
        Filter for obfuscating audio. Default is "lowpass=f=80";
      • setAudioFilter

        public void setAudioFilter​(String newAudioFilter)
        Setter for audioFilter: Filter for obfuscating audio.
        Parameters:
        newAudioFilter - Filter for obfuscating audio.
      • getDeleteSource

        public Boolean getDeleteSource()
        Getter for deleteSource: Delete source file when finished.
        Returns:
        Delete source file when finished.
      • setDeleteSource

        public void setDeleteSource​(Boolean newDeleteSource)
        Setter for deleteSource: Delete source file when finished.
        Parameters:
        newDeleteSource - Delete source file when finished.
      • getVerbose

        public Boolean getVerbose()
        Getter for verbose: Whether to output intervals and ffmpeg command line arguments to stderr or not.
        Returns:
        Whether to output intervals and ffmpeg command line arguments to stderr or not.
      • setVerbose

        public FfmpegCensor setVerbose​(Boolean newVerbose)
        Setter for verbose: Whether to output intervals and ffmpeg command line arguments to stderr or not.
        Parameters:
        newVerbose - Whether to output intervals and ffmpeg command line arguments to stderr or not.
      • configure

        public ParameterSet configure​(ParameterSet configuration)
                               throws MediaException
        Configure the censor. This might include executable paths, obfuscation parameters, etc.

        This method can be invoked with an empty parameter set, to discover what (if any) parameters are required. If parameters are returned, and user interaction is possible, then the user may be presented with an interface for setting/confirming these parameters.

        Specified by:
        configure in interface MediaCensor
        Parameters:
        configuration - The configuration for the censor.
        Returns:
        A list of configuration parameters must be set before the censor can be used.
        Throws:
        MediaException - If an error occurs.
      • typeSupported

        public boolean typeSupported​(String sourceType)
                              throws MediaException
        Determines whether this censor supports censoring of media of the given type.
        Specified by:
        typeSupported in interface MediaCensor
        Parameters:
        sourceType - The MIME type of the source media.
        Returns:
        true if the censor can censor media of sourceType, false otherwise.
        Throws:
        MediaException - If an error occurs.
      • start

        public MediaThread start​(String sourceType,
                                 File source,
                                 List<Double> boundaries,
                                 File destination)
                          throws MediaException
        Starts censoring.

        The boundaries are a list of time points in seconds, which define the boundaries of contiguous intervals. Every second interval (starting from the first point) will be censored. An initial uncensored portion starting at 0s is assumed, so only add a point at 0.0 if you want the first censored interval to start at 0s. e.g.

        • If boundaries is empty, then destination will have no obfuscated intevals (it will be a copy of source).
        • If boundaries contains one point, at 1.0, then the media from 0.0-1.0 will be uncensored, and from 1.0 onward will be obfuscated.
        • If boundaries contains two points, at 1.0 and 2.0, then the media from 0.0-1.0 will be uncensored, from 1.0-2.0 will be obfuscated, and from 2.0 onward will be uncensored.
        • If boundaries contains three points, at 0.0, 1.0, and 2.0, then the media from 0.0-1.0 will be obfuscated, from 1.0-2.0 will be uncensored, and from 2.0 onward will be obfuscated.
        Specified by:
        start in interface MediaCensor
        Parameters:
        sourceType - The MIME type of the source media.
        source - The (old) original file.
        boundaries - A list of time points, in seconds, which define the boundaries of contiguous intervals.
        destination - The (new) censored file.
        Returns:
        A thread that is processing the media.
        Throws:
        MediaException - If an error occurs.