Thursday 15 April 2010

c - ffmpeg avcodec_open2 returns -22 if I change my speaker configuration -



c - ffmpeg avcodec_open2 returns -22 if I change my speaker configuration -

i maintain having unusual issue lately. depending on how set sound configuration in windows ( stereo/quad/5.1 ), ffmpeg phone call avcodec_open2() fails error -22 or works. not beingness able find much error, thought should inquire here. main flow goes this:

c = st->codec; avformat_alloc_output_context2(&oc, null, null, "video.mpeg"); oc->fmt->audio_codec = av_codec_id_mp2; avdictionary* dict = null; ret = av_dict_set(&dict, "ac", "2", 0); c->request_channels = 2; ret = avcodec_open2(c, codec, &dict); //here fails -22 if speaker configuration not stereo

the codec context 'c' set in stream:

st = avformat_new_stream(oc, *codec); c = st->codec; c->channels = 2; c->channel_layout = av_ch_layout_stereo; c->sample_fmt = av_sample_fmt_s16; c->codec_id = codec_id;

most of copied 1 of muxing examples found in documentation. works expected if in windows have set output stereo.

if set speaker configuration 5.1 ( 6 channels ), avcodec_open2 fails error -22.

so have hard time understanding doing wrong. should not relationship between speaker configuration , result of avcodec_open2.

are there other parameters need set ?

here header file libavcodec\avcodec.h taken how can find out ffmpeg error code means?

#if einval > 0 #define averror(e) (-(e)) /**< returns negative error code posix error code, homecoming library functions. */ #define avunerror(e) (-(e)) /**< returns posix error code library function error homecoming value. */ #else /* platforms have e* , errno negated. */ #define averror(e) (e) #define avunerror(e) (e) #endif #define averror_unknown averror(einval) /**< unknown error */ #define averror_io averror(eio) /**< i/o error */ #define averror_numexpected averror(edom) /**< number syntax expected in filename. */ #define averror_invaliddata averror(einval) /**< invalid info found */ #define averror_nomem averror(enomem) /**< not plenty memory */ #define averror_nofmt averror(eilseq) /**< unknown format */ #define averror_notsupp averror(enosys) /**< operation not supported. */ #define averror_noent averror(enoent) /**< no such file or directory. */ #define averror_eof averror(epipe) /**< end of file. */ #define averror_patchwelcome -mktag('p','a','w','e') /**< not yet implemented in ffmpeg. patches welcome. */

then errno.h header file einval

#define einval 22 /* invalid argument */

p.s. averror means (-(-22)) = 22

layout channels header channel_layout.h header file

/** * @file * sound conversion routines */ /* sound channel masks */ #define av_ch_front_left 0x00000001 #define av_ch_front_right 0x00000002 #define av_ch_front_center 0x00000004 #define av_ch_low_frequency 0x00000008 #define av_ch_back_left 0x00000010 #define av_ch_back_right 0x00000020 #define av_ch_front_left_of_center 0x00000040 #define av_ch_front_right_of_center 0x00000080 #define av_ch_back_center 0x00000100 #define av_ch_side_left 0x00000200 #define av_ch_side_right 0x00000400 #define av_ch_top_center 0x00000800 #define av_ch_top_front_left 0x00001000 #define av_ch_top_front_center 0x00002000 #define av_ch_top_front_right 0x00004000 #define av_ch_top_back_left 0x00008000 #define av_ch_top_back_center 0x00010000 #define av_ch_top_back_right 0x00020000 #define av_ch_stereo_left 0x20000000 ///< stereo downmix. #define av_ch_stereo_right 0x40000000 ///< see av_ch_stereo_left. /** channel mask value used avcodeccontext.request_channel_layout indicate user requests channel order of decoder output native codec channel order. */ #define av_ch_layout_native 0x8000000000000000ll /* sound channel convenience macros */ #define av_ch_layout_mono (av_ch_front_center) #define av_ch_layout_stereo (av_ch_front_left|av_ch_front_right) #define av_ch_layout_2_1 (av_ch_layout_stereo|av_ch_back_center) #define av_ch_layout_surround (av_ch_layout_stereo|av_ch_front_center) #define av_ch_layout_4point0 (av_ch_layout_surround|av_ch_back_center) #define av_ch_layout_2_2 (av_ch_layout_stereo|av_ch_side_left|av_ch_side_right) #define av_ch_layout_quad (av_ch_layout_stereo|av_ch_back_left|av_ch_back_right) #define av_ch_layout_5point0 (av_ch_layout_surround|av_ch_side_left|av_ch_side_right) #define av_ch_layout_5point1 (av_ch_layout_5point0|av_ch_low_frequency) #define av_ch_layout_5point0_back (av_ch_layout_surround|av_ch_back_left|av_ch_back_right) #define av_ch_layout_5point1_back (av_ch_layout_5point0_back|av_ch_low_frequency) #define av_ch_layout_7point0 (av_ch_layout_5point0|av_ch_back_left|av_ch_back_right) #define av_ch_layout_7point1 (av_ch_layout_5point1|av_ch_back_left|av_ch_back_right) #define av_ch_layout_7point1_wide (av_ch_layout_5point1_back|av_ch_front_left_of_center|av_ch_front_right_of_center) #define av_ch_layout_stereo_downmix (av_ch_stereo_left|av_ch_stereo_right)

c ffmpeg

No comments:

Post a Comment