[MPlayer-dev-eng] Re: mencoder HEAD: tv audio recording broken?

Oswald Buddenhagen ossi at kde.org
Sun Feb 1 03:36:10 CET 2004


On Fri, Jan 30, 2004 at 01:23:29PM +0100, Oswald Buddenhagen wrote:
> surprise surprise, it still does not work. :[
> 
> On Fri, Jan 16, 2004 at 02:52:34PM +0100, Oswald Buddenhagen wrote:
> > this must have been introduced somewhen between my last cvs update (no
> > more than two weeks) and today.
> > 
> more concretely, it was between jan 8 and jan 16.
> 
i tracked it down to rev 1.7 of libmpdemux/ai_oss.c

> things do work fine with -oac pcm, so the problem is possibly in the
> liblame interface code. liblame is current cvs HEAD (works fine when i
> downgrade mencoder).
> 
the problem is the combination of my soundcard with liblame: my card (or
the driver, whatever) says the actual sample rate is 44101, instead of
44100. as a consequence, liblame cannot handle the data:

> > my command line is (as ever):
> > 
> >  mencoder tv:// -tv \
> >   driver=v4l:width=768:height=576:volume=65535:bass=32768:treble=32768 \
> >   -vf crop=720:540:24:18,pp=lb,denoise3d -ovc lavc -lavcopts \
> >   vcodec=mpeg4:vqscale=4:keyint=300 -oac mp3lame -lameopts fast:vbr=4:q=4
> > 
> > output is: [...]
> > 
> > Video stream:  665.036 kbit/s  (83129 bps)  size: 3358431 bytes  40.400 secs  1009 frames
> > 
> > Audio stream:      nan kbit/s  (-2147483648 bps)  size: 0 bytes  0.000 secs
> >   MJP: returning!
> > 

two consequences:
- the attached patch: if the actual rate is within +/- 10 hz of the
  requested rate, pretend that it is the requested rate. the 10 is
  arbitrary - maybe it would be better to use 1, so only rounding errors
  are caught.
- we know that liblame cannot handle "odd" rates, so we should refuse
  them.

greetings

-- 
Chaos, panic, and disorder - my work here is done.
-------------- next part --------------
Index: ai_oss.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/ai_oss.c,v
retrieving revision 1.8
diff -U2 -r1.8 ai_oss.c
--- ai_oss.c	29 Jan 2004 12:43:54 -0000	1.8
+++ ai_oss.c	1 Feb 2004 02:33:02 -0000
@@ -24,9 +24,14 @@
 #include "mp_msg.h"
 
+#define TOL 10 /* rate tolerance for broken audio cards/drivers */
+
 int ai_oss_set_samplerate(audio_in_t *ai)
 {
     int tmp = ai->req_samplerate;
     if (ioctl(ai->oss.audio_fd, SNDCTL_DSP_SPEED, &tmp) == -1) return -1;
-    ai->samplerate = tmp;
+    if (tmp < ai->req_samplerate - TOL || tmp > ai->req_samplerate + TOL)
+    	ai->samplerate = tmp;
+    else
+    	ai->samplerate = ai->req_samplerate;
     return 0;
 }
@@ -104,5 +109,9 @@
 	return -1;
     }
-    ai->samplerate = ioctl_param;
+    if (ioctl_param < ai->req_samplerate - TOL ||
+	ioctl_param > ai->req_samplerate + TOL)
+	ai->samplerate = ioctl_param;
+    else
+	ai->samplerate = ai->req_samplerate;
 
     mp_msg(MSGT_TV, MSGL_V, "ioctl dsp trigger: %d\n",


More information about the MPlayer-dev-eng mailing list