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


Java SeekableByteChannel.close方法代码示例

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


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

示例1: dumpHeader

import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
private static void dumpHeader(File headerFile, File source) throws IOException, FileNotFoundException {
    SeekableByteChannel raf = null;
    SeekableByteChannel daos = null;
    try {
        raf = readableFileChannel(source);
        daos = writableFileChannel(headerFile);

        for (Atom atom : MP4Util.getRootAtoms(raf)) {
            String fourcc = atom.getHeader().getFourcc();
            if ("moov".equals(fourcc) || "ftyp".equals(fourcc)) {
                atom.copy(raf, daos);
            }
        }
    } finally {
        raf.close();
        daos.close();
    }
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:19,代码来源:MovDump.java

示例2: list

import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
private List<Atom> list(String fileName) throws IOException {
    ArrayList<Atom> result = new ArrayList<Atom>();
    SeekableByteChannel is = null;
    try {
        is = readableFileChannel(new File(fileName));
        int version = 0;
        for (Atom atom : MP4Util.getRootAtoms(is)) {
            if ("free".equals(atom.getHeader().getFourcc()) && isMoov(is, atom)) {
                result.add(atom);
            }
            if ("moov".equals(atom.getHeader().getFourcc())) {
                result.add(atom);
                break;
            }
        }
    } finally {
        is.close();
    }
    return result;
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:21,代码来源:Undo.java

示例3: getData

import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
@Override
public ByteBuffer getData() throws IOException {
    ByteBuffer bb = ByteBuffer.allocate(packet.getSize());
    SeekableByteChannel ch = null;
    try {
        ch = pool.getChannel();
        if(packet.getFileOff() >= ch.size())
            return null;
        ch.position(packet.getFileOff());
        ch.read(bb);
        bb.flip();
        return bb;
    } finally {
        if (ch != null)
            ch.close();
    }
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:18,代码来源:RealTrack.java

示例4: main

import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    if (args.length < 2) {
        System.out.println("Syntax: self <ref movie> <out movie>");
        System.exit(-1);
    }
    File outFile = new File(args[1]);
    outFile.delete();
    SeekableByteChannel input = null;
    try {
        input = readableFileChannel(new File(args[0]));
        MovieBox movie = MP4Util.parseMovie(input);
        new Flattern().flattern(movie, outFile);
    } finally {
        if (input != null)
            input.close();
    }
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:18,代码来源:Flattern.java

示例5: webOptimize

import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
public static void webOptimize(String path) throws IOException {
    File orig = new File(path);
    SeekableByteChannel input = NIOUtils.readableFileChannel(orig);
    MovieBox movie = MP4Util.createRefMovie(input, "file://" + orig.getCanonicalPath());

    File optim = new File(path + "_optim");
    new Flattern().flattern(movie, optim);
    input.close();

    Files.move(Paths.get(path + "_optim"), Paths.get(path), StandardCopyOption.REPLACE_EXISTING); // doesn't work on DOS
}
 
开发者ID:Helioviewer-Project,项目名称:JHelioviewer-SWHV,代码行数:12,代码来源:JCodecUtils.java

示例6: parseMovie

import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
public static MovieBox parseMovie(File source) throws IOException {
    SeekableByteChannel input = null;
    try {
        input = readableFileChannel(source);
        return parseMovie(input);
    } finally {
        if (input != null)
            input.close();
    }
}
 
开发者ID:ihmcrobotics,项目名称:ihmc-video-codecs,代码行数:11,代码来源:MP4Util.java

示例7: createRefMovie

import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
public static MovieBox createRefMovie(File source) throws IOException {
    SeekableByteChannel input = null;
    try {
        input = readableFileChannel(source);
        return createRefMovie(input, "file://" + source.getCanonicalPath());
    } finally {
        if (input != null)
            input.close();
    }
}
 
开发者ID:ihmcrobotics,项目名称:ihmc-video-codecs,代码行数:11,代码来源:MP4Util.java

示例8: save

import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
public boolean save(File f) throws IOException, Exception {
    SeekableByteChannel fi = null;
    try {
        fi = NIOUtils.rwFileChannel(f);
        Atom moov = getMoov(fi);
        Assert.assertNotNull(moov);

        fi.position(moov.getOffset());
        ByteBuffer oldMov = NIOUtils.fetchFrom(fi, (int) moov.getHeader().getSize());
        Header header = Header.read(oldMov);
        MovieBox movBox = (MovieBox) NodeBox.parseBox(oldMov, header, BoxFactory.getDefault());

        apply(movBox);
        
        oldMov.clear();

        try {
            movBox.write(oldMov);
        } catch (Exception e) {
            return false;
        }
        if (oldMov.hasRemaining()) {
            if (oldMov.remaining() < 8)
                return false;
            oldMov.putInt(oldMov.remaining());
            oldMov.put(new byte[] { 'f', 'r', 'e', 'e' });
        }
        oldMov.flip();
        fi.position(moov.getOffset());
        fi.write(oldMov);

        return true;
    } finally {
        if (fi != null)
            fi.close();
    }
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:38,代码来源:InplaceEdit.java

示例9: WavTrack

import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
public WavTrack(ByteChannelPool pool, Label... labels) throws IOException {
    this.pool = pool;

    SeekableByteChannel ch = null;
    try {
        ch = pool.getChannel();
        header = WavHeader.read(Channels.newInputStream(ch));
        size = header.dataSize <= 0 ? ch.size() : header.dataSize;
    } finally {
        ch.close();
    }

    se = MP4Muxer.audioSampleEntry("sowt", 1, header.fmt.bitsPerSample >> 3, header.fmt.numChannels,
            header.fmt.sampleRate, Endian.LITTLE_ENDIAN);
    ChannelBox chan = new ChannelBox();
    if (labels != null && labels.length > 0) {
        ChannelUtils.setLabels(labels, chan);
    } else {
        labels = new Label[header.getFormat().getChannels()];
        for (int i = 0; i < labels.length; i++)
            labels[i] = Label.Mono;
        ChannelUtils.setLabels(labels, chan);
    }
    se.add(chan);

    pktDataLen = FRAMES_PER_PKT * header.fmt.numChannels * (header.fmt.bitsPerSample >> 3);
    pktDuration = (double) FRAMES_PER_PKT / header.fmt.sampleRate;

    offset = header.dataOffset;
    pts = 0;
    frameNo = 0;
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:33,代码来源:WavTrack.java

示例10: getData

import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
@Override
public ByteBuffer getData() throws IOException {
    SeekableByteChannel ch = null;
    try {
        ch = pool.getChannel();
        ch.position(offset);
        ByteBuffer buffer = ByteBuffer.allocate(dataLen);
        NIOUtils.read(ch, buffer);
        buffer.flip();
        return buffer;
    } finally {
        ch.close();
    }
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:15,代码来源:WavTrack.java

示例11: close

import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
@Override
    public void close() {
        while (!allChannels.isEmpty()) {
            SeekableByteChannel channel = allChannels.remove(0);
            if (channel != null) {
                try {
                    channel.close();
                } catch (IOException e) {
                }
//                System.out.println("CLOSED FILE");
            }
        }
//        System.out.println("FILE POOL CLOSED!!!");
    }
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:15,代码来源:FilePool.java

示例12: flattern

import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
public void flattern(MovieBox movie, File video) throws IOException {
    video.delete();
    SeekableByteChannel out = null;
    try {
        out = writableFileChannel(video);
        flattern(movie, out);
    } finally {
        if (out != null)
            out.close();
    }
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:12,代码来源:Flattern.java

示例13: saveRawFrame

import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
public static void saveRawFrame(ByteBuffer data, AvcCBox avcC, File f) throws IOException {
    SeekableByteChannel raw = NIOUtils.writableFileChannel(f);
    saveStreamParams(avcC, raw);
    raw.write(data.duplicate());
    raw.close();
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:7,代码来源:H264Utils.java


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