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


Java IPacket.getDuration方法代码示例

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


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

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