bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.59k stars 1.59k forks source link

avfoundation not found #1799

Closed wlkfec closed 2 years ago

wlkfec commented 2 years ago

on mac : org.bytedeco.javacv.FFmpegFrameGrabber$Exception: av_find_input_format() error: Could not find input format "avfoundation".

wlkfec commented 2 years ago

public static void createGif(String dest) throws Exception{ FFmpegLogCallback.set(); FFmpegFrameGrabber grabber = new FFmpegFrameGrabber("0"); grabber.setFormat("avfoundation"); grabber.start(); FFmpegFrameRecorder recorder =new FFmpegFrameRecorder(dest + ".gif", 500, 500, 0); // AV_PIX_FMT_RGB4_BYTE recorder.setPixelFormat(AV_PIX_FMT_RGB4_BYTE); recorder.setVideoCodec(AV_CODEC_ID_GIF); recorder.start(); double frameRate = grabber.getFrameRate(); AtomicInteger count = new AtomicInteger(0); do { Frame frame = grabber.grab(); recorder.record(frame); } while (count.incrementAndGet() != frameRate * 5); recorder.stop(); grabber.stop(); recorder.release(); grabber.release(); }

saudet commented 2 years ago

There is a bug in JavaCV 1.5.7. Please call FFmpegFrameGrabber.tryLoad() before start().

saudet commented 2 years ago

Duplicate of #1756

wlkfec commented 2 years ago

It works, but when I call grab.grab, I find that only the first few frames have data, and then all the frames are empty, and the camera is not turned off, is it still missing the necessary settings?

saudet commented 2 years ago

That's another issue that was fixed in commit https://github.com/bytedeco/javacv/commit/8d75c0a33c9a105c7da08e754179ac785bf6f788, see issue #1784. Please give it a try with the snapshots: http://bytedeco.org/builds/