ffmpeg-light 0.14.0 → 0.14.1
raw patch · 3 files changed
+38/−37 lines, 3 filesdep ~transformers
Dependency ranges changed: transformers
Files
- demo/VPlay.hs +2/−0
- ffmpeg-light.cabal +3/−3
- src/Codec/FFmpeg/Resampler.hs +33/−34
demo/VPlay.hs view
@@ -117,6 +117,8 @@ (\ event -> case SDL.eventPayload event of SDL.QuitEvent -> True+ SDL.KeyboardEvent ev ->+ SDL.keysymKeycode (SDL.keyboardEventKeysym ev) == SDL.KeycodeEscape _ -> False)) action {- Return ByteString filled by image data from frame.
ffmpeg-light.cabal view
@@ -1,5 +1,5 @@ name: ffmpeg-light-version: 0.14.0+version: 0.14.1 synopsis: Minimal bindings to the FFmpeg library. description: Stream frames from an encoded video, or stream frames to@@ -28,7 +28,7 @@ build-type: Simple extra-source-files: src/hscMacros.h, src/nameCompat.h, CHANGELOG.md cabal-version: >=1.10-tested-with: GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.2+tested-with: GHC == 8.6.5 || == 8.8.4 || == 8.10.7 || == 9.0.2 || == 9.2.1 source-repository head type: git@@ -84,7 +84,7 @@ exceptions, vector >= 0.10.9 && < 0.13, stm >= 2.0.0.0 && < 3.0.0.0.0,- transformers >= 0.4.1 && < 0.6,+ transformers >= 0.4.1 && < 0.7, mtl >= 2.2.1 && < 2.3, JuicyPixels >= 3.1 && < 3.4, bytestring
src/Codec/FFmpeg/Resampler.hs view
@@ -9,7 +9,6 @@ import Foreign.C.String import Foreign.C.Types import Foreign.Marshal.Alloc-import Foreign.Marshal.Array import Foreign.Ptr import Foreign.Storable @@ -54,13 +53,13 @@ lineSize <- malloc dstChannelCount <- av_get_channel_layout_nb_channels (apChannelLayout outParams)- runWithError "Could not alloc samples"- (av_samples_alloc_array_and_samples dstDataPtr lineSize- dstChannelCount (fromIntegral dstSamples)- (apSampleFormat outParams) 0)+ _ <- runWithError "Could not alloc samples"+ (av_samples_alloc_array_and_samples dstDataPtr lineSize+ dstChannelCount (fromIntegral dstSamples)+ (apSampleFormat outParams) 0) dstData <- peek dstDataPtr- runWithError "Error converting samples"- (swr_convert swr nullPtr 0 srcData srcSamples)+ _ <- runWithError "Error converting samples"+ (swr_convert swr nullPtr 0 srcData srcSamples) frameSize <- getFrameSize ctx let convertLoop = do@@ -68,11 +67,11 @@ if outSamples < frameSize * dstChannelCount then return () else do- frame <- allocAudioFrame ctx- outSamples <- swr_convert swr (castPtr $ hasData frame)- frameSize nullPtr 0+ aframe <- allocAudioFrame ctx+ _outSamples <- swr_convert swr (castPtr $ hasData aframe)+ frameSize nullPtr 0 - atomically $ writeTChan frameChan frame+ atomically $ writeTChan frameChan aframe convertLoop convertLoop@@ -81,22 +80,22 @@ return () allocAudioFrame :: AVCodecContext -> IO AVFrame- allocAudioFrame ctx = do+ allocAudioFrame actx = do frame <- av_frame_alloc when (getPtr frame == nullPtr) (error "Error allocating an audio frame") - setFormat frame . getSampleFormatInt =<< getSampleFormat ctx- setChannelLayout frame =<< getChannelLayout ctx- setSampleRate frame =<< getSampleRate ctx- fs <- (do fs <- getFrameSize ctx+ setFormat frame . getSampleFormatInt =<< getSampleFormat actx+ setChannelLayout frame =<< getChannelLayout actx+ setSampleRate frame =<< getSampleRate actx+ fs <- (do fs <- getFrameSize actx if fs == 0 then return 1000 else return fs) setNumSamples frame fs - runWithError "Error allocating an audio buffer"- (av_frame_get_buffer frame 0)+ _ <- runWithError "Error allocating an audio buffer"+ (av_frame_get_buffer frame 0) return frame readFrame = do@@ -113,11 +112,11 @@ when (getPtr swr == nullPtr) (error "Could not allocate resampler context") let set_int str i = do cStr <- newCString str- av_opt_set_int (getPtr swr) cStr (fromIntegral i) 0+ _ <- av_opt_set_int (getPtr swr) cStr (fromIntegral i) 0 free cStr set_sample_fmt str fmt = do cStr <- newCString str- av_opt_set_sample_fmt (getPtr swr) cStr fmt 0+ _ <- av_opt_set_sample_fmt (getPtr swr) cStr fmt 0 free cStr -- set_int "in_channel_count" (aoChannelCount inParams)@@ -131,19 +130,19 @@ void $ runWithError "Failed to initialize the resampling context" (swr_init swr) - let get_int str = do- cStr <- newCString str- p <- malloc- r <- av_opt_get_int (getPtr swr) cStr 0 p- v <- peek p- free p- return v- get_sample_fmt str = do- cStr <- newCString str- p <- malloc- r <- av_opt_get_sample_fmt (getPtr swr) cStr 0 p- fmt <- peek p- free p- return fmt+ -- let get_int str = do+ -- cStr <- newCString str+ -- p <- malloc+ -- r <- av_opt_get_int (getPtr swr) cStr 0 p+ -- v <- peek p+ -- free p+ -- return v+ -- get_sample_fmt str = do+ -- cStr <- newCString str+ -- p <- malloc+ -- r <- av_opt_get_sample_fmt (getPtr swr) cStr 0 p+ -- fmt <- peek p+ -- free p+ -- return fmt return swr