Opened 15 years ago

Closed 13 years ago

Last modified 13 years ago

#122 closed defect (wontfix)

Mencoder is unable to record sound, video ok

Reported by: sakari.ailus@… Owned by: alex@…
Priority: normal Component: ad
Version: 1.0pre5 Severity: critical
Keywords: Cc:
Blocked By: Blocking:
Reproduced by developer: Analyzed by developer:

Description

Mencoder is not able to record sound, while video is ok. This is both CVS
version (23.10.2004) and 1.0pre5. 1.0pre3try2 works fine.

Mencoder is fairly unusable because of this.

(I posted this information also on mplayer-users, it's here:
<URL:http://mplayerhq.hu/pipermail/mplayer-users/2004-October/049182.html>)

Here's output from the latest CVS version:

---
mencoder tv:// -passlogfile /tmp/mrec-tmp-8812 -oac mp3lame -lavcopts
vqscale=7:vcodec=mpeg4 -ovc lavc -o baz.avi -tv
driver=v4l2:height=576:device=/dev/video0:adevice=/dev/dsp2:width=768
-lameopts aq=0:vbr=0:br=64
MEncoder dev-CVS-041023-19:16-3.4.2 (C) 2000-2004 MPlayer Team

CPU: Advanced Micro Devices Athlon MP/XP Thoroughbred (Family: 6,
Stepping: 1)
Detected cache-line size is 64 bytes
CPUflags: Type: 6 MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 0
Compiled with runtime CPU detection - WARNING - this is not optimal!
To get best performance, recompile MPlayer with
--disable-runtime-cpudetection.
Reading /home/sakke/.mplayer/codecs.conf: This codecs.conf is too old
and incompatible with this MPlayer release! at line 6
Reading /etc/mplayer/codecs.conf: Can't open '/etc/mplayer/codecs.conf':
No such file or directory
Using built-in default codecs.conf.
File not found: 'frameno.avi'
Failed to open frameno.avi
Reading config file /home/sakke/.mplayer/mencoder
Font /home/sakke/.mplayer/font/font.desc loaded successfully! (206 chars)
success: format: 9 data: 0x0 - 0x0
TV detected! ;-)
Selected driver: v4l2

name: Video 4 Linux 2 input
author: Martin Olschewski <olschewski at zpr.uni-koeln.de>
comment: first try, more to come ;-)

Selected device: BT878 video (Pinnacle PCTV Stud

Tuner cap:
Tuner rxs: MONO
Capabilites: video capture video overlay VBI capture device tuner
read/write streaming
supported norms: 0 = PAL; 1 = NTSC; 2 = SECAM; 3 = PAL-Nc; 4 = PAL-M;

5 = PAL-N; 6 = NTSC-JP; 7 = PAL-60;

inputs: 0 = Television; 1 = Composite1; 2 = S-Video;
Current input: 0
Current format: YUV420

v4l2: current audio mode is : MONO
audio block size too low, setting to 8192!
[V] filefmt:9 fourcc:0x32315659 size:768x576 fps:25.00 ftime:=0.0400
==========================================================================
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 44101 Hz, 1 ch, 16 bit (0x10), ratio: 88202->88202 (705.6 kbit)
Selected audio codec: [pcm] afm:pcm (Uncompressed PCM)
==========================================================================
Opening video filter: [expand osd=1]
Expand: -1 x -1, -1 ; -1 (-1=autodetect) osd: 1
==========================================================================
Opening video decoder: [raw] RAW Uncompressed Video
VDec: vo config request - 768 x 576 (preferred csp: Planar YV12)
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is undefined - no prescaling applied.
videocodec: libavcodec (768x576 fourcc=58564944 [DIVX])
Using constant qscale = 7.000000 (VBR)
Selected video codec: [rawyv12] vfm:raw (RAW YV12)
==========================================================================
MP3 audio selected
Building audio filter chain for 44101Hz/1ch/16bit -> 44101Hz/1ch/16bit...
Writing AVI header...
ODML: Aspect information not (yet?) available or unspecified, not
writing vprp header.
Forcing audio preload to 0, max pts correction to 0
ODML: Aspect information not (yet?) available or unspecified, not
writing vprp header.
v4l2: select failed: Interrupted system calln 0mb A-V:0.000 [1118:0]

not enough audio samples!
Pos: 9.4s 234f ( 0%) 25fps Trem: 0min 0mb A-V:0.000 [1118:0]
Flushing video frames
---

The sound is recorded from a sound card /dev/dsp2 with OSS driver. It
looks like mencoder detects number of channels etc. correcly, but still
is unable to record any sound. The bit rate for sound is zero.

The TV tuner card uses bttv driver from V4L2.

Here's log from 1.0pre3try2, which works. The command line options are
the same with the excepion of file name in case you're wondering.

---
encoder tv:// -passlogfile /tmp/mrec-tmp-8943 -oac mp3lame -lavcopts
vqscale=7:vcodec=mpeg4 -ovc lavc -o bar.avi -tv
driver=v4l2:height=576:device=/dev/video0:adevice=/dev/dsp2:width=768
-lameopts aq=0:vbr=0:br=64
MEncoder 1.0pre3try2-3.3.1 (C) 2000-2003 MPlayer Team

CPU: Advanced Micro Devices Athlon MP/XP Thoroughbred 2010 MHz (Family:
6, Stepping: 1)
Detected cache-line size is 64 bytes
CPUflags: Type: 6 MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 0
Compiled with Runtime CPU Detection - WARNING - this is not optimal!
To get best performance, recompile MPlayer with
--disable-runtime-cpudetection.
Reading /home/sakke/.mplayer/codecs.conf: This codecs.conf is too old
and incompatible with this MPlayer release! at line 6
Reading /etc/mplayer/codecs.conf: Can't open '/etc/mplayer/codecs.conf':
No such file or directory
Using built-in default codecs.conf.
File not found: 'frameno.avi'
Failed to open frameno.avi
Reading config file /home/sakke/.mplayer/mencoder
Font /home/sakke/.mplayer/font/font.desc loaded successfully! (206 chars)
success: format: 9 data: 0x0 - 0x0
TV detected! ;-)
Selected driver: v4l2

