本文整理汇总了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");
}
}