Example usage for android.media MediaFormat createVideoFormat

List of usage examples for android.media MediaFormat createVideoFormat

Introduction

In this page you can find the example usage for android.media MediaFormat createVideoFormat.

Prototype

public static final MediaFormat createVideoFormat(String mime, int width, int height) 

Source Link

Document

Creates a minimal video format.

Usage

From source file:br.com.skylane.voicer.rtp.RtpMediaDecoder.java

/**
 * /*ww w. j  a v  a  2  s . co m*/
 * @return
 */
public MediaFormat getMediaFormat() {
    String mimeType = "video/avc";

    MediaFormat format = MediaFormat.createVideoFormat(mimeType, SURFACE_WIDTH, SURFACE_HEIGHT);

    // from avconv, when streaming sample.h264.mp4 from disk
    /*byte[] header_sps = {0, 0, 0, 1, // header
        0x67, 0x64, (byte) 0x00, 0x1e, (byte) 0xac, (byte) 0xd9, 0x40, (byte) 0xa0, 0x3d,
        (byte) 0xa1, 0x00, 0x00, (byte) 0x03, 0x00, 0x01, 0x00, 0x00, 0x03, 0x00, 0x3C, 0x0F, 0x16, 0x2D, (byte) 0x96}; // sps
    byte[] header_pps = {0, 0, 0, 1, // header
        0x68, (byte) 0xeb, (byte) 0xec, (byte) 0xb2, 0x2C}; // pps
     */

    //byte[] header_sps = {0, 0, 0, 1, 103, 100, 0, 41, -84, 27, 26, -64, -96, 61, -112}; // sps
    //byte[] header_sps = {0, 0, 0, 1, 103, 66, 0, 30, -90, -128, -96, 61, -112}; //-samsung
    byte[] header_sps = { 0, 0, 0, 1, 103, 66, -128, 30, -85, 64, 80, 30, -48, -128, 0, 0, 3, 0, -128, 0, 0, 30,
            112, 32, 0, 122, 18, 0, 15, 66, 86, -79, -80, 16 }; //-asus
    //byte[] header_pps = {0, 0, 0, 1, 104, -22, 67, -53}; // pps
    //byte[] header_pps = {0, 0, 0, 1, 104, -50, 56, -128}; // -samsung
    byte[] header_pps = { 0, 0, 0, 1, 104, -50, 60, -128 }; // -asus

    /*format.setByteBuffer("csd-0", ByteBuffer.wrap(header_sps));
    format.setByteBuffer("csd-1", ByteBuffer.wrap(header_pps));*/

    format.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, SURFACE_WIDTH * SURFACE_HEIGHT);
    format.setInteger(MediaFormat.KEY_DURATION, 12600000);

    /*format.setInteger(MediaFormat.KEY_COLOR_FORMAT,
        MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface);
    format.setInteger(MediaFormat.KEY_BIT_RATE, 1000000);
    format.setInteger(MediaFormat.KEY_FRAME_RATE, FRAME_RATE);
    format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, IFRAME_INTERVAL);*/

    return format;
}

From source file:com.c77.androidstreamingclient.lib.rtp.RtpMediaExtractor.java

/**
 * Retrieves an Android MediaFormat for H.264, 640x480 video codec.
 * SPS and PPS are hardcoded to the ones used by libstreaming.
 * TODO: Think how to get CSD-0/CSD-1 codec-specific data chunks
 *
 * @return/*ww  w.j ava2s . com*/
 */
public MediaFormat getMediaFormat() {
    String mimeType = "video/avc";
    int width = 640;
    int height = 480;

    MediaFormat format = MediaFormat.createVideoFormat(mimeType, width, height);

    // from avconv, when streaming sample.h264.mp4 from disk
    byte[] header_sps = { 0, 0, 0, 1, // header
            0x67, 0x64, (byte) 0x00, 0x1e, (byte) 0xac, (byte) 0xd9, 0x40, (byte) 0xa0, 0x3d, (byte) 0xa1, 0x00,
            0x00, (byte) 0x03, 0x00, 0x01, 0x00, 0x00, 0x03, 0x00, 0x3C, 0x0F, 0x16, 0x2D, (byte) 0x96 }; // sps
    byte[] header_pps = { 0, 0, 0, 1, // header
            0x68, (byte) 0xeb, (byte) 0xec, (byte) 0xb2, 0x2C }; // pps

    format.setByteBuffer(CSD_0, ByteBuffer.wrap(header_sps));
    format.setByteBuffer(CSD_1, ByteBuffer.wrap(header_pps));

    //format.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, width * height);
    format.setInteger(DURATION_US, 12600000);

    return format;
}

From source file:com.c77.androidstreamingclient.lib.rtp.OriginalRtpMediaExtractor.java

public MediaFormat getMediaFormat() {
    String mimeType = "video/avc";
    int width = 640;
    int height = 480;

    MediaFormat format = MediaFormat.createVideoFormat(mimeType, width, height);
    /*/*  w w  w. j  a  v  a 2  s.  c  o  m*/
    // the one got from internet
    byte[] header_sps = { 0, 0, 0, 1, // header
        0x67, 0x42, 0x00, 0x1f, (byte)0xe9, 0x01, 0x68, 0x7b, (byte) 0x20 }; // sps
    byte[] header_pps = { 0, 0, 0, 1, // header
        0x68, (byte)0xce, 0x06, (byte)0xf2 }; // pps
            
    // the one got from libstreaming at HQ
    byte[] header_sps = { 0, 0, 0, 1, // header
        0x67, 0x42, (byte)0x80, 0x14, (byte)0xe4, 0x40, (byte)0xa0, (byte)0xfd, 0x00, (byte)0xda, 0x14, 0x26, (byte)0xa0}; // sps
    byte[] header_pps = { 0, 0, 0, 1, // header
        0x68, (byte)0xce, 0x38, (byte)0x80 }; // pps
            
            
    // the one got from libstreaming at home
    byte[] header_sps = { 0, 0, 0, 1, // header
        0x67, 0x42, (byte) 0xc0, 0x1e, (byte) 0xe9, 0x01, 0x40, 0x7b, 0x40, 0x3c, 0x22, 0x11, (byte) 0xa8}; // sps
    byte[] header_pps = { 0, 0, 0, 1, // header
        0x68, (byte) 0xce, 0x06, (byte) 0xe2}; // pps
     */

    // from avconv, when streaming sample.h264.mp4 from disk
    byte[] header_sps = { 0, 0, 0, 1, // header
            0x67, 0x64, (byte) 0x00, 0x1e, (byte) 0xac, (byte) 0xd9, 0x40, (byte) 0xa0, 0x3d, (byte) 0xa1, 0x00,
            0x00, (byte) 0x03, 0x00, 0x01, 0x00, 0x00, 0x03, 0x00, 0x3C, 0x0F, 0x16, 0x2D, (byte) 0x96 }; // sps
    byte[] header_pps = { 0, 0, 0, 1, // header
            0x68, (byte) 0xeb, (byte) 0xec, (byte) 0xb2, 0x2C }; // pps

    format.setByteBuffer(CSD_0, ByteBuffer.wrap(header_sps));
    format.setByteBuffer(CSD_1, ByteBuffer.wrap(header_pps));

    //format.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, width * height);
    format.setInteger(DURATION_US, 12600000);

    return format;
}