Hi,

I have problem with audio_resample procedure. I decode AMR (over RTP) stream. 

Problem one: otput of ffmpeg is after calling  avcodec_open(avctx, codec) set 
to SAMPLE_FMT_FLT (however I set avctx->sample_fmt to SAMPLE_FMT_S16). But OK I 
try another way:

Problem two: Because I need to convert output of avcodec_decode_audio3 to 
SAMPLE_FMT_S16 I try this:

if ( dec->context->sample_fmt != AUDIO_FORMAT_OUT) {
        // create convertor
        ReSampleContext *ctx = av_audio_resample_init(1, dec->context->channels,
                    A_SAMPLE_RATE_OUT, dec->context->sample_rate,
                    AUDIO_FORMAT_OUT, dec->context->sample_fmt,
                    16, 10, 0, 0.8);
        
        if (ctx == NULL) { 
            av_log(dec->context, AV_LOG_ERROR, "Resampling context cannot be 
created.");
            return -1;
        }

        // size of one sample on input buffer and output buffer
        int isamp = av_get_bits_per_sample_format( dec->context->sample_fmt ) 
>> 3, 
          osamp = av_get_bits_per_sample_format( AUDIO_FORMAT_OUT ) >> 3;

        // space necessary in samples output buffer
        int extra_samples = ( dec->output_size * osamp ) / isamp;
        
        if (extra_samples + dec->samples_length >= AUDIO_BUFFER_SIZE) {
            av_log(NULL, AV_LOG_ERROR, "not enough memory");
            return -1;
        }

        extra_samples = audio_resample(ctx, dec->samples+dec->samples_length, 
dec->ffmpeg_output, dec->output_size/isamp);

        dec->samples_length += extra_samples*osamp;
        audio_resample_close( ctx );
}

in spite of putting 160 samples to audio_resample and output frequency is the 
same as input frequency I obtain extra_samples = 150 and number of processed 
samples (inside audio_resample value consumed) is 141.

Problem three: The sound is only noise not sound.

Any suggestion?

Note: I use last git version of ffmpeg

Thanks for any help

gimli
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to