ffmpeg-light- Minimal bindings to the FFmpeg library.

Safe HaskellNone




Video encoding API. Includes FFI declarations for the underlying FFmpeg functions, wrappers for these functions that wrap error condition checking, and high level Haskellized interfaces.


FFI Declarations

av_freep :: Ptr (Ptr a) -> IO ()Source

FFmpeg Encoding Interface

data EncodingParams Source

Minimal parameters describing the desired video output.




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.

epPreset :: String

defaultH264 :: CInt -> CInt -> EncodingParamsSource

Use default parameters for a video of the given width and height, forcing the choice of the h264 encoder.

defaultParams :: CInt -> CInt -> EncodingParamsSource

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

checkFlag :: Bits a => a -> a -> BoolSource

Determine if the bitwise intersection of two values is non-zero.

initStream :: EncodingParams -> AVFormatContext -> IO (AVStream, AVCodecContext)Source

Find and initialize the requested encoder, and add a video stream to the output container.

initTempFrame :: EncodingParams -> AVPixelFormat -> IO AVFrameSource

Initialize a temporary YUV frame of the same resolution as the output video stream. We well convert RGB frames using this frame as a destination before encoding the video frame.

allocOutputContext :: FilePath -> IO AVFormatContextSource

Allocate an output context inferring the codec from the given file name.

avio_open_check :: AVFormatContext -> String -> IO ()Source

Open the given file for writing.

avio_close_check :: AVFormatContext -> IO ()Source

Close an open IO context.

encode_video_check :: AVCodecContext -> AVPacket -> Maybe AVFrame -> IO BoolSource

Returns True if the AVPacket was updated with new output data; False otherwise.

write_header_check :: AVFormatContext -> IO ()Source

Allocate the stream private data and write the stream header to an output media file.

write_frame_check :: AVFormatContext -> AVPacket -> IO ()Source

Write a packet to an output media file.

write_trailer_check :: AVFormatContext -> IO ()Source

Write the stream trailer to an output media file and free the private data. May only be called after a successful call to write_header_check.

frameWriter :: EncodingParams -> FilePath -> IO (Maybe (Vector CUChar) -> IO ())Source

Open a target file for writing a video stream. The function returned may be used to write RGB images of the resolution given by the provided EncodingParams. The function will convert the supplied RGB frame to YUV (specifically, yuv420p) before encoding the image to the video stream. If this function is applied to Nothing, then the output stream is closed. Note that Nothing must be provided to properly terminate video encoding.