[MPlayer-dev-eng] [PATCH] TV & DXR3: mencoder works but mplayer does not

Jaroslav Tulach jtulach at netbeans.org
Sat Jan 4 17:52:53 CET 2003


Sorry if this message comes twice.


Hi,
few days ago I have cried on user mailing list that I can record from a
TV card with sound, but I cannot hear the sound during playback, I have
just investigated the problem and here is a patch to make everything
work. I'll be graceful if you could review it, improve it and integrate it.


Problem description:

mencoder -tv
on:driver=v4l:device=/dev/video0:width=384:height=288:forceaudio:forcechan=2:adevice=/dev/dsp 

-ovc lavc -lavcopts vcodec=mpeg4:vbitrate=900 -oac mp3lame -lameopts
cbr:br=32 -o Y.avi

works fine, but

mplayer -vo dxr3:noprebuf -ao oss:/dev/em8300_ma -tv
on:driver=v4l:device=/dev/video0:width=384:height=288:forceaudio:forcechan=2:adevice=/dev/dsp

does not. The reason for this is that mplayer.c sets tv_param_immediate
= 1 and then the tv_v4l.c driver disables the sound completely.



Solution:

The necessary thing to make the TV sound work is to convince the mplayer
to leave value of tv_param_immediate zero, but that would not work well
in usual cases (audio input from /dev/dsp and output to /dev/dsp). So I
decided to enable the audio only if requested. There already is a
parameter -tv forceaudio so I decided to reuse it. When specified the
tvi_v4l.c sets tv_param_immediate and tv_param_nosound to zero. Maybe
you can find a cleaner way how to do it, but this works, so it is enough
for me.

The second problem I have encountered is that the mencoder calls
grab_video_frame and after that it calls grab_audio_frame. The mplayer
calls grab_audio_frame first. This causes starvation, because video
grabbing thread in tvi_v4l.c is not started. I have solved this by
separating the starting code into own function and calling it from both
grab_*_frame functions. This should be thread safe, as I expect both
grab_*_frame functions to be called only by the mplayer/mencoder core
that is supposed to be singlethreaded, so only one video grabbing thread
is started.

I am looking forward to see conflict during cvs upd indicating that my
patch was integrated ;-)
-jst


PS: In tvi_v4l.c there is a code:

case TVI_CONTROL_IS_AUDIO:
	if (priv->channels[priv->act_channel].flags & VIDEO_VC_AUDIO)
	{
		return(TVI_CONTROL_TRUE);
	}
	return(TVI_CONTROL_TRUE);

which I think has wrong last line. It should be return FALSE, is it not?


-- 
/**
* @author Jaroslav Tulach
* @see http://www.netbeans.org
*/
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: TVAudio.diff
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20030104/8a7a2179/attachment.txt>


More information about the MPlayer-dev-eng mailing list