[MPlayer-dev-eng] mencoder -oac copy does not work all the times.
Giacomo Comes
comes at naic.edu
Mon Jan 17 17:45:09 CET 2005
I have found that -oac copy produces incorrect results
in some particular cases.
Here is a simple way to test the bug;
take a dvd with LPCM audio and do:
mencoder dvd://1 -ovc frameno -oac copy -aid 160 -frames 500 -o file.avi
Now play file.avi: mplayer file.avi
You will get only loud noise.
Explanation of the bug:
durning the copy mencoder stores in the avi header the format of the
audio stream, the line of C code that does it in mencoder.c is:
mux_a->wf->wFormatTag = sh_audio->format
Now format, member of the structure sh_audio_t, is a unsigned int
but wFormatTag, member of the structure WAVEFORMATEX, is a unsigned short.
If the audio stream has a format that can be represented with 16 bit,
the result is correct:
0x50 (mp2)
0x55 (mp3)
0x2000 (ac3)
0x1 (pcm)
If the audio stream has a format that requires more than 16 bit,
it cannot be stored correctly in the avi header.
0x10001 (dvdpcm)
and all the other 32 bit format listed in codec.conf
I have prepared this small patch:
--- libmpdemux/ms_hdr.h.ori 2005-01-17 11:49:41.000000000 -0400
+++ libmpdemux/ms_hdr.h 2005-01-17 11:50:37.000000000 -0400
@@ -4,7 +4,7 @@
#ifndef _WAVEFORMATEX_
#define _WAVEFORMATEX_
typedef struct __attribute__((__packed__)) _WAVEFORMATEX {
- unsigned short wFormatTag;
+ unsigned int wFormatTag;
unsigned short nChannels;
unsigned int nSamplesPerSec;
unsigned int nAvgBytesPerSec;
I did some tests and it seems to work. But I'm not sure if
it breaks something else.
Can anybody comment on this patch?
I have found a similar structure defined in loader/wine/mmreg.h
the following patch change wFormatTag as before, but I dont know
if this should be appliend or not, may be it is not necessary.
--- loader/wine/mmreg.h.ori 2005-01-17 12:30:33.000000000 -0400
+++ loader/wine/mmreg.h 2005-01-17 12:30:38.000000000 -0400
@@ -47,7 +47,7 @@
#ifndef _WAVEFORMATEX_
#define _WAVEFORMATEX_
typedef struct __attribute__((__packed__)) _WAVEFORMATEX {
- WORD wFormatTag;
+ DWORD wFormatTag;
WORD nChannels;
DWORD nSamplesPerSec;
DWORD nAvgBytesPerSec;
I can prepare and submit a proprer patch if requested.
Giacomo
More information about the MPlayer-dev-eng
mailing list