AVI header 채우기 (ADPCM)[완료]

rev7707의 이미지

avi open source 를 구해서 mpeg4 와 IMA-adpcm을 넣어 동영상을
만드는 함수를 만들었습니다. 그런데 화면은 나오는데 소리가는 제대로 안나와서 약간 수정했더니
소리는 나오는데(윈도우에 코덱있는거 확인했는데 안나와서 통합코덱까니깐 나왔음)
윈도우에서 등록정보를 보면 오디오의 정보가 잘 못표시되네요.(비트전송율)
아시는 분 도움 부탁드립니다.
아래는파일헤더를 채우는 부분입니다.

오디오 정보: IMA-adpcm, 4bit, mono, 32000sampling.
OUT--- 은 파일에 쓰는 함수입니다.

int aud_extword =0;
// sampsize = avi_sampsize(AVI);

/* Start the audio stream list ---------------------------------- */

OUT4CC ("LIST");
OUTLONG(0); /* Length of list in bytes, don't know yet */
strl_start = nhb; /* Store start position */
OUT4CC ("strl");

/* The audio stream header */

OUT4CC ("strh");
OUTLONG(64); /* # of bytes to follow */
OUT4CC ("auds");
OUT4CC ("\0\0\0\0");
OUTLONG(0); /* Flags */
OUTLONG(0); /* Reserved, MS says: wPriority, wLanguage */
OUTLONG(0); /* InitialFrames */

sampsize = 1024;
OUTLONG(sampsize); /* Scale */

//OUTLONG(sampsize*AVI->a_rate); /* Rate: Rate/Scale == samples/second */
aud_extword = (((sampsize - (4 * 1)) * 8) / (4 * 1)) + 1;
OUTLONG((32000) * sampsize / aud_extword);

OUTLONG(0); /* Start */
OUTLONG(AVI->audio_bytes/sampsize); /* Length */
// OUTLONG(0); /* SuggestedBufferSize */
OUTLONG(sampsize*8);
OUTLONG(-1); /* Quality */
OUTLONG(sampsize); /* SampleSize */
OUTLONG(0); /* Frame */
OUTLONG(0); /* Frame */
OUTLONG(0); /* Frame */
OUTLONG(0); /* Frame */

/* The audio stream format */

OUT4CC ("strf");
OUTLONG(16); /* # of bytes to follow */
OUTSHRT(AVI->a_fmt); /* Format */
OUTSHRT(AVI->a_chans); /* Number of channels */
OUTLONG(AVI->a_rate); /* SamplesPerSec */
OUTLONG(sampsize*AVI->a_rate); /* AvgBytesPerSec */
OUTSHRT(sampsize); /* BlockAlign */
OUTSHRT(AVI->a_bits); /* BitsPerSample */

/* Finish stream list, i.e. put number of bytes in the list to proper pos */

long2str(AVI_header+strl_start-4,nhb-strl_start);

}

static int avi_sampsize(avi_t *AVI)
{
int s;
s = ((AVI->a_bits+7)/8)*AVI->a_chans;
if(s==0) s=1; /* avoid possible zero divisions */
return s;
}

특히 samplesize와 scale 그리고 scale바로 아래부분이 궁금합니다.

Necromancer의 이미지

http://www.wotsit.org

가서 AVI 포맷 문서를 찾아보시면 도움이 될지 모르겠습니다.

Written By the Black Knight of Destruction

Written By the Black Knight of Destruction

Prentice의 이미지

4 x 1 x 32000 == 128000 bps == 128 kbps

맞나요?

rev7707의 이미지

감사합니다 많은 도움 됐습니다.