[MPlayer-dev-eng] [PATCH] v4l2 interface

Jindrich Makovicka makovick at kmlinux.fjfi.cvut.cz
Mon Jan 13 18:09:22 CET 2003


Martin Olschewski wrote:

>>I'd like to commit this code if you're willing to maintain it so we 
>>could have a working and well tested v4l2 capture when v4l2 appears in 
>>the kernel.
>>    
>>
>I will try my very best.  Just for the moment there is surely a lot
>of work to do.
>
>  
>
>>Unfortunately, I don't use v4l2 and am unfamiliar with the new 
>>interface. How exactly does this tvi and v4l2 maintain the a/v sync? I 
>>found that you pass the samplerate to v4l2 but it's not clear to me how 
>>v4l2 knows which audio device is used, and thus which timebase it should 
>>use.
>>    
>>
>The name of the audio device (if any) is passed to v4l2 like in v4l.
>First it is set to some nice defaults (16-bit signed little endian
>stereo at 44100 Hz).  All of this may be changed from the command line,
>i.e. audiorate=22050 because my soundcard gives 44101 if I ask for
>44100.  From now it delivers audio frames that are as long (talking
>about time) as the video frames and makes sure that the values returned
>from grab_audio/video_frame are correct.  In the begining I suspected
>that would not be enough, but it works even if there are a lot of
>(video-) framedrops.  For same reasons I do not understand right now
>it fails if the video output is suspended for some time, i.e. if I
>press pause in mplayer.
>  
>
There's a well known problem that the timestamps of the video stream and 
sample counts are related to different timebases. It took me a while to 
make the a/v sync work and it required a lot of tedious hacking (see the 
*skew* stuff in tvi_v4l.c). If tvi_v4l2 isn't still capable to do 
internal a/v sync, it has to be compensated for in mencoder. tvi_v4l2 
corrects the video timestamps by the difference between theoretical and 
real audio sample count. On my hardware the difference does about 1s pes 
hour so it's not negligible.

In mplayer, the capture process currently works differently. Audio isn't 
captured and grab_video_frame returns timestamps with fixed delta. Any 
excess frames are silently dropped.

-- 
Jindrich Makovicka




More information about the MPlayer-dev-eng mailing list