pkt->size = ret;
static int img_read_packet(AVFormatContext *s1, AVPacket *pkt){    VideoData *s = s1->priv_data;    char filename[1024];    int ret;    ByteIOContext f1, *f;    if (!s->is_pipe) {        /* loop over input *//*        if (loop_input && s->img_number > s->img_last) {            s->img_number = s->img_first;        }*/        if (get_frame_filename(filename, sizeof(filename),                               s->path, s->img_number)<0 && s->img_number > 1)            return AVERROR_IO;        f = &f1;        if (url_fopen(f, filename, URL_RDONLY) < 0)            return AVERROR_IO;    } else {        f = &s1->pb;        if (url_feof(f))            return AVERROR_IO;    }    if (s->is_pipe) {        av_new_packet(pkt, 4096);    }else{        av_new_packet(pkt, url_filesize(url_fileno(f)));    }    pkt->stream_index = 0;    pkt->flags |= PKT_FLAG_KEY;    ret = get_buffer(f, pkt->data, pkt->size);    if (!s->is_pipe) {        url_fclose(f);    }    if (ret <= 0) {        av_free_packet(pkt);        return AVERROR_IO; /* signal EOF */    } else {        s->img_count++;        s->img_number++;        return 0;    }}