Skip to content

Commit

Permalink
probe: Can extract the image size for a stream
Browse files Browse the repository at this point in the history
  • Loading branch information
waldheinz committed Mar 15, 2016
1 parent 61cbfc7 commit 4dafbe5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Codec/FFmpeg/Probe.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Codec.FFmpeg.Probe (
-- * Streams
AvStreamT, withStream, codecContext, codecName,
codecMediaTypeName, streamBitrate, streamMetadata,
codec,
codec, streamImageSize,

-- * Dictionaries
dictFoldM_
Expand Down Expand Up @@ -120,6 +120,13 @@ codecName cctx = liftIO $ getCodecID cctx >>= avcodec_get_name >>= peekCString
streamBitrate :: MonadIO m => AVCodecContext -> AvStreamT m Int
streamBitrate cctx = liftIO $ getBitRate cctx >>= return . fromIntegral

-- |
-- Gives the (width, height) of a video stream in pixels, not accounting for the pixel aspect ratio.
streamImageSize :: MonadIO m => AVCodecContext -> AvStreamT m (Int, Int)
streamImageSize cctx = liftIO $ (,)
<$> liftM fromIntegral (getWidth cctx)
<*> liftM fromIntegral (getHeight cctx)

streamMetadata :: MonadIO m => AvStreamT m AVDictionary
streamMetadata = ask >>= liftIO . (#peek AVStream, metadata) . getPtr

Expand Down

0 comments on commit 4dafbe5

Please sign in to comment.