c++ - how to put a raw char * to AVPacket -
i have compressed image stored in char * , want put avpacket can put ffmpeg decoder. can show how this? sample or tutorial appreciated.
thanks in advance
i show sample code related ffmpeg encoder.
static int encode_frame(avcodeccontext *avctx, avpacket *pkt, const avframe *pict, int *got_packet) { unsigned char *buf; int ret, buflen; int64_t maxsize; // store image data buf variable. buf = .... // calculate buf length. buflen = .... // allocate avpacket. maxsize = ff_min_buffer_size + avctx->width * avctx->height * 9; if ((ret = ff_alloc_packet2(avctx, pkt, maxsize)) < 0) return ret; // copy buf avpacket. memcpy(pkt->data, buf, buflen); pkt->size = buflen; *got_packet = 1; return 0; }
Comments
Post a Comment