Skip to content

imageReader reads all but two frames of a video #58

@burkaman

Description

@burkaman

imageReader reads all but two frames when attempting to read all frames of a video, regardless of the video length. I'm not yet sure which frames are not being read.

OS: NixOS 20.03
ffmpeg version: 3.4.7

Things I would like to try but haven't yet: other OSes, other ffmpeg versions, other video types, and making a short video with numbered frames so I can save the images and see which frames are dropped.

Steps to Reproduce

Make sure you have the following packages installed: ffmpeg-light, JuicyPixels, monad-loops.

  1. Make DroppedFrames.hs and add the following:
import Codec.FFmpeg
import Codec.Picture
import Control.Monad.Loops
import Data.Maybe

readAllFrames :: IO Int
readAllFrames = do
 initFFmpeg
 setLogLevel avLogTrace
 (reader, cleanup) <- imageReader (File "pulse.mov") :: IO (IO (Maybe (Image PixelRGB8)), IO ())
 frames <- unfoldM reader
 return $ length frames
  1. Generate pulse.mov, either by building the demo application and running with no arguments, or loading /demo/Main.hs in ghci and running testEncode.
  2. Run ffmpeg -i pulse.mov -map 0:v:0 -c copy -f null -, and in the second to last line of output you'll see frame= 600, indicating that this video has 600 frames.
  3. Load DroppedFrames.hs in ghci and run readAllFrames. The output is 598, indicating imageReader only got 598 frames out of this video.

Here's a gist with the output of ffmpeg and readAllFrames with log level set to trace: https://gist.github.com/burkaman/0bb1e18b6769eed13cdf521c240222c4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions