1

Topic: FFMPEG: swr_convert ()

It is necessary for audio to translate me the frame of format AV_SAMPLE_FMT_S16 in AV_SAMPLE_FMT_S32P. For this purpose I use swr_convert () which takes off in . Program received signal SIGSEGV, Segmentation fault. A surrounding 10 Windows, Code:: Blocks 16.01. Here all under the order (in the simplified code): 1. Initialization SwrContext of a context. I do it through the homebrew class: class CSwrContext {public: SwrContext* m_pSwr; int64_t m_out_ch_layout; enum AVSampleFormat m_out_sample_fmt; int m_out_sample_rate; int64_t m_in_ch_layout; enum AVSampleFormat m_in_sample_fmt; int m_in_sample_rate; CSwrContext () {m_pSwr = NULL;} ~CSwrContext () {if (m_pSwr) swr_free (&m_pSwr);} bool CreateSwrContext (void) {m_pSwr = swr_alloc_set_opts (NULL, m_out_ch_layout, m_out_sample_fmt, m_out_sample_rate, m_in_ch_layout, m_in_sample_fmt, m_in_sample_rate, 0, NULL); if (m_pSwr == NULL) return false; if (swr_init (m_pSwr) <0) return false; return true;} }; CSwrContext g_CSwr;//Entering parameters: g_CSwr.m_in_ch_layout = AV_CH_LAYOUT_STEREO; g_CSwr.m_in_sample_fmt = AV_SAMPLE_FMT_S16; g_CSwr.m_in_sample_rate = 44100;//the Output g_CSwr.m_out_ch_layout = AV_CH_LAYOUT_STEREO; g_CSwr.m_out_sample_fmt = AV_SAMPLE_FMT_S32P; g_CSwr.m_out_sample_rate = 44100; if (! g_CSwr. CreateSwrContext ()) {//leaving by mistake} 2. The generated frame entering audio turns out the following: AVFrame *decoded_frame;//this part decoded_frame-> data [0] is filled only here;//an amount of samples 44100 decoded_frame-> nb_samples;//the size of a packet 176400 decoded_frame-> pkt_size; 3. I calculate number of samples for an input and an output: int in_samples = decoded_frame-> nb_samples; int out_samples = av_rescale_rnd (swr_get_delay (g_CSwr.m_pSwr, 44100) + 44100, 44100, 44100, AV_ROUND_UP);//result: in_samples = out_samples = 44100; 4. I calculate the output buffer: int64_t size_out; uint8_t *output = NULL; if ((size_out = av_samples_alloc (&output, NULL, 2, out_samples, AV_SAMPLE_FMT_S32P, 0)) <0) {//leaving by mistake}//on an output I receive size_out = 2822400 5. Further I try all : size_out = swr_convert (g_CSwr.m_pSwr, &output, out_samples, (const uint8_t **) decoded_frame-> data, in_samples);//here I take off in  Where I here ?

2

Re: FFMPEG: swr_convert ()

V> V> Program received signal SIGSEGV, Segmentation fault. And for a long time generally program? The experience what?

3

Re: FFMPEG: swr_convert ()

V>> V>> Program received signal SIGSEGV, Segmentation fault. If I that do not know -

4

Re: FFMPEG: swr_convert ()

And what here to explain, you would not try at all  what to understand where falls, well and then from what you want to understand at once that at you not so in the code normally so beginners arrive the pro take tools for debugging and understand

5

Re: FFMPEG: swr_convert ()

R> pros take tools for debugging and Thanks that is necessary understand.

6

Re: FFMPEG: swr_convert ()

The question is solved