[Mjpeg-users] lav_read_audio: how many samples for ONE frame?

2003-01-19 Thread Torsten Mohr
Hi,

i try to do some video and audio effects on some AVI streams,
i have some questions related to that, it would be great if
someone could give me some hints.

I just sampled an AVI stream with lavrec, audio in 16 bits, 1 channel,
audio rate is 11025.

When i open that stream and read out the informations in it i get:

Video frames: 438
Video rate: 25.0 frames per second

Audio channels: 1
Audio Bits: 16
Audio Rate: 11025
Audio Samples: 192413

I try to check the audio sample number now:

438*11025/25 is 193158, that's higher than the number in the stream.

437*11025/25 is 192717, that's still too high, though i took one
frame less.


I'd like to mix two (or more) streams (video works!) but when
i try to figure out how many samples are related to a video
frame it gets annoying.
I only work with frames with matching audio/video parameters,
so rate, bits, channels are the same.

As in the example above, it seems i can't just try to read the
(audio_rate/video_rate) samples.

So i tried it a different way:

audio_pos = video_frame * audio_samples / all_video_frames;
audio_pos = ~1;

I calculate the size of the data as:

size = audio_pos(frame+1) - audio_pos(frame);

But this leads to differing sizes, sometimes 438, sometimes 440.
(Also, for large number of frames there can be an overflow.)

So when i read in video frames from TWO streams, the audio size
of the first one may be 438, the second one 440.  This leads
to complicated algorithms for mixing the audio data.


Has anybody got an idea of how to read in the audio chunks
related to a frame?  I'd like to use a fixed buffer size,
this would make things much easier.


Thanks for any hints,
Torsten.



---
This SF.NET email is sponsored by: FREE  SSL Guide from Thawte
are you planning your Web Server Security? Click here to get a FREE
Thawte SSL guide and find the answers to all your  SSL security issues.
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en
___
Mjpeg-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mjpeg-users



Re: [Mjpeg-users] lav_read_audio: how many samples for ONE frame?

2003-01-19 Thread Ronald Bultje
Hi Torsten,

On Sun, 2003-01-19 at 21:40, Torsten Mohr wrote:
 When i open that stream and read out the informations in it i get:
 
 Video frames: 438
 Video rate: 25.0 frames per second
 
 Audio channels: 1
 Audio Bits: 16
 Audio Rate: 11025
 Audio Samples: 192413
 
 I try to check the audio sample number now:
 
 438*11025/25 is 193158, that's higher than the number in the stream.
 
 437*11025/25 is 192717, that's still too high, though i took one
 frame less.

You don't know the exact practical sample rate. The requested sample
rate is 11025, but audio card clocks are often biased a bit.

 So when i read in video frames from TWO streams, the audio size
 of the first one may be 438, the second one 440.  This leads
 to complicated algorithms for mixing the audio data.

Well, yes. You'd need to either resample the audio or just accept that
audio can be slightly time-biased within frames (just try to keep this
in track by using a total_audio_samples counter). Mixing audio isn't
that simple, I fear.

Anyway, I don't have much experience here either, others might be able
to give much better advice.

Ronald

-- 
Ronald Bultje [EMAIL PROTECTED]
Linux Video/Multimedia developer



---
This SF.NET email is sponsored by: FREE  SSL Guide from Thawte
are you planning your Web Server Security? Click here to get a FREE
Thawte SSL guide and find the answers to all your  SSL security issues.
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en
___
Mjpeg-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mjpeg-users