색 형식을 COLOR_FormatYUV420Flexible
으로 설정하여 MediaCodec을 사용하여 인코딩하려고합니다. 내 입력 버퍼의이 같은 yuv420p.When I 입력 버퍼입니다 :일부 장치에서 MediaCodec getInputImage가 null을 반환 함
int inputBufferIndex = mEncoder.dequeueInputBuffer(-1);
mCurrentBufferIndex = inputBufferIndex;
if (inputBufferIndex >= 0) {
ByteBuffer inputBuffer = inputBuffers[inputBufferIndex];
//if(VERBOSE)
Log.i(TAG,"pos:"+inputBuffer.position()+"\tlimit:"+inputBuffer.limit());
inputBuffer.clear();
return inputBuffer;
}
그러나 일부 장치는 잘못된 색상을 얻을.
int inputBufferIndex = mEncoder.dequeueInputBuffer(-1);
mCurrentBufferIndex = inputBufferIndex;
if (inputBufferIndex >= 0) {
Image img = mEncoder.getInputImage(inputBufferIndex);
if(img==null)
return null;
//mCurrentInputPlanes = img.getPlanes();
ByteBuffer buffers[]={img.getPlanes()[0].getBuffer(),
img.getPlanes()[1].getBuffer(),
img.getPlanes()[2].getBuffer()};
나는 일부 장치에 YUV 채널에 .IT 작업을 버퍼를 채우기 : 그래서 나는이 시도. 그러나 moto X pro와 huawei P7은 getInputImage를 호출 할 때 null이됩니다. 설명서에 이미지에 원시 데이터가 들어 있지 않다고 나와 있습니다. 그러나 API21 이후로 COLOR_FormatYUV420Flexible
이 지원됩니다. 어떻게 해결해야합니까?
을 처리 할 수있는 다른 코덱 Galaxy Note3 및 Galaxy Tab 4 10.1 장치에 대한 추가 정보 – FTLRalph
@FTLRalph 전체 코드 예제를 게시 할 수 있습니까? 질문에서 YUV 데이터가 입력 버퍼로 복사되는 방법이 명확하지 않습니다. 또한 문제를 보여주는 인코딩 된 비디오의 예를 게시 할 수 있습니까? 보폭이나 패딩과 같은 잘못된 색상의 소리가 내게 문제가되지만 디버그하는 데 더 많은 정보가 필요합니다. –
확인 되었습니까? COLOR_FormatYUV420Flexible? 이 링크에 따라 : https://stackoverflow.com/questions/30857610/will-all-phones-support-yuv-420-semi-planar-color-format-in-h-264-encoder – user1796260