javacv icon indicating copy to clipboard operation
javacv copied to clipboard

FFmpegFrameGrabber's png image pipeline decodes dropped frames

Open jetamie opened this issue 1 year ago • 3 comments

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

jetamie avatar May 15 '23 05:05 jetamie

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

saudet avatar May 16 '23 00:05 saudet

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

jetamie avatar May 16 '23 06:05 jetamie

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

jetamie avatar May 16 '23 06:05 jetamie