[FFmpeg-devel] doc/examples/muxing.c

JULIAN GARDNER joolzg at btinternet.com
Tue Nov 4 18:39:22 CET 2014

I have been working on a program which needs to do audio resampling, and used muxing.c as a base but now i am coming up against a problem.

Changing muxing.c so that the sound produced by the routine get_audio_frame is not the same audio rate as the output causes an assert in the write_audio_frame routine, normally the program prodces the same audio rate that the output format is going to use, so the resampler really does nothing.

Modifying the audio tmp_frame definition and the associated tables for the resampler was easy but i have 1 thing which im struggling to understand

line 310 muxing.c

if (frame) { 
        /* convert samples from native format to destination codec format, using the resampler */ 
        /* compute destination number of samples */ 
        dst_nb_samples = av_rescale_rnd(swr_get_delay(ost->swr_ctx, c->sample_rate) + frame->nb_samples, 
                                                                c->sample_rate, c->sample_rate, AV_ROUND_UP); 
        av_assert0(dst_nb_samples == frame->nb_samples); 

line 335 muxing.c
        frame->pts = av_rescale_q(ost->samples_count, (AVRational){1, c->sample_rate}, c->time_base);

As the current code stands the input and output sample_rate is the same, so this code really does nothing, but now i have it so that the output is 44100 and the input is 48000, this code needs changing, my initial thought was this will use the output sample rate, but i still get the assert

Can someone who knows more about this fix the demo so that the input sample rate != output sample rate


More information about the ffmpeg-devel mailing list