当前位置: 首页>>代码示例>>Java>>正文


Java FFmpegFrameGrabber类代码示例

本文整理汇总了Java中org.bytedeco.javacv.FFmpegFrameGrabber的典型用法代码示例。如果您正苦于以下问题:Java FFmpegFrameGrabber类的具体用法?Java FFmpegFrameGrabber怎么用?Java FFmpegFrameGrabber使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FFmpegFrameGrabber类属于org.bytedeco.javacv包,在下文中一共展示了FFmpegFrameGrabber类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadData

import org.bytedeco.javacv.FFmpegFrameGrabber; //导入依赖的package包/类
protected List<Writable> loadData(File file, InputStream inputStream) throws IOException {
    List<Writable> ret = new ArrayList<>();
    try (FFmpegFrameGrabber grabber = inputStream != null ? new FFmpegFrameGrabber(inputStream)
                    : new FFmpegFrameGrabber(file.getAbsolutePath())) {
        grabber.setSampleFormat(AV_SAMPLE_FMT_FLT);
        grabber.start();
        Frame frame;
        while ((frame = grabber.grab()) != null) {
            while (frame.samples != null && frame.samples[0].hasRemaining()) {
                for (int i = 0; i < frame.samples.length; i++) {
                    ret.add(new FloatWritable(((FloatBuffer) frame.samples[i]).get()));
                }
            }
        }
    }
    return ret;
}
 
开发者ID:deeplearning4j,项目名称:DataVec,代码行数:18,代码来源:NativeAudioRecordReader.java

示例2: main

import org.bytedeco.javacv.FFmpegFrameGrabber; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(args[0]);
    grabber.start();
    int i = 0;
    opencv_core.IplImage img = null;
    int max = Integer.parseInt(args[2]);
    if (max <= 0) {
        max = Integer.MAX_VALUE;
    }
    while (i++ < max) {
        opencv_core.IplImage source = grabber.grab();
        if (img == null) {
            opencv_core.CvSize size = cvSize(source.width() / 2, source.height() / 2);
            img = opencv_core.IplImage.create(size, source.depth(), source.nChannels());
        }
        cvResize(source, img);
        cvSaveImage(String.format(args[1] + "/%05d.jpg", i), img);
    }
    System.out.println("done, got " + i + " images");
}
 
开发者ID:ADSC-Resa,项目名称:resa,代码行数:21,代码来源:Video2Image2.java

示例3: configureThumbnail

import org.bytedeco.javacv.FFmpegFrameGrabber; //导入依赖的package包/类
/**
 * Configures the thumbnails for the given uploadId
 * @param uploadId The session id
 * @return Result
 * @throws Exception
 * @throws IOException
 * @throws ClientProtocolException
 */
protected StatusResult configureThumbnail(String uploadId) throws Exception, IOException, ClientProtocolException {
    try (FFmpegFrameGrabber frameGrabber = new FFmpegFrameGrabber(videoFile)) {
        frameGrabber.start();
        Java2DFrameConverter converter = new Java2DFrameConverter();
        
        int width = frameGrabber.getImageWidth();
        int height = frameGrabber.getImageHeight();
        long length = frameGrabber.getLengthInTime();
        
        BufferedImage bufferedImage;
        if (thumbnailFile == null) {
            bufferedImage = MyImageUtils.deepCopy(converter.convert(frameGrabber.grabImage()));
            thumbnailFile = File.createTempFile("insta", ".jpg");
            
            log.info("Generated thumbnail: " + thumbnailFile.getAbsolutePath());
            ImageIO.write(bufferedImage, "JPG", thumbnailFile);
        } else {
            bufferedImage = ImageIO.read(thumbnailFile);
        }

        
        holdOn();
        
        StatusResult thumbnailResult = api.sendRequest(new InstagramUploadPhotoRequest(thumbnailFile, caption, uploadId));
        log.info("Thumbnail result: " + thumbnailResult);
        
        StatusResult configureResult = api.sendRequest(InstagramConfigureVideoRequest.builder().uploadId(uploadId)
                    .caption(caption)
                    .duration(length)
                    .width(width)
                    .height(height)
                    .build());
        
        log.info("Video configure result: " + configureResult);

        return configureResult;
    }
}
 
