[MPlayer-dev-eng] audio pts bad in mplayer if audio encoding with lavc (mencoder)
Ötvös Attila
oattila at chello.hu
Thu Jan 17 11:42:09 CET 2008
Hi All!
My problem incorrect apts if I play with mplayer encoded avi:
mencoder in.avi -ovc lavc -oac lavc -o out.avi
mplayer out.avi -> apts=correct pts * audio block len
Relevant files ----------:
libmpcodecs/ae_lavc:
static int bind_lavc(audio_encoder_t *encoder, muxer_stream_t *mux_a)
line 50:
if(lavc_actx->block_align)
mux_a->h.dwSampleSize = mux_a->h.dwScale = lavc_actx->block_align;
else
{
mux_a->h.dwScale = (mux_a->wf->nAvgBytesPerSec * lavc_actx->frame_size)/
mux_a->wf->nSamplesPerSec; /* for cbr */
if ((mux_a->wf->nAvgBytesPerSec *
lavc_actx->frame_size) % mux_a->wf->nSamplesPerSec)
{
mux_a->h.dwScale = lavc_actx->frame_size;
mux_a->h.dwRate = lavc_actx->sample_rate;
mux_a->h.dwSampleSize = 0; // Blocksize not constant
}
else
mux_a->h.dwSampleSize = 0;
}
if(mux_a->h.dwSampleSize)
mux_a->wf->nBlockAlign = mux_a->h.dwSampleSize;
else
mux_a->wf->nBlockAlign = 1;
libmpdemux/demux_avi:
demux_stream_t* demux_avi_select_stream(demuxer_t *demux,unsigned int id)
line 45:
if(sh->wf){
priv->audio_block_size=sh->wf->nBlockAlign;
libmpdemux/demux_avi:
static int demux_avi_read_packet(demuxer_t *demux,demux_stream_t *ds,unsigned
int id,unsigned int len,int idxpos,int flags)
line 125:
if(pts_from_bps){
pts = priv->audio_block_no *
(float)((sh_audio_t*)demux->audio->sh)->audio.dwScale /
(float)((sh_audio_t*)demux->audio->sh)->audio.dwRate;
} else
pts=priv->avi_audio_pts; //+priv->pts_correction;
priv->avi_audio_pts=0;
// update blockcount:
priv->audio_block_no+=priv->audio_block_size ?
((len+priv->audio_block_size-1)/priv->audio_block_size) : 1;
end of relevant files --------
mencoder:
nBlockAlign always 1 if lavc_actx->block_align is 0
mplayer:
priv->audio_block_no+=(packet len) if nBlockAlign is 1 -->
pts=(byte pos)*dwScale/dwRate if nBlockAlign is 1
I think so correct apts:
nBlockAlign=dwScale in mencoder (ae_lavc) or
swScale=1 if nBlockAlign is 1 in mplayer (demux_avi)
Comment or other solving?
Best regards.
Attila
-------------- next part --------------
A non-text attachment was scrubbed...
Name: simplify_to_ae_lavc.patch
Type: text/x-diff
Size: 1296 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20080117/0a8b9067/attachment.patch>
More information about the MPlayer-dev-eng
mailing list