Open zouxiaodong opened 3 years ago
Make sure that the output frames are in a format supported by Java 2D such as "bgr24".
Make sure that the output frames are in a format supported by Java 2D such as "bgr24".
converter.getBufferedImage work well ,if filter only fps=fps=0.2,
grabber.getPixelFormat() is AV_PIX_FMT_BGR24
FFmpegFrameFilter filter = new FFmpegFrameFilter(videoFilter, null, grabber.getImageWidth(), grabber.getImageHeight(), grabber.getAudioChannels()); filter.setPixelFormat(grabber.getPixelFormat()); filter.setSampleFormat(grabber.getSampleFormat()); filter.setFrameRate(grabber.getFrameRate()); filter.setSampleRate(grabber.getSampleRate());
The format filter should be able to do that with "format=pix_fmts=bgr24": https://ffmpeg.org/ffmpeg-filters.html#format-1
The format filter should be able to do that with "format=pix_fmts=bgr24": https://ffmpeg.org/ffmpeg-filters.html#format-1
”fps=fps=0.2,crop=639:216:0:0,format=pix_fmts=bgr24“ not work yet. why need to set format filter? the input video format is AV_PIX_FMT_BGR24
What does System.out.println(frameImg.image[0])
prints out?
What does
System.out.println(frameImg.image[0])
prints out?
java.nio.DirectByteBuffer[pos=0 lim=1244160 cap=1244160] frameImg.imageChannels is 9, so colorSpec is NULL? but why frameImg.imageChannels is 9 with crop filter?
Hum, I guess it's a bug when settings the imageChannels, where it assumes that the stride covers the width: https://github.com/bytedeco/javacv/blob/master/src/main/java/org/bytedeco/javacv/FFmpegFrameFilter.java#L727 You can probably set it to 3 manually and it's going to work.
So, we need to figure out how we're supposed to get the number of channels with FFmpeg, correctly...
Hum, I guess it's a bug when settings the imageChannels, where it assumes that the stride covers the width: https://github.com/bytedeco/javacv/blob/master/src/main/java/org/bytedeco/javacv/FFmpegFrameFilter.java#L727 You can probably set it to 3 manually and it's going to work.
So, we need to figure out how we're supposed to get the number of channels with FFmpeg, correctly... I Made a Mistake, the name option crop filter also not work.
frameImg.imageChannels = 3; that works , thanks.
frame video filter:fps=fps=0.2,crop=639:216:0:0 crop=639:216:0:0 will cause NullPointerExcepttion
ERROR] 2021-04-09 13:04:58.306 [grab--0] Grabber - java.lang.NullPointerException at java.awt.image.ComponentColorModel.bitsHelper(ComponentColorModel.java:359) at java.awt.image.ComponentColorModel.(ComponentColorModel.java:273)
at java.awt.image.ComponentColorModel.(ComponentColorModel.java:351)
at org.bytedeco.javacv.Java2DFrameConverter.getBufferedImage(Java2DFrameConverter.java:639)