开发者ID:brunocvcunha,项目名称:instagram4j,代码行数:47,代码来源:InstagramUploadVideoRequest.java

示例4: start

import org.bytedeco.javacv.FFmpegFrameGrabber; //导入依赖的package包/类
@Override
public void start() {
    FFmpegFrameGrabber grabberFF = new FFmpegFrameGrabber(this.cameraDescription);

    grabberFF.setImageMode(FrameGrabber.ImageMode.COLOR);
    
    this.setPixelFormat(PixelFormat.BGR);
    
    grabberFF.setFormat(this.imageFormat);
    grabberFF.setImageWidth(width());
    grabberFF.setImageHeight(height());
    grabberFF.setFrameRate(frameRate);
    

    try {
        grabberFF.start();
        this.grabber = grabberFF;
        this.isConnected = true;
    } catch (Exception e) {
        System.err.println("Could not start frameGrabber... " + e);

        System.err.println("Could not camera start frameGrabber... " + e);
        System.err.println("Camera ID " + this.systemNumber + " could not start.");
        System.err.println("Check cable connection, ID and resolution asked.");

        this.grabber = null;
    }
}
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:29,代码来源:CameraFFMPEG.java

示例5: VidImageSequence

import org.bytedeco.javacv.FFmpegFrameGrabber; //导入依赖的package包/类
public VidImageSequence(File f) throws IOException {
	
	super(f.getName());
	
	try {
		g = new FFmpegFrameGrabber(f);
		g.start();
		width	= g.getImageWidth();
		height	= g.getImageHeight();
		frames	= g.getLengthInFrames();
		
	} catch (Exception e) {
		throw new IOException();
	}
}
 
开发者ID:CalebKussmaul,项目名称:GIFKR,代码行数:16,代码来源:VidImageSequence.java

示例6: initialize

import org.bytedeco.javacv.FFmpegFrameGrabber; //导入依赖的package包/类
@Override
public void initialize() throws IOException {
  try {
    frameGrabber = new FFmpegFrameGrabber(path);
    frameGrabber.start();
    final double fps = frameGrabber.getFrameRate();
    fpsSocket.setValue(fps);
    frameCount = frameGrabber.getLengthInFrames();
    if (frameCount <= 1) {
      // Only one frame, no point in scheduling automatic updates to grab the same
      // image over and over
      manualGrabberService.submit(this::grabNextFrame);
    } else {
      grabberFuture = Executors.newSingleThreadScheduledExecutor(DaemonThread::new)
          .scheduleAtFixedRate(
              () -> {
                if (!isPaused()) {
                  grabNextFrame();
                }
              },
              0L,
              (long) (1e3 / fps),
              TimeUnit.MILLISECONDS
          );
    }
  } catch (FrameGrabber.Exception e) {
    throw new IOException("Could not open video file " + path, e);
  }
}
 
开发者ID:WPIRoboticsProjects,项目名称:GRIP,代码行数:30,代码来源:VideoFileSource.java

示例7: track

import org.bytedeco.javacv.FFmpegFrameGrabber; //导入依赖的package包/类
/**
 * Read a video from a URL, and perform pedestrian tracking on it.
 *
 * @param videoStream the video stream to conduct tracking on.
 * @return a set of tracklets of pedestrians.
 */
