他的代码
YUV 转换
- 硬件摄像头nv21 转yuv420
- 摄像头旋转/前后摄像头切换
public class LibYUVConvert {
public native byte[] LibNV21toYUV420(byte[] srcYUV, int iSrcWidth, int iSrcHeight);
public native byte[] LibYUV420Rotate270(byte[] srcYUV, int iSrcWidth, int iSrcHeight);
public native byte[] LibYUV420Rotate90(byte[] srcYUV, int iSrcWidth, int iSrcHeight);
static {
System.loadLibrary("AvcEncoder");
}
}
rtmp 部分
public class FdkAacEncode {
public native void FdkAacDeInit(int handle);
public native byte[] FdkAacEncode(int handle, byte[] buffer);
public native int FdkAacInit(int iSampleRate, int iChannel);
static {
System.loadLibrary("AvcEncoder");
}
}
public class RtmpSession {
public native int RtmpConnect(String rtmpUrl);
public native void RtmpDisconnect(int handle);
public native int RtmpIsConnect(int handle);
public native int RtmpSendAudioData(int handle, byte[] audioData, long lLen);
public native int RtmpSendVideoData(int handle, byte[] videoData, long lLen);
static {
System.loadLibrary("AvcEncoder");
System.loadLibrary("rtmp");
}
}
h264 编码
public class OpenH264Encoder {
public static final int YUV12_TYPE = 24;
public static final int YUV420_TYPE = 23;
public native void DeInitEncode(int iHandle);
public native byte[] EncodeH264frame(int iHandle, byte[] inbuf_ptr);
public native int InitEncode(int nImgWidth, int nImgHight, int nBitrate, int Frmrate, int iYUVType);
static {
System.loadLibrary("AvcEncoder");
}
}
编程语言
视频混合
- MediaCodec
- VideoRecMuxer -----> MediaMuxer
- MediaFormat ----> audio/raw