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


Java ColorUtil类代码示例

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


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

示例1: SequenceEncoderMp4

import org.jcodec.scale.ColorUtil; //导入依赖的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.scale.ColorUtil; //导入依赖的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: toColorArray

import org.jcodec.scale.ColorUtil; //导入依赖的package包/类
public static int[] toColorArray(Picture src){
	if (src.getColor() != ColorSpace.RGB) {
           Transform transform = ColorUtil.getTransform(src.getColor(), ColorSpace.RGB);
           Picture rgb = Picture.create(src.getWidth(), src.getHeight(), ColorSpace.RGB, src.getCrop());
           transform.transform(src, rgb);
           src = rgb;
       }
	
	int[] _return = new int[src.getCroppedWidth() * src.getCroppedHeight()];
	
	int[] data = src.getPlaneData(0);
	
	for(int i = 0; i < _return.length; ++i){
		_return[i] = ReadableRGBContainer.toIntColor(data[3*i + 2], data[3*i + 1], data[3*i]);
	}
	
	return _return;
}
 
开发者ID:vitrivr,项目名称:cineast,代码行数:19,代码来源:PictureUtil.java

示例4: SequenceEncoder

import org.jcodec.scale.ColorUtil; //导入依赖的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

示例5: ImageToH264MP4Encoder

import org.jcodec.scale.ColorUtil; //导入依赖的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

示例6: toBufferedImage

import org.jcodec.scale.ColorUtil; //导入依赖的package包/类
public static BufferedImage toBufferedImage(Picture src) {
    if (src.getColor() != ColorSpace.RGB) {
        Transform transform = ColorUtil.getTransform(src.getColor(), ColorSpace.RGB);
        Picture rgb = Picture.create(src.getWidth(), src.getHeight(), ColorSpace.RGB, src.getCrop());
        transform.transform(src, rgb);
        src = rgb;
    }

    BufferedImage dst = new BufferedImage(src.getCroppedWidth(), src.getCroppedHeight(),
            BufferedImage.TYPE_3BYTE_BGR);

    if (src.getCrop() == null)
        toBufferedImage(src, dst);
    else
        toBufferedImageCropped(src, dst);

    return dst;
}
 
开发者ID:Konovalov-Nik,项目名称:video-watermarking,代码行数:19,代码来源:ConverterUtils.java

示例7: colorCvt

import org.jcodec.scale.ColorUtil; //导入依赖的package包/类
private Picture colorCvt(Picture in) {

        Picture out;
        if (in.getColor() == YUV422_10) {
            out = in;
        } else {
            Transform trans = ColorUtil.getTransform(in.getColor(), YUV422_10);
            out = Picture.create(in.getWidth(), in.getHeight(), YUV422_10);
            trans.transform(in, out);
        }

        return out;
    }
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:14,代码来源:Mpeg2Prores.java

示例8: transcodeFrame

import org.jcodec.scale.ColorUtil; //导入依赖的package包/类
public ByteBuffer transcodeFrame(ByteBuffer src, ByteBuffer dst) throws IOException {
    if(src == null)
        return null;
    Picture decoded = decoder.decodeFrame(src, pic0.getData());
    if (pic1 == null) {
        pic1 = Picture.create(decoded.getWidth(), decoded.getHeight(), encoder.getSupportedColorSpaces()[0]);
        transform = ColorUtil.getTransform(decoded.getColor(), encoder.getSupportedColorSpaces()[0]);
    }
    transform.transform(decoded, pic1);
    pic1.setCrop(new Rect(0, 0, thumbWidth, thumbHeight));
    int rate = TARGET_RATE;
    do {
        try {
            encoder.encodeFrame(pic1, dst);
            break;
        } catch (BufferOverflowException ex) {
            System.out.println("Abandon frame!!!");
            rate -= 10;
            rc.setRate(rate);
        }
    } while (rate > 10);
    rc.setRate(TARGET_RATE);

    H264Utils.encodeMOVPacket(dst);

    return dst;
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:28,代码来源:Transcode2AVCTrack.java

示例9: fromBufferedImage

import org.jcodec.scale.ColorUtil; //导入依赖的package包/类
public static Picture fromBufferedImage(BufferedImage src, ColorSpace tgtColor) {
    Picture rgb = fromBufferedImage(src);
    Transform tr = ColorUtil.getTransform(rgb.getColor(), tgtColor);
    Picture res = Picture.create(rgb.getWidth(), rgb.getHeight(), tgtColor);
    tr.transform(rgb, res);
    return res;
}
 
开发者ID:Konovalov-Nik,项目名称:video-watermarking,代码行数:8,代码来源:ConverterUtils.java

示例10: transcodeFrame

import org.jcodec.scale.ColorUtil; //导入依赖的package包/类
public ByteBuffer transcodeFrame(ByteBuffer src, ByteBuffer dst, boolean iframe, int poc) throws IOException {
    if (src == null)
        return null;

    if (pic0 == null) {
        Size size = MPEGDecoder.getSize(src.duplicate());
        thumbWidth = size.getWidth() >> this.scaleFactor;
        thumbHeight = size.getHeight() >> this.scaleFactor;
        int mbW = (thumbWidth + 8) >> 4;
        int mbH = (thumbHeight + 8) >> 4;

        pic0 = Picture.create(mbW << 4, (mbH + 1) << 4, ColorSpace.YUV444);
    }
    Picture decoded = decoder.decodeFrame(src, pic0.getData());
    if (pic1 == null) {
        pic1 = Picture.create(decoded.getWidth(), decoded.getHeight(), encoder.getSupportedColorSpaces()[0]);
        transform = ColorUtil.getTransform(decoded.getColor(), encoder.getSupportedColorSpaces()[0]);
    }
    Picture toEnc;
    if (transform != null) {
        transform.transform(decoded, pic1);
        toEnc = pic1;
    } else {
        toEnc = decoded;
    }
    pic1.setCrop(new Rect(0, 0, thumbWidth, thumbHeight));
    int rate = Mpeg2AVCTrack.TARGET_RATE;
    do {
        try {
            encoder.encodeFrame(toEnc, dst, iframe, poc);
            break;
        } catch (BufferOverflowException ex) {
            System.out.println("Abandon frame!!!");
            rate -= 10;
            rc.setRate(rate);
        }
    } while (rate > 10);
    rc.setRate(Mpeg2AVCTrack.TARGET_RATE);

    H264Utils.encodeMOVPacket(dst);

    return dst;
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:44,代码来源:MPEGToAVCTranscoder.java

示例11: savePictureAsPPM

import org.jcodec.scale.ColorUtil; //导入依赖的package包/类
public static void savePictureAsPPM(Picture pic, File file) throws IOException {
    Transform transform = ColorUtil.getTransform(pic.getColor(), ColorSpace.RGB);
    Picture rgb = Picture.create(pic.getWidth(), pic.getHeight(), ColorSpace.RGB);
    transform.transform(pic, rgb);
    NIOUtils.writeTo(new PPMEncoder().encodeFrame(rgb), file);
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:7,代码来源:JCodecUtil.java


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