name: Video 4 Linux 2 input
author: Martin Olschewski <olschewski at zpr.uni-koeln.de>
comment: first try, more to come ;-)

Selected device: BT878 video (Pinnacle PCTV Stud

Tuner cap:
Tuner rxs: MONO
Capabilites: video capture video overlay VBI capture device tuner
read/write streaming
supported norms: 0 = PAL; 1 = NTSC; 2 = SECAM; 3 = PAL-Nc; 4 = PAL-M;

5 = PAL-N; 6 = NTSC-JP; 7 = PAL-60;

inputs: 0 = Television; 1 = Composite1; 2 = S-Video;
Current input: 0
Current format: YUV420

v4l2: current audio mode is : MONO
audio block size too low, setting to 8192!
[V] filefmt:9 fourcc:0x32315659 size:768x576 fps:25.00 ftime:=0.0400
==========================================================================
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 44100 Hz, 1 ch, 16 bit (0x10), ratio: 88200->88200 (705.6 kbit)
Selected audio codec: [pcm] afm:pcm (Uncompressed PCM)
==========================================================================
Opening video filter: [expand osd=1]
Expand: -1 x -1, -1 ; -1 (-1=autodetect) osd: 1
==========================================================================
Opening video decoder: [raw] RAW Uncompressed Video
VDec: vo config request - 768 x 576 (preferred csp: Planar YV12)
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is undefined - no prescaling applied.
videocodec: libavcodec (768x576 fourcc=58564944 [DIVX])
Using constant qscale = 7.000000 (VBR)
Selected video codec: [rawyv12] vfm:raw (RAW YV12)
==========================================================================
MP3 audio selected
Building audio filter chain for 44100Hz/1ch/16bit -> 44100Hz/1ch/16bit...
Writing AVI header...
Forcing audio preload to 0, max pts correction to 0
v4l2: select failed: Interrupted system calln 0mb A-V:0.000 [2010:63]

not enough audio samples!
Pos: 2.2s 53f ( 0%) 21fps Trem: 0min 0mb A-V:0.000 [1999:63]

CBR audio: 8000 bytes/sec, 209 bytes/block

Writing AVI index...
Fixing AVI header...

Video stream: 1999.581 kbit/s (249947 bps) size: 539887 bytes 2.160
secs 53 frames

Audio stream: 63.999 kbit/s (7999 bps) size: 17136 bytes 2.142 secs
v4l2: 61 frames successfully processed, 0 frames dropped.
---

I don't know if this happens to everyone trying to record also sound
with mencoder, but I've tried a few times and had the same result.

The newer mplayer was compiled with GCC 3.4.2, while the old one is with
3.3.1. Should not matter, though...

Change History (9)

comment:1 Changed 14 years ago by makovick@…

please try to reverse this patch and let me know if it fixes your problem. but
if it does, it probably means audio drivers for your card are buggy.

http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/libmpdemux/ai_oss.c.diff?r2=1.8&r1=1.7&f=u

comment:2 Changed 14 years ago by makovick@…

please try to reverse this patch and let me know if it fixes your problem. but
if it does, it probably means audio drivers for your card are buggy.

http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/libmpdemux/ai_oss.c.diff?r2=1.8&r1=1.7&f=u

comment:3 Changed 14 years ago by sakari.ailus@…

I tried the patch and it didn't help. Neither switching GCC version had any
effect. Hm...

The sound card is SB 128 PCI. Its driver is es1371 from Linux 2.4.28.

comment:4 Changed 14 years ago by sakari.ailus@…

I must say that you were close. I kept forking the CVS by date to isolate the
change which caused the problem. It turned out that a tiny change to
libmpdemux/ai_oss.c made in the morning of 11.1.2004 was the problem. It's the
change just before the change you suspected to be the cause of the problem. ;)

