[Libav-user] encoding_decoding

Georg georgsteinbacher at gmx.net
Mon Aug 17 11:51:10 CEST 2015


Hello, 

I am working with the libav-examples at the moment. 
My plan is to encode an audio file to AAC directly decode it and playing it
with libao
So i edited the "Audio encoding example" from the libav/examples

But while decoding I get the error: get_buffer() failed

Here is what I added to the example:

/* encode the samples */
    
        pkt.data = NULL; // packet data will be allocated by the encoder
        pkt.size = 0;
        ret = avcodec_encode_audio2(c, &pkt, frame, &got_output);

        if (ret < 0) 
        {
            fprintf(stderr, "error encoding audio frame\n");
            exit(1);
        }
        if (got_output) 
        {    
            //decode
            int len = 0;
           
            avpkt.data = pkt.data;
	avpkt.size = pkt.size;
			
			
			
			if (!decoded_frame) 
			{
				if (!(decoded_frame = av_frame_alloc())) 
				{
					fprintf(stderr, "out of memory\n");
					exit(1);
				}
			}

            len = avcodec_decode_audio4(c2, decoded_frame, &got_frame,
&avpkt);
            
			if (len < 0) 
			{
				fprintf(stderr, "Error while decoding\n");
				exit(1);
			}
			
			if (got_frame) 
			{
				printf("win");
				//output with ao
			}
            
            
            
            av_free_packet(&pkt);
           
        }



--
View this message in context: http://libav-users.943685.n4.nabble.com/encoding-decoding-tp4661414.html
Sent from the libav-users mailing list archive at Nabble.com.


More information about the Libav-user mailing list