Audio Transcode_AAC Error -22 opening out codec

For the developers that use FFmpeg in their software.
Post Reply
dmodi
Posts: 6
Joined: Thu Mar 03, 2016 12:33 pm

Audio Transcode_AAC Error -22 opening out codec

Post by dmodi » Sat Aug 27, 2016 4:39 pm

I am trying to transcode hls mp3 audio to aac flv format, as given in the transcode_aac example. I am using Ruslan's ffmpeg .net wrapper.

Here is the code snippet -

AVCodec* output_codec = ffmpeg.avcodec_find_encoder(AVCodecID.AV_CODEC_ID_AAC);
AVStream* out_Astream = ffmpeg.avformat_new_stream(outContext, output_codec);

// out_Astream->codec = ffmpeg.avcodec_alloc_context3(output_codec);
out_Astream->codec->strict_std_compliance = -2; //experimental
out_Astream->codec->bit_rate = 64000;// audioBitrate;
out_Astream->codec->sample_fmt = AVSampleFormat.AV_SAMPLE_FMT_U8;
out_Astream->codec->sample_rate = 8000;
out_Astream->codec->channels = 1;
out_Astream->codec->profile = ffmpeg.FF_PROFILE_AAC_MAIN;
//audioCodec->time_base = (AVRational){1, sampleRate};
out_Astream->codec->time_base.num = 1;
out_Astream->codec->time_base.den = 8000;
out_Astream->codec->codec_type = AVMediaType.AVMEDIA_TYPE_AUDIO;

int err;
if ((err = ffmpeg.avcodec_open2(out_Astream->codec, output_codec, null)) < 0)
{
console.writeline("Error : {0}",err);
}

Opening the AAC encoder gives error -22.

I have tried with different parameters and also using the input stream codec parameters. But the error code is always -22. What is wrong ?

Thanks in advance.

dmodi
Posts: 6
Joined: Thu Mar 03, 2016 12:33 pm

Re: Audio Transcode_AAC Error -22 opening out codec

Post by dmodi » Sun Aug 28, 2016 2:05 pm

To add further information, I am able to mux using ffmpeg.exe

ffmpeg -report -v 9 -loglevel 99 -re -i tcp://192.168.1.111:6666?listen -i http://192.168.1.111/monet_hls/200/live.m3u8
-c:v copy -c:a aac -strict -2 -f flv rtmp://192.168.1.117:1935/live/flv_av4

Inputs are video streamed over tcp (h264, flv format); audio is mp3, 8000 Hz over HLS protocol.

I am trying to achieve the same result using the ffmpeg dll libraries.

Thanks again.

rogerdpack
Posts: 1876
Joined: Fri Aug 05, 2011 9:56 pm

Re: Audio Transcode_AAC Error -22 opening out codec

Post by rogerdpack » Wed May 24, 2017 11:52 am

maybe ask on the libav-user mailing list??

Post Reply
'