• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java IConverter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: addImage

import com.xuggle.xuggler.video.IConverter; //导入依赖的package包/类
/**
 * Adds an image as a frame to the current video
 * @param image
 */
private void addImage(BufferedImage image){
	IPacket packet = IPacket.make();
	IConverter converter = ConverterFactory.createConverter(image, coder.getPixelType());
	IVideoPicture frame = converter.toPicture(image, Math.round(frameTime));
	
	if (coder.encodeVideo(packet, frame, 0) < 0) {
		throw new RuntimeException("Unable to encode video.");
	}
	
	if (packet.isComplete()) {
		if (writer.writePacket(packet) < 0) {
			throw new RuntimeException("Could not write packet to container.");
		}
	}
       this.frameTime += 1000000f/frameRate;
       frameCount++;
}
 
开发者ID:sensorstorm,项目名称:StormCV,代码行数:22,代码来源:StreamWriter.java


示例2: getConverter

import com.xuggle.xuggler.video.IConverter; //导入依赖的package包/类
/**
  * Gets the converter for converting images to pictures. 
  *
  * @param bgrImage the source image (must be type TYPE_3BYTE_BGR)
  * @param pixelType the desired pixel type
  */
private IConverter getConverter(BufferedImage bgrImage, IPixelFormat.Type pixelType){
	int w = bgrImage.getWidth();
	int h = bgrImage.getHeight();
	if (converterDim==null) {
		converterDim = new Dimension(w, h);
	}
	if (outConverter==null || w!=converterDim.width || h!=converterDim.height
			|| outConverter.getPictureType()!= pixelType) {
		try {
			outConverter = ConverterFactory.createConverter(bgrImage, pixelType);
			converterDim = new Dimension(w, h);
		} catch(UnsupportedOperationException e){
			System.err.println(e.getMessage());
			e.printStackTrace();
		}
	}
	return outConverter;
}
 
开发者ID:OpenSourcePhysics,项目名称:video-engines,代码行数:25,代码来源:XuggleVideoRecorder.java


示例3: recordFrame

import com.xuggle.xuggler.video.IConverter; //导入依赖的package包/类
public void recordFrame(BufferedImage frame) {
	final BufferedImage image = ConverterFactory.convertToType(frame, BufferedImage.TYPE_3BYTE_BGR);
	final IConverter converter = ConverterFactory.createConverter(image, IPixelFormat.Type.YUV420P);

	timestamp = (System.currentTimeMillis() - startTime) + timeOffset;

	final IVideoPicture f = converter.toPicture(image, timestamp * 1000);
	f.setKeyFrame(isFirstShotFrame);
	f.setQuality(0);

	if (forking) {
		synchronized (bufferedFrames) {
			bufferedFrames.add(f);
		}
	} else {
		isFirstShotFrame = false;

		synchronized (videoWriterLock) {
			if (recording)
				videoWriter.encodeVideo(0, f);
		}

		if (timestamp >= ShotRecorder.RECORD_LENGTH * 3) {
			logger.debug("Rolling video file {}, timestamp = {} ms", relativeVideoFile.getPath(), timestamp);
			fork(false);
		}
	}
}
 
开发者ID:phrack,项目名称:ShootOFF,代码行数:29,代码来源:RollingRecorder.java


示例4: recordFrame

import com.xuggle.xuggler.video.IConverter; //导入依赖的package包/类
public void recordFrame(BufferedImage frame) {
	final BufferedImage image = ConverterFactory.convertToType(frame, BufferedImage.TYPE_3BYTE_BGR);
	final IConverter converter = ConverterFactory.createConverter(image, IPixelFormat.Type.YUV420P);

	final long timestamp = (System.currentTimeMillis() - startTime) + timeOffset;

	final IVideoPicture f = converter.toPicture(image, timestamp * 1000);
	f.setKeyFrame(isFirstShotFrame);
	f.setQuality(0);
	isFirstShotFrame = false;

	videoWriter.encodeVideo(0, f);
}
 
开发者ID:phrack,项目名称:ShootOFF,代码行数:14,代码来源:ShotRecorder.java


示例5: loadFirstFrame

