Exemplo n.º 1
0
/**
 * 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;
}
Exemplo n.º 2
0
/**
 * ffmpeg_put_image
 *      Puts the image pointed to by ffmpeg->picture.
 *
 * Returns
 *      value returned by ffmpeg_put_frame call.
 */
int ffmpeg_put_image(struct ffmpeg *ffmpeg)
{
    /* 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
     */
    int retcd;
    int cnt = 0;

    retcd = ffmpeg_put_frame(ffmpeg, ffmpeg->picture);
    while ((retcd == -2) && (ffmpeg->tlapse != TIMELAPSE_NONE)) {
        retcd = ffmpeg_put_frame(ffmpeg, 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");
    }

    return retcd;
}
Exemplo n.º 3
0
/* 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);
    }
}
Exemplo n.º 4
0
/**
 * 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;
}
Exemplo n.º 5
0
/* Puts the image pointed to by ffmpeg->picture. */
void ffmpeg_put_image(struct ffmpeg *ffmpeg) 
{
    ffmpeg_put_frame(ffmpeg, ffmpeg->picture);
}
Exemplo n.º 6
0
/**
 * ffmpeg_put_image
 *      Puts the image pointed to by ffmpeg->picture.
 *
 * Returns
 *      value returned by ffmpeg_put_frame call.
 */
int ffmpeg_put_image(struct ffmpeg *ffmpeg)
{
    return ffmpeg_put_frame(ffmpeg, ffmpeg->picture);
}