public static FrameFilter createDefault(String filtersDescr, int imageWidth, int imageHeight) throws Exception { return new FFmpegFrameFilter(filtersDescr, imageWidth, imageHeight); }
@Override public Frame pull() throws Exception { frame.keyFrame = false; frame.imageWidth = 0; frame.imageHeight = 0; frame.imageDepth = 0; frame.imageChannels = 0; frame.imageStride = 0; frame.image = null; frame.sampleRate = 0; frame.audioChannels = 0; frame.samples = null; frame.opaque = null; Frame f = null; if (f == null && buffersrc_ctx != null) { f = pullImage(); } if (f == null && abuffersrc_ctx != null) { f = pullSamples(); } if (f == null && buffersrc_ctx == null && abuffersrc_ctx == null) { f = inframe; } inframe = null; return f; }
VIDEO_GRABBER.start(); initVideoRecorder(myDirectory + "/video" + System.currentTimeMillis() + ".mp4"); filter.start(); while (VIDEO_GRABBER.grab() != null) { tempVideoFrame = VIDEO_GRABBER.grabImage(); if (tempVideoFrame != null) { filter.push(tempVideoFrame); tempVideoFrame = filter.pull(); videoRecorder.record(tempVideoFrame); filter.stop(); videoRecorder.release(); VIDEO_GRABBER.stop();
/** * Constructs a filtergraph out of the filter specification. * * @param filters to use * @param width of the input images * @param height of the input images * @param channels of the input images */ public FilterImageTransform(String filters, int width, int height, int channels) { super(null); int pixelFormat = channels == 1 ? AV_PIX_FMT_GRAY8 : channels == 3 ? AV_PIX_FMT_BGR24 : channels == 4 ? AV_PIX_FMT_RGBA : AV_PIX_FMT_NONE; if (pixelFormat == AV_PIX_FMT_NONE) { throw new IllegalArgumentException("Unsupported number of channels: " + channels); } try { filter = new FFmpegFrameFilter(filters, width, height); filter.setPixelFormat(pixelFormat); filter.start(); } catch (FrameFilter.Exception e) { throw new RuntimeException(e); } }
public void push(Frame frame, int pixelFormat) throws Exception { push(0, frame, pixelFormat); } public void push(int n, Frame frame) throws Exception {
/** * Constructs a filtergraph out of the filter specification. * * @param filters to use * @param width of the input images * @param height of the input images * @param channels of the input images */ public FilterImageTransform(@JsonProperty("filters") String filters, @JsonProperty("width") int width, @JsonProperty("height") int height, @JsonProperty("channels") int channels) { super(null); this.filters = filters; this.width = width; this.height = height; this.channels = channels; int pixelFormat = channels == 1 ? AV_PIX_FMT_GRAY8 : channels == 3 ? AV_PIX_FMT_BGR24 : channels == 4 ? AV_PIX_FMT_RGBA : AV_PIX_FMT_NONE; if (pixelFormat == AV_PIX_FMT_NONE) { throw new IllegalArgumentException("Unsupported number of channels: " + channels); } try { filter = new FFmpegFrameFilter(filters, width, height); filter.setPixelFormat(pixelFormat); filter.start(); } catch (FrameFilter.Exception e) { throw new RuntimeException(e); } }
@Override public void push(Frame frame) throws Exception { push(frame, AV_PIX_FMT_NONE); } public void push(Frame frame, int pixelFormat) throws Exception {
public void push(int n, Frame frame) throws Exception { push(n, frame, AV_PIX_FMT_NONE); } public void push(int n, Frame frame, int pixelFormat) throws Exception {