goto fail;
return AVERROR_IO;
static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap){    VideoData *s = s1->priv_data;    int first_index, last_index;    AVStream *st;    s1->ctx_flags |= AVFMTCTX_NOHEADER;    st = av_new_stream(s1, 0);    if (!st) {        av_free(s);        return -ENOMEM;    }    strcpy(s->path, s1->filename);    s->img_number = 0;    s->img_count = 0;        /* find format */    if (s1->iformat->flags & AVFMT_NOFILE)        s->is_pipe = 0;    else{        s->is_pipe = 1;        st->need_parsing= 1;    }            if (!ap || !ap->frame_rate) {        st->codec.frame_rate      = 25;        st->codec.frame_rate_base = 1;    } else {        st->codec.frame_rate      = ap->frame_rate;        st->codec.frame_rate_base = ap->frame_rate_base;    }        if (!s->is_pipe) {        if (find_image_range(&first_index, &last_index, s->path) < 0)            goto fail;        s->img_first = first_index;        s->img_last = last_index;        s->img_number = first_index;        /* compute duration */        st->start_time = 0;        st->duration = ((int64_t)AV_TIME_BASE *                         (last_index - first_index + 1) *                         st->codec.frame_rate_base) / st->codec.frame_rate;    }        if(ap->video_codec_id){        st->codec.codec_type = CODEC_TYPE_VIDEO;        st->codec.codec_id = ap->video_codec_id;    }else if(ap->audio_codec_id){        st->codec.codec_type = CODEC_TYPE_AUDIO;        st->codec.codec_id = ap->audio_codec_id;    }else{        st->codec.codec_type = CODEC_TYPE_VIDEO;        st->codec.codec_id = av_str2id(img_tags, s->path);    }    return 0;  fail:    av_free(s);    return AVERROR_IO;}