Hello, I am attempting to write a java application that uses FFmpeg to record the screen of a Macbook.
If this is the incorrect place to be asking this question, are there any examples of accomplishing the screen recording with libav? My approach was to use a while loop to continuously capture the frames. However, only one frame gets captured and the recording stops. Do you have any ideas on what is going wrong? I am getting the following warnings but could not figure out how to resolve them: > [AVFoundation indev @ 0x12de64c00] Configuration of video device failed, > falling back to default. > [avfoundation @ 0x12de64980] Stream #0: not enough frames to estimate > rate; consider increasing probesize > [aac @ 0x103506660] 1 frames left in the queue on closing Here is the code I have: import org.bytedeco.ffmpeg.global.avutil; import org.bytedeco.javacpp.Loader; import org.bytedeco.javacv.Frame; import org.bytedeco.javacv.*; import org.bytedeco.opencv.opencv_java; import java.awt.*; import java.io.IOException; public class ScreenCaptureTrial { private static final String DEVICE_INDEX = "1:0"; //1 for mac's screen private static final int FRAME_RATE = 60; public static void main(String[] args) throws IOException { Loader.load(opencv_java.class); Dimension size = Toolkit.getDefaultToolkit().getScreenSize(); final int captureWidth = (int) size.getWidth(); final int captureHeight = (int) size.getHeight(); FFmpegLogCallback.set(); FFmpegFrameGrabber.tryLoad(); FrameGrabber grabber = new FFmpegFrameGrabber(DEVICE_INDEX); grabber.setFormat("avfoundation"); grabber.setPixelFormat(avutil.AV_PIX_FMT_0RGB); grabber.setFrameRate(FRAME_RATE); grabber.start(); final FFmpegFrameRecorder recorder = new FFmpegFrameRecorder( "screen_recording_trial.mp4", captureWidth, captureHeight, 2); //Start recording recorder.start(); Frame frame; while ((frame = grabber.grab()) != null) { recorder.record(frame); } recorder.stop(); grabber.stop(); } } Thank you
_______________________________________________ Libav-user mailing list Libav-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/libav-user To unsubscribe, visit link above, or email libav-user-requ...@ffmpeg.org with subject "unsubscribe".