@Nonnull
@Override
public Tracklet[] track(@Nonnull InputStream videoStream) throws FrameGrabber.Exception {
    FFmpegFrameGrabber frameGrabber = new FFmpegFrameGrabber(videoStream);
    av_log_set_level(AV_LOG_QUIET);
    frameGrabber.start();
    logger.debug("Initialized video decoder!");

    long trackerPointer = initialize(frameGrabber.getImageWidth(), frameGrabber.getImageHeight(), 3, conf);
    logger.debug("Initialized tracker!");

    int cnt = 0;
    // Every time a frame is retrieved during decoding, it is immediately fed into the tracker,
    // so as to save runtime memory.
    while (true) {
        Frame frame;
        try {
            frame = frameGrabber.grabImage();
        } catch (FrameGrabber.Exception e) {
            logger.error("On grabImage: " + e);
            break;
        }
        if (frame == null) {
            break;
        }
        final byte[] buf = new byte[frame.imageHeight * frame.imageWidth * frame.imageChannels];
        final opencv_core.Mat cvFrame = new OpenCVFrameConverter.ToMat().convert(frame);
        cvFrame.data().get(buf);
        int ret = feedFrame(trackerPointer, buf);
        if (ret != 0) {
            break;
        }
        ++cnt;
        if (cnt % 1000 == 0) {
            logger.debug("Tracked " + cnt + " frames!");
        }
    }

    logger.debug("Totally processed " + cnt + " framed!");
    logger.debug("Getting targets...");
    Tracklet[] targets = getTargets(trackerPointer);
    logger.debug("Got " + targets.length + " targets!");
    free(trackerPointer);

    for (int i = 0; i < targets.length; ++i) {
        targets[i].numTracklets = targets.length;
        targets[i].id.serialNumber = i;
    }

    return targets;
}
 
开发者ID:kyu-sz,项目名称:LaS-VPE-Platform,代码行数:58,代码来源:BasicTracker.java

示例8: open

import org.bytedeco.javacv.FFmpegFrameGrabber; //导入依赖的package包/类
@Override
public void open(Map map, TopologyContext topologyContext, SpoutOutputCollector spoutOutputCollector) {

    frameId = 0;
    sampleID = 0;
    sampleFrames = ConfigUtil.getInt(map, "sampleFrames", 1);

    firstFrameId = getInt(map, "firstFrameId");
    lastFrameId = getInt(map, "lastFrameId");
    SOURCE_FILE = getString(map, "videoSourceFile");
    grabber = new FFmpegFrameGrabber(SOURCE_FILE);
    System.out.println("Created capture: " + SOURCE_FILE);

    W = ConfigUtil.getInt(map, "width", 640);
    H = ConfigUtil.getInt(map, "height", 480);

    delayInMS = getInt(map, "inputFrameDelay");

    this.collector = spoutOutputCollector;
    try {
        grabber.start();
        while (++frameId < firstFrameId)
            grabber.grab();

    } catch (FrameGrabber.Exception e) {
        e.printStackTrace();
    }

    //kp.deallocate();

    if (Debug.topologyDebugOutput)
        System.out.println("Grabber started");

    if (Debug.timer)
        System.out.println("TIME=" + System.currentTimeMillis());

    //TODO: caustion, for RedisStreamProducerBeta version, we reajust the start and end frameID!!!
    int diff = lastFrameId - firstFrameId + 1;
    frameId = 0;
    endFrameID = frameId + diff;
    openTimeStamp = System.currentTimeMillis();

}
 
开发者ID:ADSC-Resa,项目名称:resa,代码行数:44,代码来源:tomFrameSpoutResizeFox.java

示例9: FFMpegFrameFinder

import org.bytedeco.javacv.FFmpegFrameGrabber; //导入依赖的package包/类
public FFMpegFrameFinder(File file) throws FrameGrabber.Exception {
frameGrabber = new FFmpegFrameGrabber(file);
converter = new Java2DFrameConverter();
frameGrabber.start();
   }
 
开发者ID:samcrow,项目名称:FrameViewer-AnTracks,代码行数:6,代码来源:FFMpegFrameFinder.java


注:本文中的org.bytedeco.javacv.FFmpegFrameGrabber类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。