• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java MP4Muxer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jcodec.containers.mp4.muxer.MP4Muxer的典型用法代码示例。如果您正苦于以下问题:Java MP4Muxer类的具体用法?Java MP4Muxer怎么用?Java MP4Muxer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MP4Muxer类属于org.jcodec.containers.mp4.muxer包,在下文中一共展示了MP4Muxer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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>();
}
 
开发者ID:hiliving,项目名称:P2Video-master,代码行数:27,代码来源:SequenceEncoderMp4.java


示例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>();
}
 
开发者ID:ynztlxdeai,项目名称:ImageToVideo,代码行数:27,代码来源:SequenceEncoderMp4.java


示例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>();

}
 
开发者ID:rafaelaaraujo,项目名称:Face-detect-framework,代码行数:25,代码来源:SequenceImagesEncoder.java


示例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);
}
 
开发者ID:Helioviewer-Project,项目名称:JHelioviewer-SWHV,代码行数:21,代码来源:JCodecExporter.java


示例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>();

}
 
开发者ID:deepakpk009,项目名称:JScreenRecorder,代码行数:25,代码来源:SequenceEncoder.java


示例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;
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:22,代码来源:H264Utils.java


示例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>();

}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:25,代码来源:SequenceEncoder.java


示例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");
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:24,代码来源:MXFVirtualTrack.java


示例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);
}
 
开发者ID:guardianproject,项目名称:CameraV,代码行数:25,代码来源:ImageToH264MP4Encoder.java


示例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;
}
 
开发者ID:shadoq,项目名称:s3gdxcodec,代码行数:24,代码来源:PixmapEncoder.java


示例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);
}
 
开发者ID:kamil-karkus,项目名称:EasySnap,代码行数:13,代码来源:Encoder.java


示例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);
}
 
开发者ID:ihmcrobotics,项目名称:ihmc-video-codecs,代码行数:21,代码来源:MP4H264Muxer.java


示例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;
}
 
开发者ID:ihmcrobotics,项目名称:ihmc-video-codecs,代码行数:23,代码来源:MP4MJPEGMovieBuilder.java


示例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();
}
 
开发者ID:ihmcrobotics,项目名称:ihmc-video-codecs,代码行数:11,代码来源:MP4MJPEGMovieBuilder.java


示例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);
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:10,代码来源:SequenceMuxer.java


示例16: finish

import org.jcodec.containers.mp4.muxer.MP4Muxer; //导入依赖的package包/类
public void finish() throws IOException {
    // Push saved SPS/PPS to a special storage in MP4
    outTrack.addSampleEntry(MP4Muxer.videoSampleEntry("png ", size, "JCodec"));

    // Write MP4 header and finalize recording
    muxer.writeHeader();
    NIOUtils.closeQuietly(ch);
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:9,代码来源:SequenceMuxer.java


示例17: WavTrack

import org.jcodec.containers.mp4.muxer.MP4Muxer; //导入依赖的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


示例18: finish

import org.jcodec.containers.mp4.muxer.MP4Muxer; //导入依赖的package包/类
public void finish() throws IOException {
	
	  videoTrack.addSampleEntry(MP4Muxer.videoSampleEntry(imageType, size, ENCODER_NAME));
      
    // Write MP4 header and finalize recording  
	  if (af != null)
		  audioTrack.addSampleEntry(MP4Muxer.audioSampleEntry(af));
	  
    muxer.writeHeader();
    NIOUtils.closeQuietly(ch);
}
 
开发者ID:guardianproject,项目名称:CameraV,代码行数:12,代码来源:ImageToMJPEGMOVMuxer.java


示例19: finish

import org.jcodec.containers.mp4.muxer.MP4Muxer; //导入依赖的package包/类
public void finish() throws IOException {
    // Push saved SPS/PPS to a special storage in MP4
    outTrack.addSampleEntry(H264Utils.createMOVSampleEntry(spsList, ppsList, 4));

    audioTrack.addSampleEntry(MP4Muxer.audioSampleEntry(af));

    // Write MP4 header and finalize recording
    muxer.writeHeader();
    NIOUtils.closeQuietly(ch);
}
 
开发者ID:guardianproject,项目名称:CameraV,代码行数:11,代码来源:ImageToH264MP4Encoder.java


示例20: remux

import org.jcodec.containers.mp4.muxer.MP4Muxer; //导入依赖的package包/类
public void remux(File tgt, File src, File timecode, Handler handler) throws IOException {
    SeekableByteChannel input = null;
    SeekableByteChannel output = null;
    SeekableByteChannel tci = null;
    try {
        input = readableFileChannel(src);
        output = writableFileChannel(tgt);
        MP4Demuxer demuxer = new MP4Demuxer(input);

        
        TimecodeMP4DemuxerTrack tt = null;
        if (timecode != null) {
            tci = readableFileChannel(src);
            MP4Demuxer tcd = new MP4Demuxer(tci);
            tt = tcd.getTimecodeTrack();
        }

        MP4Muxer muxer = WebOptimizedMP4Muxer.withOldHeader(output, Brand.MOV, demuxer.getMovie());

        List<AbstractMP4DemuxerTrack> at = demuxer.getAudioTracks();
        List<PCMMP4MuxerTrack> audioTracks = new ArrayList<PCMMP4MuxerTrack>();
        for (AbstractMP4DemuxerTrack demuxerTrack : at) {
            PCMMP4MuxerTrack att = muxer.addPCMAudioTrack(((AudioSampleEntry) demuxerTrack
                    .getSampleEntries()[0]).getFormat());
            audioTracks.add(att);
            att.setEdits(demuxerTrack.getEdits());
            att.setName(demuxerTrack.getName());
        }

        AbstractMP4DemuxerTrack vt = demuxer.getVideoTrack();
        FramesMP4MuxerTrack video = muxer.addTrack(VIDEO, (int) vt.getTimescale());
        // vt.open(input);
        video.setTimecode(muxer.addTimecodeTrack((int) vt.getTimescale()));
        copyEdits(vt, video, new Rational((int)vt.getTimescale(), demuxer.getMovie().getTimescale()));
        video.addSampleEntries(vt.getSampleEntries());
        MP4Packet pkt = null;
        while ((pkt = (MP4Packet)vt.nextFrame()) != null) {
            if (tt != null)
                pkt = tt.getTimecode(pkt);
            pkt = processFrame(pkt);
            video.addFrame(pkt);

            for (int i = 0; i < at.size(); i++) {
                AudioSampleEntry ase = (AudioSampleEntry) at.get(i).getSampleEntries()[0];
                int frames = (int) (ase.getSampleRate() * pkt.getDuration() / vt.getTimescale());
                MP4Packet apkt = (MP4Packet)at.get(i).nextFrame();
                audioTracks.get(i).addSamples(apkt.getData());
            }
        }

        MovieBox movie = muxer.finalizeHeader();
        if (handler != null)
            handler.handle(movie);
        muxer.storeHeader(movie);

    } finally {
        NIOUtils.closeQuietly(input);
        NIOUtils.closeQuietly(output);
        NIOUtils.closeQuietly(tci);
    }
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:62,代码来源:Remux.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DataTransferProtos类代码示例发布时间:2022-05-22
下一篇:
Java GetTaskReportRequestProtoOrBuilder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap