本文整理汇总了Java中org.jcodec.common.SeekableByteChannel类的典型用法代码示例。如果您正苦于以下问题:Java SeekableByteChannel类的具体用法?Java SeekableByteChannel怎么用?Java SeekableByteChannel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SeekableByteChannel类属于org.jcodec.common包,在下文中一共展示了SeekableByteChannel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JcodecFrameGrab
import org.jcodec.common.SeekableByteChannel; //导入依赖的package包/类
public JcodecFrameGrab(SeekableByteChannel in) throws IOException, JCodecException {
ByteBuffer header = ByteBuffer.allocate(65536);
in.read(header);
header.flip();
Format detectFormat = JCodecUtil.detectFormat(header);
switch (detectFormat) {
case MOV:
MP4Demuxer d1 = new MP4Demuxer(in);
videoTrack = d1.getVideoTrack();
break;
case MPEG_PS:
throw new UnsupportedFormatException("MPEG PS is temporarily unsupported.");
case MPEG_TS:
throw new UnsupportedFormatException("MPEG TS is temporarily unsupported.");
default:
throw new UnsupportedFormatException("Container format is not supported by JCodec");
}
decodeLeadingFrames();
}
示例2: getRootAtoms
import org.jcodec.common.SeekableByteChannel; //导入依赖的package包/类
public static List<Atom> getRootAtoms(SeekableByteChannel input) throws IOException {
input.position(0);
List<Atom> result = new ArrayList<Atom>();
long off = 0;
Header atom;
while (off < input.size()) {
input.position(off);
atom = Header.read(NIOUtils.fetchFrom(input, 16));
if (atom == null)
break;
result.add(new Atom(atom, off));
off += atom.getSize();
}
return result;
}
示例3: PCMMP4DemuxerTrack
import org.jcodec.common.SeekableByteChannel; //导入依赖的package包/类
public PCMMP4DemuxerTrack(MovieBox movie, TrakBox trak, SeekableByteChannel input) {
super(trak);
this.movie = movie;
this.input = input;
SampleSizesBox stsz = findFirst(trak, SampleSizesBox.class, "mdia", "minf", "stbl", "stsz");
defaultSampleSize = stsz.getDefaultSize();
int chunks = 0;
for (int i = 1; i < sampleToChunks.length; i++) {
int ch = (int) (sampleToChunks[i].getFirst() - sampleToChunks[i - 1].getFirst());
totalFrames += ch * sampleToChunks[i - 1].getCount();
chunks += ch;
}
totalFrames += sampleToChunks[sampleToChunks.length - 1].getCount() * (chunkOffsets.length - chunks);
}
示例4: TimecodeMP4DemuxerTrack
import org.jcodec.common.SeekableByteChannel; //导入依赖的package包/类
public TimecodeMP4DemuxerTrack(MovieBox movie, TrakBox trak, SeekableByteChannel input) throws IOException {
this.box = trak;
this.input = input;
this.movie = movie;
NodeBox stbl = trak.getMdia().getMinf().getStbl();
TimeToSampleBox stts = findFirst(stbl, TimeToSampleBox.class, "stts");
SampleToChunkBox stsc = findFirst(stbl, SampleToChunkBox.class, "stsc");
ChunkOffsetsBox stco = findFirst(stbl, ChunkOffsetsBox.class, "stco");
ChunkOffsets64Box co64 = findFirst(stbl, ChunkOffsets64Box.class, "co64");
timeToSamples = stts.getEntries();
chunkOffsets = stco != null ? stco.getChunkOffsets() : co64.getChunkOffsets();
sampleToChunks = stsc.getSampleToChunk();
if (chunkOffsets.length == 1) {
cacheSamples(sampleToChunks, chunkOffsets);
}
tse = (TimecodeSampleEntry) box.getSampleEntries()[0];
}
示例5: FramesMP4DemuxerTrack
import org.jcodec.common.SeekableByteChannel; //导入依赖的package包/类
public FramesMP4DemuxerTrack(MovieBox mov, TrakBox trak, SeekableByteChannel input) {
super(trak);
this.input = input;
this.movie = mov;
SampleSizesBox stsz = findFirst(trak, SampleSizesBox.class, "mdia", "minf", "stbl", "stsz");
SyncSamplesBox stss = Box.findFirst(trak, SyncSamplesBox.class, "mdia", "minf", "stbl", "stss");
SyncSamplesBox stps = Box.findFirst(trak, SyncSamplesBox.class, "mdia", "minf", "stbl", "stps");
CompositionOffsetsBox ctts = Box.findFirst(trak, CompositionOffsetsBox.class, "mdia", "minf", "stbl", "ctts");
compOffsets = ctts == null ? null : ctts.getEntries();
if (stss != null) {
syncSamples = stss.getSyncSamples();
}
if(stps != null) {
partialSync = stps.getSyncSamples();
}
sizes = stsz.getSizes();
maxSize = stsz.getMaxSize();
}
示例6: withOldHeader
import org.jcodec.common.SeekableByteChannel; //导入依赖的package包/类
public static WebOptimizedMP4Muxer withOldHeader(SeekableByteChannel output, Brand brand, MovieBox oldHeader)
throws IOException {
int size = (int) oldHeader.getHeader().getSize();
TrakBox vt = oldHeader.getVideoTrack();
SampleToChunkBox stsc = Box.findFirst(vt, SampleToChunkBox.class, "mdia", "minf", "stbl", "stsc");
size -= stsc.getSampleToChunk().length * 12;
size += 12;
ChunkOffsetsBox stco = Box.findFirst(vt, ChunkOffsetsBox.class, "mdia", "minf", "stbl", "stco");
if (stco != null) {
size -= stco.getChunkOffsets().length << 2;
size += vt.getFrameCount() << 3;
} else {
ChunkOffsets64Box co64 = Box.findFirst(vt, ChunkOffsets64Box.class, "mdia", "minf", "stbl", "co64");
size -= co64.getChunkOffsets().length << 3;
size += vt.getFrameCount() << 3;
}
return new WebOptimizedMP4Muxer(output, brand, size + (size >> 1));
}
示例7: Y4MDecoder
import org.jcodec.common.SeekableByteChannel; //导入依赖的package包/类
public Y4MDecoder(SeekableByteChannel is) throws IOException {
ByteBuffer buf = NIOUtils.fetchFrom(is, 2048);
String[] header = split(readLine(buf), ' ');
if (!"YUV4MPEG2".equals(header[0])) {
invalidFormat = "Not yuv4mpeg stream";
return;
}
String chroma = find(header, 'C');
if (chroma != null && !chroma.startsWith("420")) {
invalidFormat = "Only yuv420p is supported";
return;
}
width = Integer.parseInt(find(header, 'W'));
height = Integer.parseInt(find(header, 'H'));
String fpsStr = find(header, 'F');
if (fpsStr != null) {
String[] numden = split(fpsStr, ':');
fps = new Rational(Integer.parseInt(numden[0]), Integer.parseInt(numden[1]));
}
is.position(buf.position());
bufSize = width * height * 2;
}
示例8: FrameGrab
import org.jcodec.common.SeekableByteChannel; //导入依赖的package包/类
public FrameGrab(SeekableByteChannel in) throws IOException, JCodecException {
ByteBuffer header = ByteBuffer.allocate(65536);
in.read(header);
header.flip();
Format detectFormat = JCodecUtil.detectFormat(header);
switch (detectFormat) {
case MOV:
MP4Demuxer d1 = new MP4Demuxer(in);
videoTrack = d1.getVideoTrack();
break;
case MPEG_PS:
throw new UnsupportedFormatException("MPEG PS is temporarily unsupported.");
case MPEG_TS:
throw new UnsupportedFormatException("MPEG TS is temporarily unsupported.");
default:
throw new UnsupportedFormatException("Container format is not supported by JCodec");
}
decodeLeadingFrames();
}
示例9: 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();
}
}
示例10: 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;
}
示例11: RealTrack
import org.jcodec.common.SeekableByteChannel; //导入依赖的package包/类
public RealTrack(MovieBox movie, TrakBox trak, ByteChannelPool pool) {
this.movie = movie;
SampleSizesBox stsz = Box.findFirst(trak, SampleSizesBox.class, "mdia", "minf", "stbl", "stsz");
if (stsz.getDefaultSize() == 0) {
this.demuxer = new FramesMP4DemuxerTrack(movie, trak, null) {
@Override
protected ByteBuffer readPacketData(SeekableByteChannel ch, ByteBuffer buffer, long position, int size)
throws IOException {
return buffer;
}
};
} else {
this.demuxer = new PCMMP4DemuxerTrack(movie, trak, null) {
@Override
protected ByteBuffer readPacketData(SeekableByteChannel ch, ByteBuffer buffer, long position, int size)
throws IOException {
return buffer;
}
};
}
this.trak = trak;
this.pool = pool;
}
示例12: 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();
}
}
示例13: getChannel
import org.jcodec.common.SeekableByteChannel; //导入依赖的package包/类
@Override
public SeekableByteChannel getChannel() throws IOException {
SeekableByteChannel channel = channels.poll();
if (channel == null) {
// System.out.println("NO CHANNEL");
if (allChannels.size() < max) {
channel = newChannel(file);
allChannels.add(channel);
// System.out.println("CHANNELS: " + allChannels.size() + "(" + max + ")");
} else {
while (true) {
try {
channel = channels.take();
break;
} catch (InterruptedException e) {
}
}
}
}
return new PoolChannel(channel);
}
示例14: 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();
}
}
示例15: getInputs
import org.jcodec.common.SeekableByteChannel; //导入依赖的package包/类
protected SeekableByteChannel[][] getInputs(MovieBox movie) throws IOException {
TrakBox[] tracks = movie.getTracks();
SeekableByteChannel[][] result = new SeekableByteChannel[tracks.length][];
for (int i = 0; i < tracks.length; i++) {
DataRefBox drefs = NodeBox.findFirst(tracks[i], DataRefBox.class, "mdia", "minf", "dinf", "dref");
if (drefs == null) {
throw new RuntimeException("No data references");
}
List<Box> entries = drefs.getBoxes();
SeekableByteChannel[] e = new SeekableByteChannel[entries.size()];
SeekableByteChannel[] inputs = new SeekableByteChannel[entries.size()];
for (int j = 0; j < e.length; j++) {
inputs[j] = Flattern.resolveDataRef(entries.get(j));
}
result[i] = inputs;
}
return result;
}