AVStream *st = s->streams[stream_index];
AVStream *st = s->streams[pkt->stream_index];
static int img_write_packet(AVFormatContext *s, int stream_index,                            const uint8_t *buf, int size, int64_t pts){    VideoData *img = s->priv_data;    AVStream *st = s->streams[stream_index];    ByteIOContext pb1, *pb;    AVPicture *picture;    int width, height, ret;    char filename[1024];    AVImageInfo info;    width = st->codec.width;    height = st->codec.height;        picture = (AVPicture *)buf;    if (!img->is_pipe) {        if (get_frame_filename(filename, sizeof(filename),                                img->path, img->img_number) < 0)            return -EIO;        pb = &pb1;        if (url_fopen(pb, filename, URL_WRONLY) < 0)            return -EIO;    } else {        pb = &s->pb;    }    info.width = width;    info.height = height;    info.pix_fmt = st->codec.pix_fmt;    info.interleaved = 0;    /* FIXME: there should be a way to set it right */    info.pict = *picture;    ret = av_write_image(pb, img->img_fmt, &info);    if (!img->is_pipe) {        url_fclose(pb);    }    img->img_number++;    return 0;}