import com.xuggle.xuggler.video.IConverter; //导入依赖的package包/类
/**
 * Loads the first frame of the given video and then seeks back to the beginning of the stream.
 * @param container the video container
 * @param videoCoder the video stream coder
 * @return BufferedImage
 * @throws MediaException thrown if an error occurs during decoding
 */
private BufferedImage loadFirstFrame(IContainer container, IStreamCoder videoCoder) throws MediaException {
	// walk through each packet of the container format
	IPacket packet = IPacket.make();
	while (container.readNextPacket(packet) >= 0) {
		// make sure the packet belongs to the stream we care about
		if (packet.getStreamIndex() == videoCoder.getStream().getIndex()) {
			// create a new picture for the video data to be stored in
			IVideoPicture picture = IVideoPicture.make(videoCoder.getPixelType(), videoCoder.getWidth(), videoCoder.getHeight());
			int offset = 0;
			// decode the video
			while (offset < packet.getSize()) {
				int bytesDecoded = videoCoder.decodeVideo(picture, packet, offset);
				if (bytesDecoded < 0) {
					LOGGER.error("No bytes found in container.");
					throw new MediaException();
				}
				offset += bytesDecoded;

				// make sure that we have a full picture from the video first
				if (picture.isComplete()) {
					// convert the picture to an Java buffered image
					BufferedImage target = new BufferedImage(picture.getWidth(), picture.getHeight(), BufferedImage.TYPE_3BYTE_BGR);
					IConverter converter = ConverterFactory.createConverter(target, picture.getPixelType());
					return converter.toImage(picture);
				}
			}
		}
	}
	
	return null;
}
 
开发者ID:wnbittle,项目名称:praisenter,代码行数:39,代码来源:XugglerVideoMediaLoader.java


示例6: addImage

import com.xuggle.xuggler.video.IConverter; //导入依赖的package包/类
/**
 * Add new image into video stream.
 */
@Override
public void addImage(final Image image) throws IOException {
    if (!isOpen()) {
        throw new IOException("Current object does not opened yet! Please call #open() method!");
    }

    final BufferedImage worksWithXugglerBufferedImage = convertToType(TypeConvert.toBufferedImage(image),
            BufferedImage.TYPE_3BYTE_BGR);
    final IPacket packet = IPacket.make();

    IConverter converter = null;
    try {
        converter = ConverterFactory.createConverter(worksWithXugglerBufferedImage, IPixelFormat.Type.YUV420P);
    } catch (final UnsupportedOperationException e) {
        throw new IOException(e.getMessage());
    }

    this.totalTimeStamp += this.incrementTimeStamp;
    final IVideoPicture outFrame = converter.toPicture(worksWithXugglerBufferedImage, this.totalTimeStamp);
    outFrame.setQuality(0);
    int retval = this.outStreamCoder.encodeVideo(packet, outFrame, 0);
    if (retval < 0) {
        throw new IOException("Could not encode video!");
    }

    if (packet.isComplete()) {
        retval = this.outContainer.writePacket(packet);
        if (retval < 0) {
            throw new IOException("Could not save packet to container!");
        }
    }
}
 
开发者ID:dzavodnikov,项目名称:JcvLib,代码行数:36,代码来源:VideoFileWriter.java


示例7: getPicture

import com.xuggle.xuggler.video.IConverter; //导入依赖的package包/类
/**
  * Converts a bgr source image to a xuggle picture.
  *
  * @param bgrImage the source image (must be type TYPE_3BYTE_BGR)
  * @param pixelType the pixel type
  * @param timeStamp the timestamp in microseconds
  * @return the xuggle picture
  */
private IVideoPicture getPicture(BufferedImage bgrImage, IPixelFormat.Type pixelType, long timeStamp) {
	
	IVideoPicture picture = null;
	try {
		IConverter converter = getConverter(bgrImage, pixelType);
		picture = converter.toPicture(bgrImage, timeStamp);
		picture.setQuality(0);		
	} catch (Exception ex) {
		ex.printStackTrace();
	} catch (Error err) {
		err.printStackTrace();
	}
	return picture;
 }
 
开发者ID:OpenSourcePhysics,项目名称:video-engines,代码行数:23,代码来源:XuggleVideoRecorder.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EMClient类代码示例发布时间:2022-05-22
下一篇:
Java ChildProcessConnection类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap