本文整理汇总了Java中com.xuggle.xuggler.IVideoPicture.isComplete方法的典型用法代码示例。如果您正苦于以下问题:Java IVideoPicture.isComplete方法的具体用法?Java IVideoPicture.isComplete怎么用?Java IVideoPicture.isComplete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.xuggle.xuggler.IVideoPicture
的用法示例。
在下文中一共展示了IVideoPicture.isComplete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadFirstFrame
import com.xuggle.xuggler.IVideoPicture; //导入方法依赖的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;
}
示例2: onVideoPicture
import com.xuggle.xuggler.IVideoPicture; //导入方法依赖的package包/类
@Override
public void onVideoPicture(IVideoPictureEvent event) {
log.debug("Adjust onVideo");
IVideoPicture in = event.getPicture();
log.debug("Video ts: {}", in.getFormattedTimeStamp());
int inWidth = in.getWidth();
int inHeight = in.getHeight();
if (inHeight != height || inWidth != width) {
log.debug("VideoAdjustTool onVideoPicture");
log.trace("Video timestamp: {} pixel type: {}", event.getTimeStamp(), in.getPixelType());
log.trace("Video in: {} x {} out: {} x {}", new Object[] { inWidth, inHeight, width, height });
if (resampler == null) {
resampler = IVideoResampler.make(width, height, pixelType, inWidth, inHeight, in.getPixelType());
log.debug("Video resampler: {}", resampler);
}
if (resampler != null) {
IVideoPicture out = IVideoPicture.make(pixelType, width, height);
if (resampler.resample(out, in) >= 0) {
//check complete
if (out.isComplete()) {
// queue video
facade.queueVideo(out, event.getTimeStamp(), event.getTimeUnit());
in.delete();
} else {
log.warn("Resampled picture was not marked as complete");
}
} else {
log.warn("Resample failed");
}
out.delete();
} else {
log.debug("Resampler was null");
}
log.debug("VideoAdjustTool onVideoPicture - end");
} else {
// queue video
facade.queueVideo(in, event.getTimeStamp(), event.getTimeUnit());
}
}
示例3: decodeVideoPacket
import com.xuggle.xuggler.IVideoPicture; //导入方法依赖的package包/类
/**
* Decode a Video Packet. Taken from Xuggler Demo file for Video decoding.
* @param packet
* @return
*/
private IVideoPicture decodeVideoPacket(IPacket packet) {
int c = 0;
for (c = 0; c < coder.length; c++)
if (coder[c] != null
&& coder[c].getCodecType() == ICodec.Type.CODEC_TYPE_VIDEO)
break;
if (c >= coder.length)
return null;
IStreamCoder videoCoder = coder[c];
/*
* We allocate a new picture to get the data out of Xuggler
*/
IVideoPicture picture = IVideoPicture.make(videoCoder.getPixelType(),
videoCoder.getWidth(), videoCoder.getHeight());
if (!videoCoder.isOpen()) {
int o = videoCoder.open();
if (o < 0)
LOG.debug("error on open VideoCoder = " + o);
//setResampler(videoCoder);
}
int offset = 0;
while (offset < packet.getSize()) {
/*
* Now, we decode the video, checking for any errors.
*/
int bytesDecoded = videoCoder.decodeVideo(picture, packet, offset);
if (bytesDecoded < 0)
throw new RuntimeException("got error decoding video in: "
+ packet.getPosition());
offset += bytesDecoded;
/*
* Some decoders will consume data in a packet, but will not be able
* to construct a full video picture yet. Therefore you should
* always check if you got a complete picture from the decoder
*/
if (picture.isComplete()) {
IVideoPicture newPic = picture;
/*
* If the resampler is not null, that means we didn't get the
* video in BGR24 format and need to convert it into BGR24
* format.
*/
if (resampler != null) {
// we must resample
newPic = IVideoPicture.make(
resampler.getOutputPixelFormat(),
picture.getWidth(), picture.getHeight());
if (resampler.resample(newPic, picture) < 0)
throw new RuntimeException(
"could not resample video from: "
+ packet.getPosition());
}
return newPic;
}
}
return null;
}