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


Java H264Utils.createMOVSampleEntry方法代码示例

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


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

示例1: Transcode2AVCTrack

import org.jcodec.codecs.h264.H264Utils; //导入方法依赖的package包/类
public Transcode2AVCTrack(VirtualTrack src, Size frameDim) {
    checkFourCC(src);
    this.src = src;
    ConstantRateControl rc = new ConstantRateControl(TARGET_RATE);
    H264Encoder encoder = new H264Encoder(rc);

    scaleFactor = selectScaleFactor(frameDim);
    thumbWidth = frameDim.getWidth() >> scaleFactor;
    thumbHeight = (frameDim.getHeight() >> scaleFactor) & ~1;

    mbW = (thumbWidth + 15) >> 4;
    mbH = (thumbHeight + 15) >> 4;

    se = H264Utils.createMOVSampleEntry(encoder.initSPS(new Size(thumbWidth, thumbHeight)), encoder.initPPS());
    PixelAspectExt pasp = Box.findFirst(src.getSampleEntry(), PixelAspectExt.class, "pasp");
    if (pasp != null)
        se.add(pasp);

    frameSize = rc.calcFrameSize(mbW * mbH);
    frameSize += frameSize >> 4;
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:22,代码来源:Transcode2AVCTrack.java

示例2: Mpeg2AVCTrack

import org.jcodec.codecs.h264.H264Utils; //导入方法依赖的package包/类
public Mpeg2AVCTrack(VirtualTrack src) throws IOException {
    checkFourCC(src);
    this.src = src;
    ConstantRateControl rc = new ConstantRateControl(TARGET_RATE);
    H264Encoder encoder = new H264Encoder(rc);

    nextPacket = src.nextPacket();
    Size frameDim = MPEGDecoder.getSize(nextPacket.getData());

    scaleFactor = selectScaleFactor(frameDim);
    thumbWidth = frameDim.getWidth() >> scaleFactor;
    thumbHeight = (frameDim.getHeight() >> scaleFactor) & ~1;

    mbW = (thumbWidth + 15) >> 4;
    mbH = (thumbHeight + 15) >> 4;

    se = H264Utils.createMOVSampleEntry(encoder.initSPS(new Size(thumbWidth, thumbHeight)), encoder.initPPS());
    PixelAspectExt pasp = Box.findFirst(src.getSampleEntry(), PixelAspectExt.class, "pasp");
    if (pasp != null)
        se.add(pasp);

    frameSize = rc.calcFrameSize(mbW * mbH);
    frameSize += frameSize >> 4;
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:25,代码来源:Mpeg2AVCTrack.java

示例3: AVCConcatTrack

import org.jcodec.codecs.h264.H264Utils; //导入方法依赖的package包/类
public AVCConcatTrack(VirtualTrack... tracks) {
    this.tracks = tracks;

    avcCs = new AvcCBox[tracks.length];
    PixelAspectExt pasp = null;

    allPps = new ArrayList<PictureParameterSet>();
    allSps = new ArrayList<SeqParameterSet>();
    tweakers = new H264Utils.SliceHeaderTweaker[tracks.length];
    for (int i = 0; i < tracks.length; i++) {
        SampleEntry se = tracks[i].getSampleEntry();
        if (!(se instanceof VideoSampleEntry))
            throw new RuntimeException("Not a video track.");
        if (!"avc1".equals(se.getFourcc()))
            throw new RuntimeException("Not an AVC track.");

        PixelAspectExt paspL = Box.findFirst(se, PixelAspectExt.class, "pasp");
        if (pasp != null && paspL != null && !pasp.getRational().equals(paspL.getRational()))
            throw new RuntimeException("Can not concat video tracks with different Pixel Aspect Ratio.");
        pasp = paspL;

        AvcCBox avcC = H264Utils.parseAVCC((VideoSampleEntry) se);
        for (ByteBuffer ppsBuffer : avcC.getPpsList()) {
            PictureParameterSet pps = H264Utils.readPPS(NIOUtils.duplicate(ppsBuffer));
            pps.pic_parameter_set_id |= i << 8;
            pps.seq_parameter_set_id |= i << 8;
            allPps.add(pps);
        }
        for (ByteBuffer spsBuffer : avcC.getSpsList()) {
            SeqParameterSet sps = H264Utils.readSPS(NIOUtils.duplicate(spsBuffer));
            sps.seq_parameter_set_id |= i << 8;
            allSps.add(sps);
        }
        final int idx2 = i;
        tweakers[i] = new H264Utils.SliceHeaderTweaker(avcC.getSpsList(), avcC.getPpsList()) {
            protected void tweak(SliceHeader sh) {
                sh.pic_parameter_set_id = map.get((idx2 << 8) | sh.pic_parameter_set_id);
            }
        };
        avcCs[i] = avcC;
    }
    map = mergePS(allSps, allPps);

    se = H264Utils.createMOVSampleEntry(writeSPS(allSps), writePPS(allPps));
    if (pasp != null)
        se.add(pasp);
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:48,代码来源:AVCConcatTrack.java


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