ffmpeg-light-0.13.0: Minimal bindings to the FFmpeg library.
Safe HaskellNone
LanguageHaskell2010

Codec.FFmpeg

Description

Interface to initialize FFmpeg, decode video files, encode video files, and convert decoded image frames to JuicyPixels images.

Synopsis

Initialization

initFFmpeg :: IO () Source #

Initialize FFmpeg by registering all known codecs. This must be called before using other FFmpeg functions. The debug level is initially set to quiet. If you would like the standard ffmpeg debug level, call setLogLevel avLogInfo after initFFmpeg.

setLogLevel :: LogLevel -> IO () Source #

Log output is sent to stderr.

Decoding

imageReader :: JuicyPixelFormat p => InputSource -> IO (IO (Maybe (Image p)), IO ()) Source #

Read frames from a video stream. Errors are thrown as IOExceptions.

imageReaderTime :: JuicyPixelFormat p => InputSource -> IO (IO (Maybe (Image p, Double)), IO ()) Source #

Read time stamped frames from a video stream. Time is given in seconds from the start of the stream. Errors are thrown as IOExceptions.

imageReaderT :: forall m p. (Functor m, MonadIO m, MonadError String m, JuicyPixelFormat p) => InputSource -> m (IO (Maybe (Image p)), IO ()) Source #

Read frames from a video stream.

imageReaderTimeT :: forall m p. (Functor m, MonadIO m, MonadError String m, JuicyPixelFormat p) => InputSource -> m (IO (Maybe (Image p, Double)), IO ()) Source #

Read time stamped frames from a video stream. Time is given in seconds from the start of the stream.

Encoding

data EncodingParams Source #

Minimal parameters describing the desired video output.

Constructors

EncodingParams 

Fields

  • epWidth :: CInt
     
  • epHeight :: CInt
     
  • epFps :: Int
     
  • epCodec :: Maybe AVCodecID

    If Nothing, then the codec is inferred from the output file name. If Just, then this codec is manually chosen.

  • epPixelFormat :: Maybe AVPixelFormat

    If Nothing, automatically chose a pixel format based on the output codec. If Just, force the selected pixel format.

  • epPreset :: String

    Encoder-specific hints. For h264, the default preset is "medium" (other options are "fast", "slow", etc.). For the GIF codec, setting this to "dither" will enable dithering during the palettization process. This will improve image quality, but result in a larger file.

  • epFormatName :: Maybe String

    FFmpeg muxer format name. If Nothing, tries to infer from the output file name. If Just, the string value should be the one available in ffmpeg -formats.

defaultParams :: CInt -> CInt -> EncodingParams Source #

Use default parameters for a video of the given width and height. The output format is determined by the output file name.

imageWriter :: forall p. JuicyPixelFormat p => EncodingParams -> FilePath -> IO (Maybe (Image p) -> IO ()) Source #

Open a target file for writing a video stream. When the returned function is applied to Nothing, the output stream is closed. Note that Nothing must be provided when finishing in order to properly terminate video encoding.

Support for source images that are of a different size to the output resolution is limited to non-palettized destination formats (i.e. those that are handled by libswscaler). Practically, this means that animated gif output is only supported if the source images are of the target resolution.

Types and Enums