[FFmpeg-trac] #2609(avformat:new): av_seek_frame crashes on .nut file

FFmpeg trac at avcodec.org
Thu May 30 08:51:51 CEST 2013


#2609: av_seek_frame crashes on .nut file
----------------------------------+---------------------------------------
             Reporter:  hxuanyu   |                     Type:  defect
               Status:  new       |                 Priority:  normal
            Component:  avformat  |                  Version:  unspecified
             Keywords:            |               Blocked By:
             Blocking:            |  Reproduced by developer:  0
Analyzed by developer:  0         |
----------------------------------+---------------------------------------
 I'm building application with ffmpeg 1.1.3
 http://ffmpeg.org/releases/ffmpeg-1.1.3.tar.gz. While opening a .nut file,
 av_seek_frame always crashes. I also wrote a simple test app, it also
 crashes every time.

 The file I used is here
 https://dl.dropboxusercontent.com/u/89678527/Akon.nut. And below is the
 test code:

 static int open_codec_context(int *stream_idx,
                               AVFormatContext *fmt_ctx, enum AVMediaType
 type)
 {
     int ret;
     AVStream *st;
     AVCodecContext *dec_ctx = NULL;
     AVCodec *dec = NULL;

     ret = av_find_best_stream(fmt_ctx, type, -1, -1, NULL, 0);
     if (ret < 0) {
         //fprintf(stderr, "Could not find %s stream in input file '%s'\n",
         //        av_get_media_type_string(type), src_filename);
         return ret;
     } else {
         *stream_idx = ret;
         st = fmt_ctx->streams[*stream_idx];

         /* find decoder for the stream */
         dec_ctx = st->codec;
         dec = avcodec_find_decoder(dec_ctx->codec_id);
         if (!dec) {
             fprintf(stderr, "Failed to find %s codec\n",
                     av_get_media_type_string(type));
             return ret;
         }

         if ((ret = avcodec_open2(dec_ctx, dec, NULL)) < 0) {
             fprintf(stderr, "Failed to open %s codec\n",
                     av_get_media_type_string(type));
             return ret;
         }
     }

     return 0;
 }

 int main(int argc, char **argv)
 {
     int ret;

     if (argc == 1) {
         printf("no argument provided, exit ************** \n");
         return 0;
     }
     const char *src_filename = argv[1];

     printf("to play %s\n", src_filename);

     avcodec_register_all();
     av_register_all();

     AVFormatContext *pFormatCtx = NULL;
     if (avformat_open_input(&pFormatCtx, src_filename, NULL, NULL) < 0) {
         fprintf(stderr, "Could not open source file %s\n", src_filename);
         exit(1);
     }

     if (avformat_find_stream_info(pFormatCtx, NULL) < 0) {
         fprintf(stderr, "Could not find stream information\n");
         exit(1);
     }

     int video_stream_idx = -1, audio_stream_idx = -1;
     AVStream *video_stream;
     AVCodecContext *pCodecCtx = NULL;
     if (open_codec_context(&video_stream_idx, pFormatCtx,
 AVMEDIA_TYPE_VIDEO) >= 0) {
         video_stream = pFormatCtx->streams[video_stream_idx];
         pCodecCtx = video_stream->codec;
         printf("video stream index = %d", video_stream_idx);
     }

     AVCodec* pCodec = avcodec_find_decoder(pCodecCtx->codec_id);
     avcodec_open(pCodecCtx, pCodec);


     AVFrame *frame = avcodec_alloc_frame();
     AVPacket pkt;

     av_init_packet(&pkt);
     pkt.data = NULL;
     pkt.size = 0;

     int count = 0;
     while (av_read_frame(pFormatCtx, &pkt) >= 0) {
         printf("frame %d\n", count++);
         if (count == 100) av_seek_frame(pFormatCtx, video_stream_idx, 0,
 0); // always crashes here.
     }
 }

 I tried to print out some trace, it's pretty much that crash happens in
 read_seek of nutdec.c

-- 
Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/2609>
FFmpeg <http://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list