Commits

Michael Ziegler committed 9a38838

add channel layout constants and get_channel_layout methods

  • Participants
  • Parent commits 96349c5

Comments (0)

Files changed (2)

File myffmpeg/ffmpeg.py

                     AV_SAMPLE_FMT_S32P, \
                     AV_SAMPLE_FMT_FLTP, \
                     AV_SAMPLE_FMT_DBLP, \
-                    AV_SAMPLE_FMT_NB
+                    AV_SAMPLE_FMT_NB,   \
+                    AV_CH_LAYOUT_STEREO,   \
+                    AV_CH_LAYOUT_2POINT1,  \
+                    AV_CH_LAYOUT_2_1,      \
+                    AV_CH_LAYOUT_SURROUND, \
+                    AV_CH_LAYOUT_2_2,      \
+                    AV_CH_LAYOUT_QUAD,     \
+                    AV_CH_LAYOUT_STEREO_DOWNMIX
 
 
 class Decoder(object):
             self.resampler = None
 
     channels   = property( lambda self: self._decoder.get_channels(),   doc="The number of channels in the input stream." )
+    channel_layout = property( lambda self: self._decoder.get_channel_layout(), doc="The channel layout of the input stream." )
     bitrate    = property( lambda self: self._decoder.get_bitrate(),    doc="The bitrate of the input channels." )
     duration   = property( lambda self: self._decoder.get_duration(),   doc="The length of the input stream in seconds." )
     path       = property( lambda self: self._decoder.get_path(),       doc="The input file path." )

File myffmpeg/ffmpegmodule.c

 	return PyInt_FromLong( self->pCodecCtx->channels );
 }
 
+static PyObject* ffmpeg_decoder_get_channel_layout( ffmpegDecoderObject* self ){
+	return PyInt_FromLong( self->pCodecCtx->channel_layout );
+}
+
 static PyObject* ffmpeg_decoder_get_codec( ffmpegDecoderObject* self ){
 	return PyString_FromString( self->pCodecCtx->codec->name );
 }
 	{ "get_samplerate", (PyCFunction)ffmpeg_decoder_get_samplerate, METH_NOARGS, "get_samplerate()\nReturn the sample rate of the decoded file." },
 	{ "get_samplefmt",  (PyCFunction)ffmpeg_decoder_get_samplefmt,  METH_NOARGS, "get_samplefmt()\nReturn the sample format of the decoded file." },
 	{ "get_channels",   (PyCFunction)ffmpeg_decoder_get_channels,   METH_NOARGS, "get_channels()\nReturn the number of channels in the decoded file." },
+	{ "get_channel_layout", (PyCFunction)ffmpeg_decoder_get_channel_layout, METH_NOARGS, "get_channel_layout()\nReturn the channel layout." },
 	{ "get_duration",   (PyCFunction)ffmpeg_decoder_get_duration,   METH_NOARGS, "get_duration()\nReturn the duration of the decoded file in seconds." },
 	{ "get_metadata",   (PyCFunction)ffmpeg_decoder_get_metadata,   METH_NOARGS, "get_metadata()\nReturn a dict containing the file's meta data." },
 	{ "get_codec",      (PyCFunction)ffmpeg_decoder_get_codec,      METH_NOARGS, "get_codec()\nReturn the name of the codec being used." },
 	PyModule_AddIntMacro( module, AV_SAMPLE_FMT_FLTP );
 	PyModule_AddIntMacro( module, AV_SAMPLE_FMT_DBLP );
 	PyModule_AddIntMacro( module, AV_SAMPLE_FMT_NB   );
+
+	PyModule_AddIntMacro( module, AV_CH_LAYOUT_STEREO         );
+	PyModule_AddIntMacro( module, AV_CH_LAYOUT_2POINT1        );
+	PyModule_AddIntMacro( module, AV_CH_LAYOUT_2_1            );
+	PyModule_AddIntMacro( module, AV_CH_LAYOUT_SURROUND       );
+	PyModule_AddIntMacro( module, AV_CH_LAYOUT_2_2            );
+	PyModule_AddIntMacro( module, AV_CH_LAYOUT_QUAD           );
+	PyModule_AddIntMacro( module, AV_CH_LAYOUT_STEREO_DOWNMIX );
 	
 	avcodec_register_all();
 	av_register_all();