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


Java IPacket.isComplete方法代码示例

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


在下文中一共展示了IPacket.isComplete方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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


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