/** * ffmpeg_put_other_image * Puts an arbitrary picture defined by y, u and v. * * Returns * Number of bytes written by ffmpeg_put_frame * -1 if any error happens in ffmpeg_put_frame * 0 if error allocating picture. */ int ffmpeg_put_other_image(struct ffmpeg *ffmpeg, unsigned char *y, unsigned char *u, unsigned char *v) { AVFrame *picture; int retcd = 0; int cnt = 0; /* Allocate the encoded raw picture. */ picture = ffmpeg_prepare_frame(ffmpeg, y, u, v); if (picture) { /* A return code of -2 is thrown by the put_frame * when a image is buffered. For timelapse, we absolutely * never want a frame buffered so we keep sending back the * the same pic until it flushes or fails in a different way */ retcd = ffmpeg_put_frame(ffmpeg, picture); while ((retcd == -2) && (ffmpeg->tlapse != TIMELAPSE_NONE)) { retcd = ffmpeg_put_frame(ffmpeg, picture); cnt++; if (cnt > 50){ MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: Excessive attempts to clear buffered packet"); retcd = -1; } } //non timelapse buffered is ok if (retcd == -2){ retcd = 0; MOTION_LOG(DBG, TYPE_ENCODER, NO_ERRNO, "%s: Buffered packet"); } av_free(picture); } return retcd; }
/* Puts an arbitrary picture defined by y, u and v. */ void ffmpeg_put_other_image(struct ffmpeg *ffmpeg, unsigned char *y, unsigned char *u, unsigned char *v) { AVFrame *picture; /* allocate the encoded raw picture */ picture = ffmpeg_prepare_frame(ffmpeg, y, u, v); if (picture) { ffmpeg_put_frame(ffmpeg, picture); av_free(picture); } }
/** * ffmpeg_put_other_image * Puts an arbitrary picture defined by y, u and v. * * Returns * Number of bytes written by ffmpeg_put_frame * -1 if any error happens in ffmpeg_put_frame * 0 if error allocating picture. */ int ffmpeg_put_other_image(struct ffmpeg *ffmpeg, unsigned char *y, unsigned char *u, unsigned char *v) { AVFrame *picture; int ret = 0; /* Allocate the encoded raw picture. */ picture = ffmpeg_prepare_frame(ffmpeg, y, u, v); if (picture) { ret = ffmpeg_put_frame(ffmpeg, picture); if (!ret) av_free(picture); } return ret; }