---
Index: main/libmpdemux/ai_oss.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/ai_oss.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- main/libmpdemux/ai_oss.c 7 Aug 2003 12:24:35 -0000 1.6
+++ main/libmpdemux/ai_oss.c 11 Jan 2004 10:01:18 -0000 1.7
@@ -27,7 +27,7 @@

{

int tmp = ai->req_samplerate;
if (ioctl(ai->oss.audio_fd, SNDCTL_DSP_SPEED, &tmp) == -1) return -1;

  • ai->samplerate = ai->req_samplerate;

+ ai->samplerate = tmp;

return 0;

}


---

I checked the values of tmp and ai->req_samplerate in the assignment to
ai->samplerate, and they were 44101 and 44100, respectively. I can now also see
the diffecences in mencoder log:

This is with the change:
---
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 44101 Hz, 1 ch, 16 bit (0x10), ratio: 88202->88202 (705.6 kbit)
Selected audio codec: [pcm] afm:pcm (Uncompressed PCM)
---
vs. without it:
---
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 44100 Hz, 1 ch, 16 bit (0x10), ratio: 88200->88200 (705.6 kbit)
Selected audio codec: [pcm] afm:pcm (Uncompressed PCM)
---

It seems that the sound card driver changes the requested sample rate (44100 Hz)
to 44101 Hz (maybe it thinks it can't do exactly 44100 Hz), and then something
is not at all happy with this. I noticed that if I use -tv with
audiorate=something it works, when that something is 48000 or 22050. Any values,
like 46000 or 47000, don't work. I assume it's ok when the driver changes 44100
Hz to e.g. 22050 but it's not ok to have just any sample rate here.

So, the change assumes that sound card drivers only can record at some
frequencies it supports. Apparently that doesn't hold with just any sound card
driver.

comment:5 Changed 14 years ago by reimar

This looks like a bug in your sound driver. MP3 supports only certain sample
rates. You must add -srate 44100 to make it work. Maybe this should be said in
the FAQ if it isn't already there. Who volunteers to check and send a patch?

comment:6 Changed 14 years ago by sakari.ailus@…

There are situations where it can happen that the requested sample rate is not
the same than returned, whether it was a hardware's limitation, driver's
arrogancy or a bug. And if it's a hardware limitation, the driver may "fix" it
only by lying, no matter if it's ALSA or OSS.

According to OSS Programmer's guide v1.1
<URL:http://www.opensound.com/pguide/oss.pdf>, page 35,

---
Codec devices usually generate the sampling clock by dividing the frequency of a
high speed crystal
oscillator. In this way it is not possible to generate all possible frequencies
in the valid range. For
this reason the driver always computes the valid frequency which is closest to
the requested one and
returns it to the calling program. The application should check the returned
frequency and to
compare it with the requested one. Differences of few percents should be ignored
since they are
usually not audible. A larger difference means that the device is not capable to
reproduce the
requested sampling rate at all or it may be currently configured to use some
fixed rate.
Also note that this call rarely returns an error (-1). Getting an OK result
doesn't mean that the
requested sampling rate was accepted. The value returned in the argument needs
to be checked.
---

I suppose that for 1 Hz or similar difference no resampling is required. Most
devices around now can do 44100 Hz fairly well, that's what they're designed
for... Also note that the clocks may not be so accurate. It might be that a
device tells it records at 44100 Hz, but really uses 44110 Hz...

In short: it was working, now it's broken. X)

comment:7 Changed 14 years ago by sakari.ailus@…

Yeah, a sound card using 44110 Hz frequency when it says it's using 44100 Hz
would probably be a very lousy one, but you got the point. :)

comment:8 Changed 14 years ago by reimar

I suppose that for 1 Hz or similar difference no resampling is required. Most
devices around now can do 44100 Hz fairly well, that's what they're designed
for... Also note that the clocks may not be so accurate. It might be that a
device tells it records at 44100 Hz, but really uses 44110 Hz...

Well, with the quality of the current resampling filter it better shouldn't do
resampling ;-). Though you could add -af lavcresample=44100, too. The quality
should be acceptable. But probably -srate 44100 is the better solution.
I can't test myself, so can you tell me if these solutions actually work?

In short: it was working, now it's broken. X)

No, it was broken, now it is correct. Only that sometimes the correct way is
much more problematic :-(

comment:9 Changed 13 years ago by reimar

  • Resolution set to wontfix
  • Status changed from new to closed

Current behaviour seems correct, although uncomfortable, thus WONTFIX. If there
is additional information that would contradict this assumption (like -srate
44100 not helping), reopen.

Note: See TracTickets for help on using tickets.