2015-02-03 4 views
0

나는 stagefright videoencoder를 사용하여 android 4.4에서 비디오를 인코딩합니다. 내가 전화했을 때무언가에 대한 stagefright 코덱 입력 형식

sp<AMessage> format = new AMessage; 
format->setInt32("width", 1080); 
format->setInt32("height", 1920); 
format->setString("mime", "video/avc"); 
format->setInt32("color-format", OMX_COLOR_FormatYUV420Planar); 
format->setInt32("bitrate", 1000000); 
format->setFloat("frame-rate", 25); 
format->setInt32("i-frame-interval", 5); 
sp<MediaCodec> videoEncoder = MediaCodec::CreateByType(looper, "video/avc", true); 
videoEncoder->configure(format, NULL, NULL,MediaCodec::CONFIGURE_FLAG_ENCODE); 
videoEncoder->start(); 

하지만 :

status_t err = gSpVideoEncoder->dequeueOutputBuffer(&bufIndex, &offset, &size, &ptsUsec, &flags, kTimeout); 

내가 가지고 :

err === INFO_FORMAT_CHANGED 

다음 단계는 내가 전화 :

sp<AMessage> newFormat; 
videoEncoder->getOutputFormat(&newFormat); 
uint32_t width = 0, height = 0; 
newFormat->findInt32("width", (int32_t *)(&width)); 
newFormat->findInt32("height", (int32_t *)(&height)); 
fprintf(stderr, "new width: %d, height: %d\n", width, height) 

내가 가지고 결과 :

new width: 1088, height: 1920 

videoEncoder에 새로운 입력 프레임 (1088x1920)을 제공해야하는지 혼란 스럽습니까 (1080x1920 아님)?

답변

2

비디오 코딩은 프레임 크기가 16의 배수 즉 매크로 블록 크기로 정렬되어야합니다. HD 해상도, 즉 1920 x 1080은 1080이 이 아니고이 아닌 16의 배수 인 특수한 경우입니다. 기본 엔코더는 클라이언트가 정렬 된 경계를 제공 할 것으로 기대합니다.

이 경우 다음과 같이 창에 데이터를 제공 할 수 있습니다. Luma의 경우 의 배수로 정렬하고 Chroma의 경우 의 배수로 정렬해야합니다. 나머지 픽셀은 의 값이으로 미리 채워질 수 있습니다.

참고 : : 인코딩 해상도로 1920 x 1080을 처리 할 수있는 인코더가있는 경우 출력이 좋을 것입니다. 인코더가 1920 x 1088로 인코딩하면 제로 패딩으로 인해 생성 된 비트 스트림의 그림 하단에 녹색 밴드가 표시됩니다.

--------------------------------------------- 
|           | 
|           | 
|           | 
|     Luma     | 
|    1920 x 1080    | 
|    filled into    | 
|    a buffer of    | 
|    1920 x 1088    | 
|           | 
|    Last 8 lines could   | 
|    be filled with zeroes  | 
|           | 
--------------------------------------------- 
----------------------- 
|  Cb   | 
| 960 x 540   | 
| filled into  | 
| a buffer of  | 
| 960 x 544   | 
|      | 
----------------------- 
----------------------- 
|  Cr   | 
| 960 x 540   | 
| filled into  | 
| a buffer of  | 
| 960 x 544   | 
|      | 
----------------------- 
+0

대단히 감사합니다. ~ _ –

+0

@BingShine .. 해결 방법으로 문제가 해결되면 대답을 수락하십시오. – Ganesh