[MPlayer-dev-eng] pts audio sync/-tv audio/video interleaving

Arpi arpi at thot.banki.hu
Sat Mar 2 20:11:09 CET 2002


Hi,

>     sh_audio->format = sh_audio_format;
>     sh_audio->sample_format = audio_format;
> 
>     funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLERATE,
>                    &sh_audio->samplerate);
>     funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLESIZE,
>                    &sh_audio->samplesize);
>     funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_CHANNELS,
>                    &sh_audio->channels);

what are these variables set to in your case?
i wanna see the dec/hex values...

>     sh_audio->wf->nBlockAlign = sh_audio->wf->nAvgBytesPerSec;
ehh. should be samplesize*channers for PCM
anyway i doubt it matters for mencoder

>     demuxer->audio->sh = sh_audio;
>     sh_audio->ds = demuxer->audio;
>     demuxer->audio->id = 0;
> 
>     sh_audio->o_bps = sh_audio->samplerate * sh_audio->samplesize *
>                       sh_audio->channels;
>     sh_audio->i_bps = sh_audio->samplerate * sh_audio->samplesize *
>                       sh_audio->channels;
seems to be ok. did you fixed samplesize in bytes, instead of bits in your
earlier example? so for 16bit pcm it should be ==2

>     // uncompressed PCM format
>     sh_audio->wf->wFormatTag = sh_audio->format;
nope. it should be 0x1, regarding to codecs.conf codec 'pcm'

>     sh_audio->wf->nChannels = sh_audio->channels;
>     sh_audio->wf->wBitsPerSample = sh_audio->samplesize*8;
>     sh_audio->wf->nSamplesPerSec = sh_audio->samplerate;
>     sh_audio->wf->nAvgBytesPerSec = sh_audio->wf->nChannels *
>                                     sh_audio->samplesize *
>                                     sh_audio->samplerate;
is there any diff between sh_audio->channels and sh_audio->wf->nChannels ?

> AUDIO READ DATA (grab_audio_frame returns exactly len bytes each call, which
> is i_bps/fps) :
ehh. i said, you don't have to read teh same amount of audio and video
packets. it's well handled by mplayer and mencoder.
you should read small (few kbytes) audio packets to get buffering sync error
small, and try to avoid blocking by dsp device (so use select or better OSS
calls and check if there is enough data available in card's buffer)

i think each audio block should be outburst size. outburst can be detected
by using some OSS ioctls. see ao_oss.c

>             dp->pts=tvh->seq*1.0/sh_video->fps;
use gettimeofday (or better: GetTimer(0 from timer-lx.c) for both video and
audio, but dont forget to add delay of OSS buffering (use GETIDELAY ioctl)
to audio pts.

> data can be any size right?  So If I return all audio data in one chunk
> (instead of framed) and slap the timeofday() stamp on the last byte read, wi
> ll
> it work it backwards properly?  I guess is PTS beginning of frame or end of
> frame?.. Will experiment with this):
beginnig of block.
so do GETIDELAY before reading out buffer, then GetTimer and sub/add value
from GETIDELAY

>         dp->pts=cframe/sh_video->fps;
GetTimer here too

if you have audio and video coming from different sources, then calculating
audio pts from video frame no is a VERY BAD IDEA.


A'rpi / Astral & ESP-team

--
Developer of MPlayer, the Movie Player for Linux - http://www.MPlayerHQ.hu



More information about the MPlayer-dev-eng mailing list