bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.45k stars 1.57k forks source link

FFmpegFrameGrabber's png image pipeline decodes dropped frames #2025

Open jetamie opened 1 year ago

jetamie commented 1 year ago

This is my image input pseudocode

int inputCount=0;
whlie(true) {
   byte[] imageBytes = producePngImage();
   if (inputBytes.length == 0) {
       continue;
   }
   pipeOutputStream.write(imageBytes);
   inputCount++;
}

this is my FFmpegFrameGrabber's pseudocode

FFmpegFrameGrabber g= new FFmpegFrameGrabber(pipeInputStream, 0);
g.setImageWidth(width);
g.setImageheight(height);
g.setImageMode(ImageMode.RAW);
g.setFormat("image2pipe");
g.setPixelFormat(AV_PIX_FMT_BGR24);
g.start()

Frame frame;
int count=0
while((frame = g.grab()) != null) {
   count++;
   recorder.record(frame);
}

But the above two counters inputCount are not equal to count, always 16 frames less

saudet commented 1 year ago

Are you getting any warning messages? Please make sure that FFmpegLogCallback.set() has been called.

jetamie commented 1 year ago

There is no warn information, I'm sure that has been called.FFmpegLogCallback.set(), and the level setting is info

jetamie commented 1 year ago

If I use a YUV420P encoded image with a format of rawvideo, I won't have a problem