[MPlayer-dev-eng] [PATCH] select the number of channels to save with -ao pcm

Giacomo Comes comes at naic.edu
Fri Oct 7 18:59:34 CEST 2005


I was looking for a solution to extract a particular channel from a
multichannel audio stream (tipically ac3).

I found a way to listen to a specific channel with:

mplayer dvd://1 -channels 6 -af channels=1:1:4:0 (center channel)

but when I tryed to save the channel adding -ao pcm, all the six channels
where saved.

I created therefore a patch that allow to specify the number of channels
you want to save with -ao pcm.

Example:

mplayer dvd://1 -channels 6 -af channels=1:1:4:0 -ao pcm:channels=1 
(save only the center channels)

mplayer dvd://1 -channels 6 -af channels=2:2:2:0:3:1 -ao pcm:channels=2 
(save only the surround channels)

If the patch will be applied I will also include a man page update.

Comments?
Giacomo
-------------- next part --------------
--- libao2/ao_pcm.c.ori	2005-10-06 10:41:02.000000000 -0400
+++ libao2/ao_pcm.c	2005-10-06 10:42:14.000000000 -0400
@@ -27,6 +27,7 @@
 
 static char *ao_outputfilename = NULL;
 static int ao_pcm_waveheader = 1;
+static int ao_pcm_channels = 2;
 
 #define WAV_ID_RIFF 0x46464952 /* "RIFF" */
 #define WAV_ID_WAVE 0x45564157 /* "WAVE" */
@@ -82,6 +83,7 @@
 	int bits;
 	opt_t subopts[] = {
 	  {"waveheader", OPT_ARG_BOOL, &ao_pcm_waveheader, NULL},
+	  {"channels",   OPT_ARG_INT, &ao_pcm_channels, NULL},
 	  {"file",       OPT_ARG_MSTRZ, &ao_outputfilename, NULL},
 	  {NULL}
 	};
@@ -89,10 +91,15 @@
 	ao_pcm_waveheader = 1;
 	ao_outputfilename =
 	      strdup((ao_pcm_waveheader)?"audiodump.wav":"audiodump.pcm");
+	ao_pcm_channels = channels;
 	if (subopt_parse(ao_subdevice, subopts) != 0) {
 	  return 0;
 	}
 
+	if (ao_pcm_channels<channels) {
+	  channels = ao_pcm_channels;
+	}
+
 	/* bits is only equal to format if (format == 8) or (format == 16);
 	   this means that the following "if" is a kludge and should
 	   really be a switch to be correct in all cases */


More information about the MPlayer-dev-eng mailing list