c++ - Problems converting .flv to mp3 using FFmpeg SDK -


i'm using ffmpeg sdk programmatically convert videos mp3.

i read audio frames of video way:

while(av_read_frame(pfromctx, &pkt) >= 0)  {     if(pkt.stream_index == audiostreamindex)      {                 avcodec_get_frame_defaults(frame);         got_frame = 0;                       ret = avcodec_decode_audio4(pcodecctx, frame, &got_frame, &pkt);                         if (ret < 0) {             av_log(null, av_log_error, "error decoding audio frame.\n");                         continue;         }          if(got_frame)          {                               // write decoded audio frame                      write_audio_frame(ptoctx, ptoctx->streams[ptoctx->nb_streams-1], frame);                             }                             }     av_free_packet(&pkt);      } 

decoding audio input video file works fine. problem occurs when try encode mp3 frame:

static void write_audio_frame(avformatcontext *oc, avstream *st, avframe *frame) {   avcodeccontext *enc = st->codec;   avpacket pkt;   int got_packet = 0;    int ret = 0;    av_init_packet(&pkt);   pkt.data = null;    pkt.size = 0;     ret = avcodec_encode_audio2(enc, &pkt, frame, &got_packet);    if (ret < 0) {       // problem           fprintf(stderr, "error encoding audio frame. \n");       exit(1);   }      } 

i following console output:

[libmp3lame] inadequate avframe plane padding 

the happens .flv files, code works fine .mp4 files. clue error message means?

thanks

the source code containing error message here: http://ffmpeg.org/doxygen/trunk/libmp3lame_8c-source.html. relevant source says:

if (frame->linesize[0] < 4 * ffalign(frame->nb_samples, 8)) {     av_log(avctx, av_log_error, "inadequate avframe plane padding\n");     return averror(einval); } 

ffalign defined

#define ffalign (x,a)(((x)+(a)-1)&~((a)-1)) 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -