-
Notifications
You must be signed in to change notification settings - Fork 246
rawVideoData
xinbaicheng edited this page Sep 21, 2016
·
10 revisions
该方式暂时只在软解的情况下生效
必须在调用 prepareAsync 之前设置
ksyMediaPlayer.setOption(KSYMediaPlayer.OPT_CATEGORY_PLAYER, "overlay-format", KSYMediaPlayer.SDL_FCC_RV32);
上述代码是将输出的视频数据格式设置为 RGBA8888
开发者需申请相应的缓存,并交予播放器,播放器方可将视频数据交予开发者
ByteBuffer rawBuffer[] = new ByteBuffer[5]; // 5 is just an example.
for(int index=0; index<rawBuffer.length; index++)
{
rawBuffer[index] = ByteBuffer.allocate(mVideoWidth * mVideoHeight * 4); // make sure buffer Not smaller than video resolution
ksyMediaPlayer.addVideoRawBuffer(rawBuffer[index].array());
}
//[important]make sure it is called before "prepareAsync"
ksyMediaPlayer.setOption(KSYMediaPlayer.OPT_CATEGORY_PLAYER, "overlay-format", KSYMediaPlayer.SDL_FCC_RV32);
ByteBuffer rawBuffer[] = new ByteBuffer[5]; //5 buffers is just an example
for(int index=0; index<rawBuffer.length; index++)
{
rawBuffer[index] = ByteBuffer.allocate(mVideoWidth * mVideoHeight * 4); //make sure it is big enough, not smaller than the maximum video resolution
ksyMediaPlayer.addVideoRawBuffer(rawBuffer[index].array());
}
ksyMediaPlayer.setVideoRawDataListener(new KSYMediaPlayer.OnVideoRawDataListener() {
@Override
public void onVideoRawDataAvailable(IMediaPlayer mp, byte[] buf, int size, int width, int height, int format) {
//todo: handle RGB raw data.
//You can handle it in another thread, but never forget calling addVideoRawBuffer after it is done
//....
ksyMediaPlayer.addVideoRawBuffer(buf); //MUST call it after the buf is handled
}
}