org.jcodec.common.SeekableByteChannel Java Examples

The following examples show how to use org.jcodec.common.SeekableByteChannel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JcodecFrameGrab.java    From cineast with MIT License 6 votes vote down vote up
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();
}
 
Example #2
Source File: ImageToH264MP4Encoder.java    From CameraV with GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #3
Source File: VideoCameraActivity.java    From CameraV with GNU General Public License v3.0 5 votes vote down vote up
public Encoder (File fileOut, int baseFramesPerSecond, boolean withEmbeddedAudio) throws IOException
{
	this.fileOut = fileOut;

	fos = new info.guardianproject.iocipher.FileOutputStream(fileOut);
	SeekableByteChannel sbc = new IOCipherFileChannelWrapper(fos.getChannel());

	org.jcodec.common.AudioFormat af = null;
	
	if (withEmbeddedAudio)
		af = new org.jcodec.common.AudioFormat(org.jcodec.common.AudioFormat.MONO_S16_LE(MediaConstants.sAudioSampleRate));
	
	muxer = new ImageToMJPEGMOVMuxer(sbc,af,baseFramesPerSecond);			
}
 
Example #4
Source File: ImageToVP8Encoder.java    From CameraV with GNU General Public License v3.0 5 votes vote down vote up
public ImageToVP8Encoder(SeekableByteChannel ch) throws IOException {
    this.ch = ch;
    // Muxer that will store the encoded frames
    muxer = new MKVMuxer();

    encoder = new VP8Encoder(10);
    transform = new RgbToYuv420p(0, 0);
}
 
Example #5
Source File: ImageToMJPEGMOVMuxer.java    From CameraV with GNU General Public License v3.0 4 votes vote down vote up
public ImageToMJPEGMOVMuxer(SeekableByteChannel ch, AudioFormat af, int framesPerSecond) throws IOException {
    
	this.ch = ch;
    this.af = af;
    this.framesPerSecond = framesPerSecond;
    
    // Muxer that will store the encoded frames
    muxer = new WebOptimizedMP4Muxer(ch, Brand.MP4, 4096*4);

    // Add video track to muxer
    videoTrack = muxer.addTrack(TrackType.VIDEO, framesPerSecond);
    muxer.addTimecodeTrack(framesPerSecond);
    videoTrack.setTgtChunkDuration(new Rational(3, 1), Unit.SEC);
    
   if (af != null)
    	audioTrack = muxer.addPCMAudioTrack(af);



}
 
Example #6
Source File: IOCipherFileChannelWrapper.java    From CameraV with GNU General Public License v3.0 4 votes vote down vote up
@Override
public SeekableByteChannel truncate(long size) throws IOException {
    ch.truncate(size);
    return this;
}
 
Example #7
Source File: YUVtoWebmMuxer.java    From CameraV with GNU General Public License v3.0 3 votes vote down vote up
public YUVtoWebmMuxer(SeekableByteChannel ch, int width, int height) throws IOException {

    this.ch = ch;
    
    muxer = new IVFMuxer(ch,width,height,25);

    // Create an instance of encoder
    encoder = new VP8Encoder(10);


}
 
Example #8
Source File: IOCipherFileChannelWrapper.java    From CameraV with GNU General Public License v3.0 3 votes vote down vote up
@Override
public SeekableByteChannel position(long newPosition) throws IOException {
    
    ch.position(newPosition);
    
    return this;
}