本文整理汇总了Java中com.xuggle.xuggler.IPacket类的典型用法代码示例。如果您正苦于以下问题:Java IPacket类的具体用法?Java IPacket怎么用?Java IPacket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IPacket类属于com.xuggle.xuggler包,在下文中一共展示了IPacket类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addImage
import com.xuggle.xuggler.IPacket; //导入依赖的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: readPacket
import com.xuggle.xuggler.IPacket; //导入依赖的package包/类
public AVPacket readPacket() {
IPacket packet = IPacket.make();
XugglerPacket xpacket = null;
if (this.container.readNextPacket(packet) >= 0) {
printPacketInfo(packet);
xpacket = new XugglerPacket(packet,
streamTypes[packet.getStreamIndex()]);
} else
finished = true;
if (xpacket != null) {
// calc position of the packet relative to the whole video
long pos = xpacket.getPosition() - decompressor.getHeaderSize()
+ getAdjustedStart();
xpacket.setPosition(pos);
xpacket.setFrameNo(xpacket.getFrameNo() + getFrameOffset());
LOG.debug("readPacket, frame no " + xpacket.getFrameNo());
}
return xpacket;
}
开发者ID:openpreserve,项目名称:video-batch,代码行数:23,代码来源:XugglerInputStream.java
示例3: encode
import com.xuggle.xuggler.IPacket; //导入依赖的package包/类
public void encode( AVPacket packet ) {
IPacket ipacket = (IPacket)packet.getPacket();
int streamNum = ipacket.getStreamIndex();
ipacket = IPacket.make();
printPacketInfo(ipacket);
IVideoPicture picture = (IVideoPicture)packet.getDecodedObject();
if( picture == null ) {
LOG.debug("Picture is null" );
return;
} else
{
printPictureInfo(picture);
}
if( streamNum < outStreams.length ) {
LOG.debug( "Coder Bitrate: " + outStreams[streamNum].getStreamCoder().getBitRate());
LOG.debug( "Coder Name: " + outStreams[streamNum].getStreamCoder().getCodec().getName());
int retVal = outStreams[streamNum].getStreamCoder().encodeVideo( ipacket, picture, -1);
LOG.debug("encoding, retval = " + retVal );
if( ipacket.isComplete() )
{
//packet = new XugglerPacket( ipacket, ICodec.Type.CODEC_TYPE_VIDEO );
packet.setPacket( ipacket );
}
}
}
开发者ID:openpreserve,项目名称:video-batch,代码行数:27,代码来源:XugglerOutputStream.java
示例4: XugglerPacket
import com.xuggle.xuggler.IPacket; //导入依赖的package包/类
public XugglerPacket(IPacket packet, ICodec.Type type) {
this.packet = packet;
setPosition(packet.getPosition());
setFrameNo(packet.getPts());
switch (type) {
case CODEC_TYPE_ATTACHMENT:
this.streamType = AVPacket.StreamType.UNKNOWN;
break;
case CODEC_TYPE_AUDIO:
this.streamType = AVPacket.StreamType.AUDIO;
break;
case CODEC_TYPE_DATA:
this.streamType = AVPacket.StreamType.UNKNOWN;
break;
case CODEC_TYPE_SUBTITLE:
this.streamType = AVPacket.StreamType.UNKNOWN;
break;
case CODEC_TYPE_UNKNOWN:
this.streamType = AVPacket.StreamType.UNKNOWN;
break;
case CODEC_TYPE_VIDEO:
this.streamType = AVPacket.StreamType.VIDEO;
break;
}
}
开发者ID:openpreserve,项目名称:video-batch,代码行数:26,代码来源:XugglerPacket.java
示例5: encodeImage
import com.xuggle.xuggler.IPacket; //导入依赖的package包/类
/**
* Encodes an image and writes it to the output stream.
*
* @param image the image to encode (must be BufferedImage.TYPE_3BYTE_BGR)
* @param pixelType the pixel type
* @param timeStamp the time stamp in microseconds
* @throws IOException
*/
private boolean encodeImage(BufferedImage image, IPixelFormat.Type pixelType, long timeStamp)
throws IOException {
// convert image to xuggle picture
IVideoPicture picture = getPicture(image, pixelType, timeStamp);
if (picture==null)
throw new RuntimeException("could not convert to picture"); //$NON-NLS-1$
// make a packet
IPacket packet = IPacket.make();
if (outStreamCoder.encodeVideo(packet, picture, 0) < 0) {
throw new RuntimeException("could not encode video"); //$NON-NLS-1$
}
if (packet.isComplete()) {
boolean forceInterleave = true;
if (outContainer.writePacket(packet, forceInterleave) < 0) {
throw new RuntimeException("could not save packet to container"); //$NON-NLS-1$
}
return true;
}
return false;
}
开发者ID:OpenSourcePhysics,项目名称:video-engines,代码行数:29,代码来源:XuggleVideoRecorder.java
示例6: loadPacket
import com.xuggle.xuggler.IPacket; //导入依赖的package包/类
/**
* Loads a video packet into the current Xuggle picture.
*
* @param packet the packet
* @return true if successfully loaded
*/
private boolean loadPacket(IPacket packet) {
int offset = 0;
int size = packet.getSize();
while(offset < size) {
// decode the packet into the picture
int bytesDecoded = videoCoder.decodeVideo(picture, packet, offset);
// check for errors
if (bytesDecoded < 0)
return false;
offset += bytesDecoded;
if (picture.isComplete()) {
return true;
}
}
return true;
}
开发者ID:OpenSourcePhysics,项目名称:video-engines,代码行数:24,代码来源:XuggleVideo.java
示例7: run
import com.xuggle.xuggler.IPacket; //导入依赖的package包/类
public void run() {
while (doStream) {
IVideoPicture frame = frames.poll();
if (frame != null) {
// mark as keyframe
//frame.setKeyFrame(i % keyFrameInterval == 0);
//frame.setQuality(0);
IPacket packet = IPacket.make();
try {
coder.encodeVideo(packet, frame, 0);
if (packet.isComplete()) {
container.writePacket(packet);
}
} finally {
frame.delete();
if (packet != null) {
packet.delete();
}
}
} else {
try {
Thread.sleep(16L);
} catch (InterruptedException e) {
}
}
}
System.out.println("Frame worker exit");
}
开发者ID:BigMarker,项目名称:deskshare-public,代码行数:29,代码来源:ScreenCap.java
示例8: loadFirstFrame
import com.xuggle.xuggler.IPacket; //导入依赖的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
示例9: initialize
import com.xuggle.xuggler.IPacket; //导入依赖的package包/类
/**
* Initializes the reader thread with the given media.
* @param container the media container
* @param videoCoder the media video decoder
* @param audioCoder the media audio decoder
* @param audioConversions the flag(s) for any audio conversions to must take place
*/
public void initialize(IContainer container, IStreamCoder videoCoder, IStreamCoder audioCoder, int audioConversions) {
// assign the local variables
this.outputWidth = 0;
this.outputHeight = 0;
this.videoConversionEnabled = false;
this.scale = false;
this.container = container;
this.videoCoder = videoCoder;
this.audioCoder = audioCoder;
this.audioConversions = audioConversions;
// create a packet for reading
this.packet = IPacket.make();
// create the image converter for the video
if (videoCoder != null) {
this.width = this.videoCoder.getWidth();
this.height = this.videoCoder.getHeight();
IPixelFormat.Type type = this.videoCoder.getPixelType();
this.picture = IVideoPicture.make(type, this.width, this.height);
BufferedImage target = new BufferedImage(this.width, this.height, BufferedImage.TYPE_3BYTE_BGR);
this.videoConverter = ConverterFactory.createConverter(target, type);
}
// create a resuable container for the samples
if (audioCoder != null) {
this.samples = IAudioSamples.make(1024, this.audioCoder.getChannels());
}
}
开发者ID:wnbittle,项目名称:praisenter,代码行数:37,代码来源:XugglerMediaReaderThread.java
示例10: close
import com.xuggle.xuggler.IPacket; //导入依赖的package包/类
public void close(){
if(writer != null){
// write last packets
IPacket packet = IPacket.make();
do{
coder.encodeVideo(packet, null, 0);
if(packet.isComplete()){
writer.writePacket(packet);
}
}while(packet.isComplete());
writer.flushPackets();
writer.close();
writer = null;
coder = null;
fileCount++;
frameCount = 0;
// move video to final location (can be remote!)
if(location != null) try {
connector.moveTo(location+currentFile.getName());
logger.info("Moving video to final location: "+location+currentFile.getName());
connector.copyFile(currentFile, true);
} catch (IOException e) {
logger.error("Unable to move file to final destinaiton: location", e);
}
}
}
开发者ID:sensorstorm,项目名称:StormCV,代码行数:28,代码来源:StreamWriter.java
示例11: printPacketInfo
import com.xuggle.xuggler.IPacket; //导入依赖的package包/类
private void printPacketInfo(IPacket packet) {
String packet_info = "";
packet_info += "Packet: ";
packet_info += String.format("position = %d;", packet.getPosition());
packet_info += String.format("isKey = %s;", packet.isKey());
packet_info += String.format("stream_index = %d;",
packet.getStreamIndex());
packet_info += String.format("size = %d;", packet.getSize());
LOG.debug(packet_info);
}
开发者ID:openpreserve,项目名称:video-batch,代码行数:11,代码来源:XugglerInputStream.java
示例12: writeBufferedImage
import com.xuggle.xuggler.IPacket; //导入依赖的package包/类
public boolean writeBufferedImage( BufferedImage image ) {
BufferedImage worksWithXugglerBufferedImage = XugglerPacket.convertToType(
image, BufferedImage.TYPE_3BYTE_BGR);
IPacket packet = IPacket.make();
//IConverter converter = ConverterFactory.createConverter(
//worksWithXugglerBufferedImage, compressor.);
return false;
}
开发者ID:openpreserve,项目名称:video-batch,代码行数:10,代码来源:XugglerOutputStream.java
示例13: printPacketInfo
import com.xuggle.xuggler.IPacket; //导入依赖的package包/类
private void printPacketInfo(IPacket packet) {
String packet_info = "";
packet_info += "Packet: ";
packet_info += String.format("pts = %d;", packet.getPts());
packet_info += String.format("position = %d;", packet.getPosition());
packet_info += String.format("isKey = %s;", packet.isKey());
packet_info += String.format("stream_index = %d;",
packet.getStreamIndex());
packet_info += String.format("size = %d;", packet.getSize());
//System.out.println(packet_info);
LOG.debug(packet_info);
}
开发者ID:openpreserve,项目名称:video-batch,代码行数:13,代码来源:XugglerOutputStream.java
示例14: setFrameNo
import com.xuggle.xuggler.IPacket; //导入依赖的package包/类
@Override
public void setFrameNo(long frame_no) {
this.frame_no = frame_no;
// TODO: we should not set Pts and Dts that way. The Coder should calculate the right values.
if( this.packet != null ) {
((IPacket)this.packet).setPts( frame_no );
((IPacket)this.packet).setDts( frame_no );
}
if( this.decoded_object != null )
((IVideoPicture)this.decoded_object).setPts( frame_no * 40000 );
}
开发者ID:openpreserve,项目名称:video-batch,代码行数:12,代码来源:XugglerPacket.java
示例15: addImage
import com.xuggle.xuggler.IPacket; //导入依赖的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
示例16: isKeyPacket
import com.xuggle.xuggler.IPacket; //导入依赖的package包/类
/**
* Determines if a packet is a key packet.
*
* @param packet the packet
* @return true if packet is a key in the video stream
*/
private boolean isKeyPacket(IPacket packet) {
if (isVideoPacket(packet)
&& packet.isKeyPacket()) {
return true;
}
return false;
}
开发者ID:OpenSourcePhysics,项目名称:video-engines,代码行数:14,代码来源:XuggleVideo.java
示例17: isVideoPacket
import com.xuggle.xuggler.IPacket; //导入依赖的package包/类
/**
* Determines if a packet is a video packet.
*
* @param packet the packet
* @return true if packet is in the video stream
*/
private boolean isVideoPacket(IPacket packet) {
if (packet.getStreamIndex() == streamIndex) {
return true;
}
return false;
}
开发者ID:OpenSourcePhysics,项目名称:video-engines,代码行数:13,代码来源:XuggleVideo.java
示例18: encodeVideo
import com.xuggle.xuggler.IPacket; //导入依赖的package包/类
public void encodeVideo(IVideoPicture picture, long timeStamp, TimeUnit timeUnit) {
log.debug("encodeVideo {}", outputUrl);
// establish the stream, return silently if no stream returned
if (null != picture) {
IPacket videoPacket = IPacket.make();
// encode video picture
int result = videoCoder.encodeVideo(videoPacket, picture, 0);
//System.out.printf("Flags v: %08x\n", videoCoder.getFlags());
if (result < 0) {
log.error("{} Failed to encode video: {} picture: {}", new Object[] { result, getErrorMessage(result), picture });
videoPacket.delete();
return;
}
videoComplete = videoPacket.isComplete();
if (videoComplete) {
final long timeStampMicro;
if (timeUnit == null) {
timeStampMicro = Global.NO_PTS;
} else {
timeStampMicro = MICROSECONDS.convert(timeStamp, timeUnit);
}
log.trace("Video timestamp {} us", timeStampMicro);
// write packet
writePacket(videoPacket);
// add the duration of our video
double dur = (timeStampMicro + videoPacket.getDuration() - prevVideoTime) / 1000000d;
videoDuration += dur;
log.trace("Duration - video: {}", dur);
//double videoPts = (double) videoPacket.getDuration() * videoCoder.getTimeBase().getNumerator() / videoCoder.getTimeBase().getDenominator();
//log.trace("Video pts - calculated: {} reported: {}", videoPts, videoPacket.getPts());
prevVideoTime = timeStampMicro;
videoPacket.delete();
} else {
log.warn("Video packet was not complete");
}
} else {
throw new IllegalArgumentException("No picture");
}
}
开发者ID:Red5,项目名称:red5-hls-plugin,代码行数:40,代码来源:HLSStreamWriter.java
示例19: writePacket
import com.xuggle.xuggler.IPacket; //导入依赖的package包/类
/**
* Write packet to the output container
*
* @param packet the packet to write out
*/
private void writePacket(IPacket packet) {
log.trace("write packet - duration: {} timestamp: {}", packet.getDuration(), packet.getTimeStamp());
if (createNewSegment()) {
log.trace("New segment created: {}", facade.getActiveSegmentIndex());
}
if (container.writePacket(packet, forceInterleave) < 0) {
log.warn("Failed to write packet: {} force interleave: {}", packet, forceInterleave);
}
container.flushPackets();
//packet.delete();
}
开发者ID:Red5,项目名称:red5-hls-plugin,代码行数:17,代码来源:HLSStreamWriter.java
示例20: decode
import com.xuggle.xuggler.IPacket; //导入依赖的package包/类
public void decode(AVPacket packet) {
IPacket p = (IPacket) packet.getPacket();
packet.setDecodedObject(decodePacket(p));
}
开发者ID:openpreserve,项目名称:video-batch,代码行数:5,代码来源:XugglerInputStream.java
注:本文中的com.xuggle.xuggler.IPacket类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论