Sorry, the first submission. I modified the code, see Annex.
-----邮件原件----- 发件人: ffmpeg-devel-boun...@ffmpeg.org [mailto:ffmpeg-devel-boun...@ffmpeg.org] 代表 Michael Niedermayer 发送时间: 2016年5月26日 19:24 收件人: FFmpeg development discussions and patches 主题: Re: [FFmpeg-devel] Filter: Add snapshot filter. It is enable to save snapshot. 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 <kl...@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<kl...@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
0001-avfilter-vf_snapshot-Add-snapshot-filter.-It-is-enab.patch
Description: Binary data
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel