本文整理汇总了Java中org.jcodec.common.NIOUtils.writableFileChannel方法的典型用法代码示例。如果您正苦于以下问题:Java NIOUtils.writableFileChannel方法的具体用法?Java NIOUtils.writableFileChannel怎么用?Java NIOUtils.writableFileChannel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jcodec.common.NIOUtils
的用法示例。
在下文中一共展示了NIOUtils.writableFileChannel方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SequenceEncoderMp4
import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public SequenceEncoderMp4(File out)
throws IOException
{
super(out);
this.ch = NIOUtils.writableFileChannel(out);
// Muxer that will store the encoded frames
muxer = new MP4Muxer(ch, Brand.MP4);
// Add video track to muxer
outTrack = muxer.addTrack(TrackType.VIDEO, 5);
// Allocate a buffer big enough to hold output frames
_out = ByteBuffer.allocate(1920 * 1080 * 6);
// Create an instance of encoder
encoder = new H264Encoder();
// Transform to convert between RGB and YUV
transform = ColorUtil.getTransform(ColorSpace.RGB, encoder.getSupportedColorSpaces()[0]);
// Encoder extra data ( SPS, PPS ) to be stored in a special place of
// MP4
spsList = new ArrayList<ByteBuffer>();
ppsList = new ArrayList<ByteBuffer>();
}
示例2: SequenceEncoderMp4
import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public SequenceEncoderMp4(File out)
throws IOException
{
super(out);
this.ch = NIOUtils.writableFileChannel(out);
// Muxer that will store the encoded frames
muxer = new MP4Muxer(ch, Brand.MP4);
// Add video track to muxer
outTrack = muxer.addTrack(TrackType.VIDEO, timeScale);
// Allocate a buffer big enough to hold output frames
_out = ByteBuffer.allocate(1920 * 1080 * 6);
// Create an instance of encoder
encoder = new H264Encoder();
// Transform to convert between RGB and YUV
transform = ColorUtil.getTransform(ColorSpace.RGB, encoder.getSupportedColorSpaces()[0]);
// Encoder extra data ( SPS, PPS ) to be stored in a special place of
// MP4
spsList = new ArrayList<ByteBuffer>();
ppsList = new ArrayList<ByteBuffer>();
}
示例3: SequenceImagesEncoder
import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public SequenceImagesEncoder(File out, int screenWidth, int screenHeight) throws IOException {
this.ch = NIOUtils.writableFileChannel(out);
// Transform to convert between RGB and YUV
transform = new RgbToYuv420(0, 0);
// Muxer that will store the encoded frames
muxer = new MP4Muxer(ch, Brand.MP4);
// Add video track to muxer
outTrack = muxer.addTrackForCompressed(TrackType.VIDEO, timescale);
// Allocate a buffer big enough to hold output frames
_out = ByteBuffer.allocate(screenWidth * screenHeight * 6);
// Create an instance of encoder
encoder = new H264Encoder();
// Encoder extra data ( SPS, PPS ) to be stored in a special place of
// MP4
spsList = new ArrayList<ByteBuffer>();
ppsList = new ArrayList<ByteBuffer>();
}
示例4: SequenceEncoder
import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public SequenceEncoder(File out, int frameRate) throws IOException {
this.ch = NIOUtils.writableFileChannel(out);
// Transform to convert between RGB and YUV
transform = new RgbToYuv420(0, 0);
// Muxer that will store the encoded frames
muxer = new MP4Muxer(ch, Brand.MP4);
// Add video track to muxer
outTrack = muxer.addTrackForCompressed(TrackType.VIDEO, frameRate);// original frmae rate is 25
// Allocate a buffer big enough to hold output frames
_out = ByteBuffer.allocate(1920 * 1080 * 6);
// Create an instance of encoder
encoder = new H264Encoder();
// Encoder extra data ( SPS, PPS ) to be stored in a special place of
// MP4
spsList = new ArrayList<ByteBuffer>();
ppsList = new ArrayList<ByteBuffer>();
}
示例5: SequenceEncoder
import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public SequenceEncoder(File out) throws IOException {
this.ch = NIOUtils.writableFileChannel(out);
// Muxer that will store the encoded frames
muxer = new MP4Muxer(ch, Brand.MP4);
// Add video track to muxer
outTrack = muxer.addTrack(TrackType.VIDEO, 25);
// Allocate a buffer big enough to hold output frames
_out = ByteBuffer.allocate(1920 * 1080 * 6);
// Create an instance of encoder
encoder = new H264Encoder();
// Transform to convert between RGB and YUV
transform = ColorUtil.getTransform(ColorSpace.RGB, encoder.getSupportedColorSpaces()[0]);
// Encoder extra data ( SPS, PPS ) to be stored in a special place of
// MP4
spsList = new ArrayList<ByteBuffer>();
ppsList = new ArrayList<ByteBuffer>();
}
示例6: main
import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
FilePool fp = new FilePool(new File(args[0]), 10);
MPSTrackFactory factory = new MPSTrackFactory(NIOUtils.fetchFrom(new File(args[1])), fp);
Stream stream = factory.getVideoStreams().get(0);
FileChannelWrapper ch = NIOUtils.writableFileChannel(new File(args[2]));
List<VirtualPacket> pkt = new ArrayList<VirtualPacket>();
for (int i = 0; i < 2000; i++) {
pkt.add(stream.nextPacket());
}
for (VirtualPacket virtualPacket : pkt) {
ch.write(virtualPacket.getData());
}
ch.close();
}
示例7: main
import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
FilePool fp = new FilePool(new File(args[0]), 10);
MTSTrackFactory factory = new MTSTrackFactory(NIOUtils.fetchFrom(new File(args[1])), fp);
Stream stream = factory.getVideoStreams().get(0);
FileChannelWrapper ch = NIOUtils.writableFileChannel(new File(args[2]));
List<VirtualPacket> pkt = new ArrayList<VirtualPacket>();
for (int i = 0; i < 2000; i++) {
pkt.add(stream.nextPacket());
}
for (VirtualPacket virtualPacket : pkt) {
ch.write(virtualPacket.getData());
}
ch.close();
}
示例8: Encoder
import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public Encoder(File out, int width, int height) throws IOException {
this.ch = NIOUtils.writableFileChannel(out);
_out = ByteBuffer.allocate(width * height * 6);
encoder = new H264Encoder();
spsList = new ArrayList<ByteBuffer>();
ppsList = new ArrayList<ByteBuffer>();
this.ch = NIOUtils.writableFileChannel(out);
muxer = new MP4Muxer(ch, Brand.MP4);
outTrack = muxer.addTrackForCompressed(TrackType.VIDEO, 25);
}
示例9: MP4H264Muxer
import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
/**
* NALProcessor to mux a raw h264 stream into a mp4 file
*
* @param file File to save to
* @param fps frame rate of the video
* @param width Width of the video
* @param height Height of the video
* @throws IOException
*/
public MP4H264Muxer(File file, int fps, int width, int height) throws IOException
{
this.width = width;
this.height = height;
channel = NIOUtils.writableFileChannel(file);
muxer = new MP4Muxer(channel);
timescale = fps;
track = muxer.addTrack(TrackType.VIDEO, timescale);
}
示例10: MP4MJPEGMovieBuilder
import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
/**
* Create an MP4 file with MJPEG
*
* @param file Output file
* @param width Frame width
* @param height Frame height
* @param framerate
* @param quality JPEG quality 0 - 100
* @throws IOException
*/
public MP4MJPEGMovieBuilder(File file, int width, int height, int framerate, int quality) throws IOException
{
channel = NIOUtils.writableFileChannel(file);
muxer = new MP4Muxer(channel);
timescale = framerate;
track = muxer.addTrack(TrackType.VIDEO, timescale);
this.width = width;
this.height = height;
this.quality = quality;
}
示例11: SequenceMuxer
import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public SequenceMuxer(File out) throws IOException {
this.ch = NIOUtils.writableFileChannel(out);
// Muxer that will store the encoded frames
muxer = new MP4Muxer(ch, Brand.MP4);
// Add video track to muxer
outTrack = muxer.addTrack(TrackType.VIDEO, 25);
}
示例12: main
import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
FileChannelWrapper ch = null;
FileChannelWrapper out = null;
try {
ch = NIOUtils.readableFileChannel(new File(args[0]));
out = NIOUtils.writableFileChannel(new File(args[1]));
new MKVShiftTimecodes(Integer.parseInt(args[2])).run(ch, out);
} finally {
NIOUtils.closeQuietly(ch);
NIOUtils.closeQuietly(out);
}
}
示例13: saveRawFrame
import org.jcodec.common.NIOUtils; //导入方法依赖的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();
}