mencoder -oac copy does not work all the times.
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
Hey,
--- 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;
rofl. This will make those files unplayable with anything else than mplayer/mencoder. The WAVEFORMATEX structure has a fixed format that you cannot change.
I did some tests and it seems to work. But I'm not sure if it breaks something else.
It breaks EVERYTHING else. Mosu -- If Darl McBride was in charge, he'd probably make marriage unconstitutional too, since clearly it de-emphasizes the commercial nature of normal human interaction, and probably is a major impediment to the commercial growth of prostitution. - Linus Torvalds
On Mon, Jan 17, 2005 at 07:15:07PM +0100, Moritz Bunkus wrote:
Hey,
--- 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;
rofl. This will make those files unplayable with anything else than mplayer/mencoder. The WAVEFORMATEX structure has a fixed format that you cannot change.
Hey, I'm not an MPlayer developer. I wrote to the list to receive comments. Do you have more contructive suggestions about the problem with LPCM audio? I have another solution in mind, but I'm waiting for more comments from other people. What would be an appopriate solution? Giacomo
On Mon, 17 Jan 2005 14:28:41 -0400 Giacomo Comes <comes@naic.edu> wrote:
On Mon, Jan 17, 2005 at 07:15:07PM +0100, Moritz Bunkus wrote:
Hey,
--- 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;
rofl. This will make those files unplayable with anything else than mplayer/mencoder. The WAVEFORMATEX structure has a fixed format that you cannot change.
Hey, I'm not an MPlayer developer. I wrote to the list to receive comments.
Do you have more contructive suggestions about the problem with LPCM audio?
maybe it is not possible to put lpcm into avi? -oac copy -of mpeg work? dvds sometimes have other audio streams, e.g. ac3. or maybe -ao pcm? does lpcm > avi work with ffmpeg? could be like putting vorbis into avi. just my two cents.
Giacomo Comes wrote on Mon, 17 Jan 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.
I propose fixing this by refusing audio streamcopy if sh_audio->format does not fit into mux_a->wf->wFormatTag, patch attached. -- Tobias PGP: http://9ac7e0bc.uguu.de
On Thu, Jun 30, 2005 at 02:21:05AM +0200, Tobias Diedrich wrote:
Giacomo Comes wrote on Mon, 17 Jan 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.
I propose fixing this by refusing audio streamcopy if sh_audio->format does not fit into mux_a->wf->wFormatTag, patch attached.
I would like a different patch. If sh_audio->format does not fit into mux_a->wf->wFormatTag issue a WARNING , but still do audio streamcopy. I have found a way to play the avi file with the LPCM audio. I create a fake codec file containing: audiocodec dvdpcm info "Uncompressed DVD/VOB LPCM" status working format 0x1 driver dvdpcm and pass MPlayer the option -codecs-file codec.dummy It's a hack, but it works. Giacomo
Giacomo Comes wrote:
I would like a different patch. If sh_audio->format does not fit into mux_a->wf->wFormatTag issue a WARNING , but still do audio streamcopy.
I have found a way to play the avi file with the LPCM audio.
Well, the patch won't stop you from playing an already encoded file. And for the LPCM case on encoding you should just select -oac pcm as the patch will suggest. The audio filter chain will then do the byte swapping from big endian to little endian. -- Tobias PGP: http://9ac7e0bc.uguu.de
On Wed, Jun 29, 2005 at 08:40:20PM -0400, Giacomo Comes wrote:
On Thu, Jun 30, 2005 at 02:21:05AM +0200, Tobias Diedrich wrote:
Giacomo Comes wrote on Mon, 17 Jan 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.
I propose fixing this by refusing audio streamcopy if sh_audio->format does not fit into mux_a->wf->wFormatTag, patch attached.
I would like a different patch. If sh_audio->format does not fit into mux_a->wf->wFormatTag issue a WARNING , but still do audio streamcopy.
Agree. The patch can either make it a warning or an error, but it needs to add -ftwocc options (like -ffourcc) to force a new tag.. Then we can make new twocc's for storing random crappy audio formats in avi.. :) Rich
Rich Felker wrote:
Agree. The patch can either make it a warning or an error, but it needs to add -ftwocc options (like -ffourcc) to force a new tag.. Then we can make new twocc's for storing random crappy audio formats in avi.. :)
Ok, how about this one? -- Tobias PGP: http://9ac7e0bc.uguu.de
On Thursday, 30 June 2005 at 16:37, Tobias Diedrich wrote:
Rich Felker wrote:
Agree. The patch can either make it a warning or an error, but it needs to add -ftwocc options (like -ffourcc) to force a new tag.. Then we can make new twocc's for storing random crappy audio formats in avi.. :)
Ok, how about this one?
-- Tobias PGP: http://9ac7e0bc.uguu.de
Index: cfg-mencoder.h =================================================================== RCS file: /cvsroot/mplayer/main/cfg-mencoder.h,v retrieving revision 1.100 diff -u -r1.100 cfg-mencoder.h --- cfg-mencoder.h 19 Jun 2005 09:12:42 -0000 1.100 +++ cfg-mencoder.h 30 Jun 2005 14:36:45 -0000 @@ -234,6 +234,7 @@
// override FOURCC in output file {"ffourcc", &force_fourcc, CONF_TYPE_STRING, CONF_GLOBAL, 4, 4, NULL}, + {"fafmt", &force_audiofmt, CONF_TYPE_INT, CONF_GLOBAL, 0, 0, NULL},
Why not ftwocc? R. -- MPlayer RPMs maintainer: http://rpm.greysector.net/mplayer/ "I am Grey. I stand between the candle and the star. We are Grey. We stand between the darkness ... and the light." -- Delenn in Grey Council in Babylon 5:"Babylon Squared"
Dominik 'Rathann' Mierzejewski wrote:
// override FOURCC in output file {"ffourcc", &force_fourcc, CONF_TYPE_STRING, CONF_GLOBAL, 4, 4, NULL}, + {"fafmt", &force_audiofmt, CONF_TYPE_INT, CONF_GLOBAL, 0, 0, NULL},
Why not ftwocc?
Because it's usually just an arbitrary value and not two characters. :-) -- Tobias PGP: http://9ac7e0bc.uguu.de
Hi, On Thu, Jun 30, 2005 at 04:37:52PM +0200, Tobias Diedrich wrote:
+ {"fafmt", &force_audiofmt, CONF_TYPE_INT, CONF_GLOBAL, 0, 0, NULL},
That's irritating, it's not the format, only the ID that is forced. Also, maybe setting s->h.fccHandler in muxer_avi to the correct, non-truncated value can do the job as well?? Greetings, Reimar Döffinger
Reimar Döffinger wrote:
Hi, On Thu, Jun 30, 2005 at 04:37:52PM +0200, Tobias Diedrich wrote:
+ {"fafmt", &force_audiofmt, CONF_TYPE_INT, CONF_GLOBAL, 0, 0, NULL},
That's irritating, it's not the format, only the ID that is forced.
Then fafmttag? Or fafmtid?
Also, maybe setting s->h.fccHandler in muxer_avi to the correct, non-truncated value can do the job as well??
No, mplayer ignores that one and other players possibly as well. -- Tobias PGP: http://9ac7e0bc.uguu.de
participants (7)
-
compn -
Dominik 'Rathann' Mierzejewski -
Giacomo Comes -
Moritz Bunkus -
Reimar Döffinger -
Rich Felker -
Tobias Diedrich