[FFmpeg-devel] Filter: Add snapshot filter. It is enable to save snapshot.

Michael Niedermayer michael at niedermayer.cc
Thu May 26 13:23:42 CEST 2016


On Wed, May 25, 2016 at 10:36:13PM +0800, kl222 wrote:
> Filter: Add snapshot filter. 
> It can save a snapshot picture. Supports .png, .jpg, .bmp formats
> Snapshot with process_command api.
> 
> 

>  doc/filters.texi          |   23 ++++
>  libavfilter/Makefile      |    1 
>  libavfilter/allfilters.c  |    1 
>  libavfilter/vf_snapshot.c |  234 ++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 259 insertions(+)
> 0982d4ea5c463a71f36cb6b984ef00e418ba1380  0003-Filter-Add-snapshot-filter.-It-is-enable-to-save-sna.patch
> From a467346bea3849222c25aed2bb342b3d5fb51aeb Mon Sep 17 00:00:00 2001
> From: KangLin <kl222 at 126.com>
> Date: Wed, 25 May 2016 16:29:45 +0800
> Subject: [PATCH 3/3] Filter: Add snapshot filter. It is enable to save
>  snapshot.


[...]
> @@ -306,6 +306,7 @@ void avfilter_register_all(void)
>      REGISTER_FILTER(ZMQ,            zmq,            vf);
>      REGISTER_FILTER(ZOOMPAN,        zoompan,        vf);
>      REGISTER_FILTER(ZSCALE,         zscale,         vf);
> +	REGISTER_FILTER(SNAPSHOT,       snapshot,       vf);

tabs are forbidden in ffmpeg git


>  
>      REGISTER_FILTER(ALLRGB,         allrgb,         vsrc);
>      REGISTER_FILTER(ALLYUV,         allyuv,         vsrc);

> diff --git a/libavfilter/vf_snapshot.c b/libavfilter/vf_snapshot.c
> new file mode 100644
> index 0000000..2c76ba5
> --- /dev/null
> +++ b/libavfilter/vf_snapshot.c
> @@ -0,0 +1,234 @@
> +/**
> + * @file
> + * Snapshot video filter, it can save a snapshot picture.
> + * Author:KangLin<kl222 at 126.com>
> + */

Missing license header


[...]
> +static int snapshot_open(AVFilterContext *ctx, AVFrame* frame){
> +    int ret = 0;
> +    SnapshotContext *s = ctx->priv;
> +    char f[1024] = { 0 };
> +    if (s->ofmt_ctx)
> +        return 0;
> +
> +    if (s->pDir){
> +        av_strlcpy(f, s->pDir, 1024);
> +        av_strlcat(f, "/", 1024);
> +    }
> +    if (s->pFileName)
> +        av_strlcat(f, s->pFileName, 1024);
> +    else{
> +        av_log(ctx, AV_LOG_ERROR, "please set filename.\n");
> +        return AVERROR(EPERM);
> +    }
> +
> +    ret = avformat_alloc_output_context2(&s->ofmt_ctx, NULL, NULL, f);
> +    if (ret < 0){
> +        av_log(ctx, AV_LOG_ERROR, "open file is fail:%d;filename:%s\n", ret, f);
> +        return ret;
> +    }
> +    if (!s->ofmt_ctx) {
> +        av_log(ctx, AV_LOG_ERROR, "open file is fail:%d\n", ret);
> +        return ret;
> +    }
> +
> +    av_init_packet(&s->outPacket);
> +
> +    do{
> +        s->pEncodec = avcodec_find_encoder(s->ofmt_ctx->oformat->video_codec);
> +        if (!s->pEncodec){
> +            av_log(ctx, AV_LOG_ERROR, "encodec isn't found.codec id:%d\n",
> +                   s->ofmt_ctx->oformat->video_codec);
> +            break;
> +        }
> +
> +        AVStream *out_stream = avformat_new_stream(s->ofmt_ctx, s->pEncodec);

libavfilter/vf_snapshot.c: In function ‘snapshot_open’:
libavfilter/vf_snapshot.c:102:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160526/dd2c7fc6/attachment.sig>


More information about the ffmpeg-devel mailing list