本文整理汇总了Java中org.jcodec.containers.mp4.muxer.MP4Muxer类的典型用法代码示例。如果您正苦于以下问题:Java MP4Muxer类的具体用法?Java MP4Muxer怎么用?Java MP4Muxer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MP4Muxer类属于org.jcodec.containers.mp4.muxer包,在下文中一共展示了MP4Muxer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SequenceEncoderMp4
import org.jcodec.containers.mp4.muxer.MP4Muxer; //导入依赖的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.containers.mp4.muxer.MP4Muxer; //导入依赖的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.containers.mp4.muxer.MP4Muxer; //导入依赖的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: open
import org.jcodec.containers.mp4.muxer.MP4Muxer; //导入依赖的package包/类
@Override
public void open(String _path, int width, int _height, int _fps) throws IOException {
path = _path;
height = _height;
fps = _fps;
ch = new FileChannelWrapper(FileChannel.open(Paths.get(path), StandardOpenOption.CREATE, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING));
// Muxer that will store the encoded frames
muxer = new MP4Muxer(ch, Brand.MP4);
// Add video track to muxer
outTrack = muxer.addTrack(TrackType.VIDEO, fps);
// Allocate a buffer big enough to hold output frames
_out = ByteBuffer.allocateDirect(width * height * 6);
// Create an instance of encoder
encoder = new H264Encoder(new JCodecUtils.JHVRateControl(20));
// Encoder extra data ( SPS, PPS ) to be stored in a special place of MP4
spsList = new ArrayList<>();
ppsList = new ArrayList<>();
toEncode = Picture.create(width, height, ColorSpace.YUV420J);
}
示例5: SequenceEncoder
import org.jcodec.containers.mp4.muxer.MP4Muxer; //导入依赖的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>();
}
示例6: createMOVSampleEntry
import org.jcodec.containers.mp4.muxer.MP4Muxer; //导入依赖的package包/类
public static SampleEntry createMOVSampleEntry(List<ByteBuffer> spsList, List<ByteBuffer> ppsList) {
SeqParameterSet sps = readSPS(NIOUtils.duplicate(spsList.get(0)));
AvcCBox avcC = new AvcCBox(sps.profile_idc, 0, sps.level_idc, spsList, ppsList);
int codedWidth = (sps.pic_width_in_mbs_minus1 + 1) << 4;
int codedHeight = getPicHeightInMbs(sps) << 4;
int width = sps.frame_cropping_flag ? codedWidth
- ((sps.frame_crop_right_offset + sps.frame_crop_left_offset) << sps.chroma_format_idc.compWidth[1])
: codedWidth;
int height = sps.frame_cropping_flag ? codedHeight
- ((sps.frame_crop_bottom_offset + sps.frame_crop_top_offset) << sps.chroma_format_idc.compHeight[1])
: codedHeight;
Size size = new Size(width, height);
SampleEntry se = MP4Muxer.videoSampleEntry("avc1", size, "JCodec");
se.add(avcC);
return se;
}
示例7: SequenceEncoder
import org.jcodec.containers.mp4.muxer.MP4Muxer; //导入依赖的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>();
}
示例8: toSampleEntry
import org.jcodec.containers.mp4.muxer.MP4Muxer; //导入依赖的package包/类
private SampleEntry toSampleEntry(GenericDescriptor d) {
if (track.isVideo()) {
GenericPictureEssenceDescriptor ped = (GenericPictureEssenceDescriptor) d;
VideoSampleEntry se = MP4Muxer.videoSampleEntry(MP4Util.getFourcc(track.getCodec().getCodec()), new Size(
ped.getDisplayWidth(), ped.getDisplayHeight()), "JCodec");
Rational ar = ped.getAspectRatio();
se.add(new PixelAspectExt(
new Rational((int) ((1000 * ar.getNum() * ped.getDisplayHeight()) / (ar.getDen() * ped
.getDisplayWidth())), 1000)));
return se;
} else if (track.isAudio()) {
GenericSoundEssenceDescriptor sed = (GenericSoundEssenceDescriptor) d;
int sampleSize = sed.getQuantizationBits() >> 3;
MXFCodecMapping codec = track.getCodec();
return MP4Muxer.audioSampleEntry(sampleSize == 3 ? "in24" : "sowt", 0, sampleSize, sed.getChannelCount(),
(int) sed.getAudioSamplingRate().asFloat(), codec == MXFCodecMapping.PCM_S16BE ? Endian.BIG_ENDIAN
: Endian.LITTLE_ENDIAN);
}
throw new RuntimeException("Can't get sample entry");
}
示例9: ImageToH264MP4Encoder
import org.jcodec.containers.mp4.muxer.MP4Muxer; //导入依赖的package包/类
public ImageToH264MP4Encoder(SeekableByteChannel ch, AudioFormat af) throws IOException {
this.ch = ch;
this.af = af;
// Muxer that will store the encoded frames
muxer = new MP4Muxer(ch, Brand.MP4);
// Add video track to muxer
outTrack = muxer.addTrack(TrackType.VIDEO, 25);
// 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>();
if (af != null)
audioTrack = muxer.addPCMAudioTrack(af);
}
示例10: initalize
import org.jcodec.containers.mp4.muxer.MP4Muxer; //导入依赖的package包/类
/**
* Initalize a compress class
*
* @param fileHandle - resource to mpeg4 file
* @param width - video width
* @param height - video height
* @throws IOException
*/
public void initalize(File fileHandle, int width, int height) throws IOException{
this.width=width;
this.height=height;
ch=NIOUtils.writableFileChannel(fileHandle);
muxer=new MP4Muxer(ch, Brand.MP4);
outTrack=muxer.addTrackForCompressed(TrackType.VIDEO, frameRate);
outBuffer=ByteBuffer.allocate(width * height * 6);
transform=new RgbToYuv420(0, 0);
encoder=new H264Encoder();
spsList=new ArrayList<ByteBuffer>();
ppsList=new ArrayList<ByteBuffer>();
frameNo=0;
}
示例11: Encoder
import org.jcodec.containers.mp4.muxer.MP4Muxer; //导入依赖的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);
}
示例12: MP4H264Muxer
import org.jcodec.containers.mp4.muxer.MP4Muxer; //导入依赖的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);
}
示例13: MP4MJPEGMovieBuilder
import org.jcodec.containers.mp4.muxer.MP4Muxer; //导入依赖的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;
}
示例14: close
import org.jcodec.containers.mp4.muxer.MP4Muxer; //导入依赖的package包/类
@Override
public void close() throws IOException
{
Size size = new Size(width, height);
SampleEntry sampleEntry = MP4Muxer.videoSampleEntry("jpeg", size, "IHMCVideoCodecs");
track.addSampleEntry(sampleEntry);
muxer.writeHeader();
channel.close();
encoder.delete();
}
示例15: SequenceMuxer
import org.jcodec.containers.mp4.muxer.MP4Muxer; //导入依赖的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);
}