Message ID | 20190710014451.16132-1-ullysses.a.eoff@intel.com |
---|---|
State | New |
Headers | show |
On 7/10/19, U. Artie Eoff <ullysses.a.eoff@intel.com> wrote: > This filter enables raw frames to be dumped to a > file before they are sent through the auto-inserted > scaler filter and useful when you want unscaled > raw frames in an output file. > Why? -f rawvideo doesn't work for you?
> -----Original Message----- > From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf > Of Paul B Mahol > Sent: Wednesday, July 10, 2019 15:55 > To: FFmpeg development discussions and patches <ffmpeg- > devel@ffmpeg.org> > Cc: Eoff, Ullysses A <ullysses.a.eoff@intel.com> > Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter > > On 7/10/19, U. Artie Eoff <ullysses.a.eoff@intel.com> wrote: > > This filter enables raw frames to be dumped to a > > file before they are sent through the auto-inserted > > scaler filter and useful when you want unscaled > > raw frames in an output file. > > > > Why? > > -f rawvideo doesn't work for you? unscaled raw video could be dumped through this filter in resolution changing cases. IMHO, it will be great if there are some options available to disable/enable the auto scaling filter in pipeline, thus the whole stream doesn't need to be scaled into the same size of the first frame. The difference in scale algorithms will make it hard to compare the output with other decoder. - linjie
On 7/10/19, Fu, Linjie <linjie.fu@intel.com> wrote: >> -----Original Message----- >> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf >> Of Paul B Mahol >> Sent: Wednesday, July 10, 2019 15:55 >> To: FFmpeg development discussions and patches <ffmpeg- >> devel@ffmpeg.org> >> Cc: Eoff, Ullysses A <ullysses.a.eoff@intel.com> >> Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter >> >> On 7/10/19, U. Artie Eoff <ullysses.a.eoff@intel.com> wrote: >> > This filter enables raw frames to be dumped to a >> > file before they are sent through the auto-inserted >> > scaler filter and useful when you want unscaled >> > raw frames in an output file. >> > >> >> Why? >> >> -f rawvideo doesn't work for you? > > unscaled raw video could be dumped through this filter in resolution > changing cases. > Maybe, I still fail how this filter is useful, when user can use split filter to dump video at any point in graph. > IMHO, it will be great if there are some options available to disable/enable > the auto scaling filter > in pipeline, thus the whole stream doesn't need to be scaled into the same > size of the first frame. > The difference in scale algorithms will make it hard to compare the output > with other decoder. > > - linjie > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
On Wed, Jul 10, 2019 at 12:13 PM Fu, Linjie <linjie.fu@intel.com> wrote: > > > -----Original Message----- > > From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf > > Of Paul B Mahol > > Sent: Wednesday, July 10, 2019 15:55 > > To: FFmpeg development discussions and patches <ffmpeg- > > devel@ffmpeg.org> > > Cc: Eoff, Ullysses A <ullysses.a.eoff@intel.com> > > Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter > > > > On 7/10/19, U. Artie Eoff <ullysses.a.eoff@intel.com> wrote: > > > This filter enables raw frames to be dumped to a > > > file before they are sent through the auto-inserted > > > scaler filter and useful when you want unscaled > > > raw frames in an output file. > > > > > > > Why? > > > > -f rawvideo doesn't work for you? > > unscaled raw video could be dumped through this filter in resolution changing cases. > > IMHO, it will be great if there are some options available to disable/enable the auto scaling filter > in pipeline, thus the whole stream doesn't need to be scaled into the same size of the first frame. > The difference in scale algorithms will make it hard to compare the output with other decoder. > I believe using -reinit_filter 0 with ffmpeg can achieve such a result., as long as you make sure all filtering done (preferably none) is capable of on-the-fly changes. - Hendrik
> -----Original Message----- > From: Paul B Mahol [mailto:onemda@gmail.com] > Sent: Wednesday, July 10, 2019 3:25 AM > To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> > Cc: Eoff, Ullysses A <ullysses.a.eoff@intel.com> > Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter > > On 7/10/19, Fu, Linjie <linjie.fu@intel.com> wrote: > >> -----Original Message----- > >> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf > >> Of Paul B Mahol > >> Sent: Wednesday, July 10, 2019 15:55 > >> To: FFmpeg development discussions and patches <ffmpeg- > >> devel@ffmpeg.org> > >> Cc: Eoff, Ullysses A <ullysses.a.eoff@intel.com> > >> Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter > >> > >> On 7/10/19, U. Artie Eoff <ullysses.a.eoff@intel.com> wrote: > >> > This filter enables raw frames to be dumped to a > >> > file before they are sent through the auto-inserted > >> > scaler filter and useful when you want unscaled > >> > raw frames in an output file. > >> > > >> > >> Why? > >> > >> -f rawvideo doesn't work for you? > > > > unscaled raw video could be dumped through this filter in resolution > > changing cases. > > > > Maybe, I still fail how this filter is useful, when user can use split > filter to dump video > at any point in graph. > If there are already other ways to achieve the same result without this filter then that's great! Essentially, I'm trying to achieve exactly what Linjie stated so we can compare raw results across different decoder solutions. And the forced insertion of the auto scaler in ffmpeg makes that difficult for multi-resolution cases. Could you point me to an example of using split to achieve this? U. Artie > > > IMHO, it will be great if there are some options available to disable/enable > > the auto scaling filter > > in pipeline, thus the whole stream doesn't need to be scaled into the same > > size of the first frame. > > The difference in scale algorithms will make it hard to compare the output > > with other decoder. > > > > - linjie > > _______________________________________________ > > ffmpeg-devel mailing list > > ffmpeg-devel@ffmpeg.org > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > To unsubscribe, visit link above, or email > > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
On 7/10/19, Eoff, Ullysses A <ullysses.a.eoff@intel.com> wrote: >> -----Original Message----- >> From: Paul B Mahol [mailto:onemda@gmail.com] >> Sent: Wednesday, July 10, 2019 3:25 AM >> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> >> Cc: Eoff, Ullysses A <ullysses.a.eoff@intel.com> >> Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter >> >> On 7/10/19, Fu, Linjie <linjie.fu@intel.com> wrote: >> >> -----Original Message----- >> >> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf >> >> Of Paul B Mahol >> >> Sent: Wednesday, July 10, 2019 15:55 >> >> To: FFmpeg development discussions and patches <ffmpeg- >> >> devel@ffmpeg.org> >> >> Cc: Eoff, Ullysses A <ullysses.a.eoff@intel.com> >> >> Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter >> >> >> >> On 7/10/19, U. Artie Eoff <ullysses.a.eoff@intel.com> wrote: >> >> > This filter enables raw frames to be dumped to a >> >> > file before they are sent through the auto-inserted >> >> > scaler filter and useful when you want unscaled >> >> > raw frames in an output file. >> >> > >> >> >> >> Why? >> >> >> >> -f rawvideo doesn't work for you? >> > >> > unscaled raw video could be dumped through this filter in resolution >> > changing cases. >> > >> >> Maybe, I still fail how this filter is useful, when user can use split >> filter to dump video >> at any point in graph. >> > > If there are already other ways to achieve the same result without this > filter then that's great! Essentially, I'm trying to achieve exactly what > Linjie stated so we can compare raw results across different decoder > solutions. And the forced insertion of the auto scaler in ffmpeg makes > that difficult for multi-resolution cases. Please provide examples of filtergraph where you are supposed to use this "filter". > > Could you point me to an example of using split to achieve this? See documentation of split filter. > > U. Artie > >> >> > IMHO, it will be great if there are some options available to >> > disable/enable >> > the auto scaling filter >> > in pipeline, thus the whole stream doesn't need to be scaled into the >> > same >> > size of the first frame. >> > The difference in scale algorithms will make it hard to compare the >> > output >> > with other decoder. >> > >> > - linjie >> > _______________________________________________ >> > ffmpeg-devel mailing list >> > ffmpeg-devel@ffmpeg.org >> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> > >> > To unsubscribe, visit link above, or email >> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". >
> -----Original Message----- > From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf Of Hendrik Leppkes > Sent: Wednesday, July 10, 2019 4:13 AM > To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter > > On Wed, Jul 10, 2019 at 12:13 PM Fu, Linjie <linjie.fu@intel.com> wrote: > > > > > -----Original Message----- > > > From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf > > > Of Paul B Mahol > > > Sent: Wednesday, July 10, 2019 15:55 > > > To: FFmpeg development discussions and patches <ffmpeg- > > > devel@ffmpeg.org> > > > Cc: Eoff, Ullysses A <ullysses.a.eoff@intel.com> > > > Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter > > > > > > On 7/10/19, U. Artie Eoff <ullysses.a.eoff@intel.com> wrote: > > > > This filter enables raw frames to be dumped to a > > > > file before they are sent through the auto-inserted > > > > scaler filter and useful when you want unscaled > > > > raw frames in an output file. > > > > > > > > > > Why? > > > > > > -f rawvideo doesn't work for you? > > > > unscaled raw video could be dumped through this filter in resolution changing cases. > > > > IMHO, it will be great if there are some options available to disable/enable the auto scaling filter > > in pipeline, thus the whole stream doesn't need to be scaled into the same size of the first frame. > > The difference in scale algorithms will make it hard to compare the output with other decoder. > > > > I believe using -reinit_filter 0 with ffmpeg can achieve such a > result., as long as you make sure all filtering done (preferably none) > is capable of on-the-fly changes. > Excellent! I wouldn't have thought to try -reinit_filter 0 for such a scenario. I just tried it and it achieves the exact result we're looking for. But it's unfortunate that it generates a warning message for every frame processed. Is there a simple way to silence that message, yet still get other verbose logging (I don't want to flood our automation logs)? U. Artie > - Hendrik > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> -----Original Message----- > From: Paul B Mahol [mailto:onemda@gmail.com] > Sent: Wednesday, July 10, 2019 7:20 AM > To: Eoff, Ullysses A <ullysses.a.eoff@intel.com> > Cc: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter > > On 7/10/19, Eoff, Ullysses A <ullysses.a.eoff@intel.com> wrote: > >> -----Original Message----- > >> From: Paul B Mahol [mailto:onemda@gmail.com] > >> Sent: Wednesday, July 10, 2019 3:25 AM > >> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> > >> Cc: Eoff, Ullysses A <ullysses.a.eoff@intel.com> > >> Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter > >> > >> On 7/10/19, Fu, Linjie <linjie.fu@intel.com> wrote: > >> >> -----Original Message----- > >> >> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf > >> >> Of Paul B Mahol > >> >> Sent: Wednesday, July 10, 2019 15:55 > >> >> To: FFmpeg development discussions and patches <ffmpeg- > >> >> devel@ffmpeg.org> > >> >> Cc: Eoff, Ullysses A <ullysses.a.eoff@intel.com> > >> >> Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter > >> >> > >> >> On 7/10/19, U. Artie Eoff <ullysses.a.eoff@intel.com> wrote: > >> >> > This filter enables raw frames to be dumped to a > >> >> > file before they are sent through the auto-inserted > >> >> > scaler filter and useful when you want unscaled > >> >> > raw frames in an output file. > >> >> > > >> >> > >> >> Why? > >> >> > >> >> -f rawvideo doesn't work for you? > >> > > >> > unscaled raw video could be dumped through this filter in resolution > >> > changing cases. > >> > > >> > >> Maybe, I still fail how this filter is useful, when user can use split > >> filter to dump video > >> at any point in graph. > >> > > > > If there are already other ways to achieve the same result without this > > filter then that's great! Essentially, I'm trying to achieve exactly what > > Linjie stated so we can compare raw results across different decoder > > solutions. And the forced insertion of the auto scaler in ffmpeg makes > > that difficult for multi-resolution cases. > > Please provide examples of filtergraph where you are supposed to use > this "filter". > ffmpeg -v verbose -hwaccel vaapi -vaapi_device /dev/dri/renderD128 \ -i input.h264 -vf 'format=nv12,rawdump=file=./ffdump.yuv' -f null - > > > > Could you point me to an example of using split to achieve this? > > See documentation of split filter. Thanks. I will take a look and experiment with it. > > > > > U. Artie > > > >> > >> > IMHO, it will be great if there are some options available to > >> > disable/enable > >> > the auto scaling filter > >> > in pipeline, thus the whole stream doesn't need to be scaled into the > >> > same > >> > size of the first frame. > >> > The difference in scale algorithms will make it hard to compare the > >> > output > >> > with other decoder. > >> > > >> > - linjie > >> > _______________________________________________ > >> > ffmpeg-devel mailing list > >> > ffmpeg-devel@ffmpeg.org > >> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > >> > > >> > To unsubscribe, visit link above, or email > >> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > >
On 7/10/19, Eoff, Ullysses A <ullysses.a.eoff@intel.com> wrote: >> -----Original Message----- >> From: Paul B Mahol [mailto:onemda@gmail.com] >> Sent: Wednesday, July 10, 2019 7:20 AM >> To: Eoff, Ullysses A <ullysses.a.eoff@intel.com> >> Cc: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> >> Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter >> >> On 7/10/19, Eoff, Ullysses A <ullysses.a.eoff@intel.com> wrote: >> >> -----Original Message----- >> >> From: Paul B Mahol [mailto:onemda@gmail.com] >> >> Sent: Wednesday, July 10, 2019 3:25 AM >> >> To: FFmpeg development discussions and patches >> >> <ffmpeg-devel@ffmpeg.org> >> >> Cc: Eoff, Ullysses A <ullysses.a.eoff@intel.com> >> >> Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter >> >> >> >> On 7/10/19, Fu, Linjie <linjie.fu@intel.com> wrote: >> >> >> -----Original Message----- >> >> >> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On >> >> >> Behalf >> >> >> Of Paul B Mahol >> >> >> Sent: Wednesday, July 10, 2019 15:55 >> >> >> To: FFmpeg development discussions and patches <ffmpeg- >> >> >> devel@ffmpeg.org> >> >> >> Cc: Eoff, Ullysses A <ullysses.a.eoff@intel.com> >> >> >> Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter >> >> >> >> >> >> On 7/10/19, U. Artie Eoff <ullysses.a.eoff@intel.com> wrote: >> >> >> > This filter enables raw frames to be dumped to a >> >> >> > file before they are sent through the auto-inserted >> >> >> > scaler filter and useful when you want unscaled >> >> >> > raw frames in an output file. >> >> >> > >> >> >> >> >> >> Why? >> >> >> >> >> >> -f rawvideo doesn't work for you? >> >> > >> >> > unscaled raw video could be dumped through this filter in resolution >> >> > changing cases. >> >> > >> >> >> >> Maybe, I still fail how this filter is useful, when user can use split >> >> filter to dump video >> >> at any point in graph. >> >> >> > >> > If there are already other ways to achieve the same result without this >> > filter then that's great! Essentially, I'm trying to achieve exactly >> > what >> > Linjie stated so we can compare raw results across different decoder >> > solutions. And the forced insertion of the auto scaler in ffmpeg makes >> > that difficult for multi-resolution cases. >> >> Please provide examples of filtergraph where you are supposed to use >> this "filter". >> > > ffmpeg -v verbose -hwaccel vaapi -vaapi_device /dev/dri/renderD128 \ > -i input.h264 -vf 'format=nv12,rawdump=file=./ffdump.yuv' -f null - > >> > >> > Could you point me to an example of using split to achieve this? >> >> See documentation of split filter. > > Thanks. I will take a look and experiment with it. The resolution changing support is big hack, and should not be relied upon. Use some other tool. Like gstreamer. > >> >> > >> > U. Artie >> > >> >> >> >> > IMHO, it will be great if there are some options available to >> >> > disable/enable >> >> > the auto scaling filter >> >> > in pipeline, thus the whole stream doesn't need to be scaled into >> >> > the >> >> > same >> >> > size of the first frame. >> >> > The difference in scale algorithms will make it hard to compare the >> >> > output >> >> > with other decoder. >> >> > >> >> > - linjie >> >> > _______________________________________________ >> >> > ffmpeg-devel mailing list >> >> > ffmpeg-devel@ffmpeg.org >> >> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> >> > >> >> > To unsubscribe, visit link above, or email >> >> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". >> > >
On 10-07-2019 07:51 PM, Eoff, Ullysses A wrote: >> -----Original Message----- >> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf Of Hendrik Leppkes >> Sent: Wednesday, July 10, 2019 4:13 AM >> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> >> Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter >> >> ... >> I believe using -reinit_filter 0 with ffmpeg can achieve such a >> result., as long as you make sure all filtering done (preferably none) >> is capable of on-the-fly changes. >> > Excellent! I wouldn't have thought to try -reinit_filter 0 for such a scenario. I > just tried it and it achieves the exact result we're looking for. But it's unfortunate > that it generates a warning message for every frame processed. Is there a simple > way to silence that message, yet still get other verbose logging (I don't want to > flood our automation logs)? No. You'll have to upgrade the level in libavfilter/buffersrc.c Gyan
U. Artie Eoff (12019-07-09):
> + FILE *rawdump_file;
Independently from the question of whether this filter is useful or not,
I think the dump should have used AVIO.
Regards,
> From: Eoff, Ullysses A > +static av_cold int rawdump_init(AVFilterContext *avctx) > +{ > + RawDumpContext *ctx = avctx->priv; > + static char *mode = "w"; For the record, this "static" is a problem if multiple rawdump filters are specified in the graph. The initial reason for this was to open the file for writing on the first init (to overwrite any pre-existing file), then open for appending on successive reinit's (e.g. frame resolution changes). Thus, would need a better solution to achieve the same result without influencing other instances of the filter. > + > + ctx->rawdump_file = fopen(ctx->rawdump_file_str, mode); > + > + if (ctx->rawdump_file == NULL) { > + int err = AVERROR(errno); > + char buf[128]; > + av_strerror(err, buf, sizeof(buf)); > + av_log(ctx, AV_LOG_ERROR, "Failed to open %s for dumping: %s\n", > + ctx->rawdump_file_str, buf); > + return err; > + } > + > + av_log(ctx, AV_LOG_DEBUG, "Opened %s (mode:%s) for dumping.\n", > + ctx->rawdump_file_str, mode); > + > + mode = "a"; > + > + return 0; > +} > + > +static av_cold void rawdump_uninit(AVFilterContext *avctx) > +{ > + RawDumpContext *ctx = avctx->priv; > + > + if (ctx->rawdump_file != NULL) > + fclose(ctx->rawdump_file); > +} > + > +#define OFFSET(x) offsetof(RawDumpContext, x) > +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM > +static const AVOption rawdump_options[] = { > + {"file", "Set file where to dump raw frames", OFFSET(rawdump_file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, > + { NULL } > +}; > + > +AVFILTER_DEFINE_CLASS(rawdump); > + > +static const AVFilterPad rawdump_inputs[] = { > + { > + .name = "default", > + .type = AVMEDIA_TYPE_VIDEO, > + .filter_frame = rawdump_filter_frame, > + }, > + { NULL } > +}; > + > +static const AVFilterPad rawdump_outputs[] = { > + { > + .name = "default", > + .type = AVMEDIA_TYPE_VIDEO, > + }, > + { NULL } > +}; > + > +AVFilter ff_vf_rawdump = { > + .name = "rawdump", > + .description = NULL_IF_CONFIG_SMALL("Dump frames to file"), > + .init = rawdump_init, > + .uninit = rawdump_uninit, > + .query_formats = rawdump_query_formats, > + .priv_size = sizeof(RawDumpContext), > + .priv_class = &rawdump_class, > + .inputs = rawdump_inputs, > + .outputs = rawdump_outputs, > +}; > -- > 2.20.1
Jul 10, 2019, 3:26 PM by ullysses.a.eoff@intel.com: >> -----Original Message----- >> From: Paul B Mahol [mailto:onemda@gmail.com] >> Sent: Wednesday, July 10, 2019 7:20 AM >> To: Eoff, Ullysses A <ullysses.a.eoff@intel.com> >> Cc: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> >> Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter >> >> On 7/10/19, Eoff, Ullysses A <ullysses.a.eoff@intel.com> wrote: >> >> -----Original Message----- >> >> From: Paul B Mahol [mailto:onemda@gmail.com] >> >> Sent: Wednesday, July 10, 2019 3:25 AM >> >> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> >> >> Cc: Eoff, Ullysses A <ullysses.a.eoff@intel.com> >> >> Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter >> >> >> >> On 7/10/19, Fu, Linjie <linjie.fu@intel.com> wrote: >> >> >> -----Original Message----- >> >> >> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf >> >> >> Of Paul B Mahol >> >> >> Sent: Wednesday, July 10, 2019 15:55 >> >> >> To: FFmpeg development discussions and patches <ffmpeg- >> >> >> devel@ffmpeg.org> >> >> >> Cc: Eoff, Ullysses A <ullysses.a.eoff@intel.com> >> >> >> Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter >> >> >> >> >> >> On 7/10/19, U. Artie Eoff <ullysses.a.eoff@intel.com> wrote: >> >> >> > This filter enables raw frames to be dumped to a >> >> >> > file before they are sent through the auto-inserted >> >> >> > scaler filter and useful when you want unscaled >> >> >> > raw frames in an output file. >> >> >> > >> >> >> >> >> >> Why? >> >> >> >> >> >> -f rawvideo doesn't work for you? >> >> > >> >> > unscaled raw video could be dumped through this filter in resolution >> >> > changing cases. >> >> > >> >> >> >> Maybe, I still fail how this filter is useful, when user can use split >> >> filter to dump video >> >> at any point in graph. >> >> >> > >> > If there are already other ways to achieve the same result without this >> > filter then that's great! Essentially, I'm trying to achieve exactly what >> > Linjie stated so we can compare raw results across different decoder >> > solutions. And the forced insertion of the auto scaler in ffmpeg makes >> > that difficult for multi-resolution cases. >> >> Please provide examples of filtergraph where you are supposed to use >> this "filter". >> > > ffmpeg -v verbose -hwaccel vaapi -vaapi_device /dev/dri/renderD128 \ > -i input.h264 -vf 'format=nv12,rawdump=file=./ffdump.yuv' -f null - > You can make the decoder output nv12 directly via -hwaccel_output_format nv12
Eoff, Ullysses A (12019-07-10): > For the record, this "static" is a problem if multiple rawdump filters are > specified in the graph. The initial reason for this was to open the file for > writing on the first init (to overwrite any pre-existing file), then open for > appending on successive reinit's (e.g. frame resolution changes). Thus, > would need a better solution to achieve the same result without > influencing other instances of the filter. The variable needs to be in the filter's private context, nothing more. Regards,
> -----Original Message----- > From: Nicolas George [mailto:george@nsup.org] > Sent: Wednesday, July 10, 2019 7:37 AM > To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> > Cc: Eoff, Ullysses A <ullysses.a.eoff@intel.com> > Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter > > U. Artie Eoff (12019-07-09): > > + FILE *rawdump_file; > > Independently from the question of whether this filter is useful or not, > I think the dump should have used AVIO. > Thanks for the tip! Even though this patch is redundant and unnecessary (based on feedback)... I will have a look at AVIO for future changes/patches. Cheers, U. Artie > Regards, > > -- > Nicolas George
> -----Original Message----- > From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf Of Lynne > Sent: Wednesday, July 10, 2019 7:52 AM > To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter > > > > > Jul 10, 2019, 3:26 PM by ullysses.a.eoff@intel.com: > > >> -----Original Message----- > >> From: Paul B Mahol [mailto:onemda@gmail.com] > >> Sent: Wednesday, July 10, 2019 7:20 AM > >> To: Eoff, Ullysses A <ullysses.a.eoff@intel.com> > >> Cc: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> > >> Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter > >> > >> On 7/10/19, Eoff, Ullysses A <ullysses.a.eoff@intel.com> wrote: > >> >> -----Original Message----- > >> >> From: Paul B Mahol [mailto:onemda@gmail.com] > >> >> Sent: Wednesday, July 10, 2019 3:25 AM > >> >> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> > >> >> Cc: Eoff, Ullysses A <ullysses.a.eoff@intel.com> > >> >> Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter > >> >> > >> >> On 7/10/19, Fu, Linjie <linjie.fu@intel.com> wrote: > >> >> >> -----Original Message----- > >> >> >> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf > >> >> >> Of Paul B Mahol > >> >> >> Sent: Wednesday, July 10, 2019 15:55 > >> >> >> To: FFmpeg development discussions and patches <ffmpeg- > >> >> >> devel@ffmpeg.org> > >> >> >> Cc: Eoff, Ullysses A <ullysses.a.eoff@intel.com> > >> >> >> Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter > >> >> >> > >> >> >> On 7/10/19, U. Artie Eoff <ullysses.a.eoff@intel.com> wrote: > >> >> >> > This filter enables raw frames to be dumped to a > >> >> >> > file before they are sent through the auto-inserted > >> >> >> > scaler filter and useful when you want unscaled > >> >> >> > raw frames in an output file. > >> >> >> > > >> >> >> > >> >> >> Why? > >> >> >> > >> >> >> -f rawvideo doesn't work for you? > >> >> > > >> >> > unscaled raw video could be dumped through this filter in resolution > >> >> > changing cases. > >> >> > > >> >> > >> >> Maybe, I still fail how this filter is useful, when user can use split > >> >> filter to dump video > >> >> at any point in graph. > >> >> > >> > > >> > If there are already other ways to achieve the same result without this > >> > filter then that's great! Essentially, I'm trying to achieve exactly what > >> > Linjie stated so we can compare raw results across different decoder > >> > solutions. And the forced insertion of the auto scaler in ffmpeg makes > >> > that difficult for multi-resolution cases. > >> > >> Please provide examples of filtergraph where you are supposed to use > >> this "filter". > >> > > > > ffmpeg -v verbose -hwaccel vaapi -vaapi_device /dev/dri/renderD128 \ > > -i input.h264 -vf 'format=nv12,rawdump=file=./ffdump.yuv' -f null - > > > > You can make the decoder output nv12 directly via -hwaccel_output_format nv12 Agree. There are many ways to specify format. But there are some formats which one might want to dump that some hw drivers can't output directly without conversion. > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Eoff, Ullysses A (12019-07-10): > Agree. There are many ways to specify format. But there are some formats > which one might want to dump that some hw drivers can't output directly > without conversion. In that case, your goal to avoid conversion is moot. Regards,
> -----Original Message----- > From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf Of Nicolas George > Sent: Wednesday, July 10, 2019 8:05 AM > To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter > > Eoff, Ullysses A (12019-07-10): > > Agree. There are many ways to specify format. But there are some formats > > which one might want to dump that some hw drivers can't output directly > > without conversion. > > In that case, your goal to avoid conversion is moot. > The goal is to avoid scaling ;-) > Regards, > > -- > Nicolas George
> -----Original Message----- > From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf Of Nicolas George > Sent: Wednesday, July 10, 2019 7:53 AM > To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter > > Eoff, Ullysses A (12019-07-10): > > For the record, this "static" is a problem if multiple rawdump filters are > > specified in the graph. The initial reason for this was to open the file for > > writing on the first init (to overwrite any pre-existing file), then open for > > appending on successive reinit's (e.g. frame resolution changes). Thus, > > would need a better solution to achieve the same result without > > influencing other instances of the filter. > > The variable needs to be in the filter's private context, nothing more. > Each time init is called (i.e. for reinit on resolution change), the private context is a new instance. On first init we want mode="w" for each rawdump filter in the graph, but on reinit we want mode="a". How do we achieve this when every call to init passes a new private context instance. I am not very familiar with ffmpeg's programming API's, so maybe I'm missing something? > Regards, > > -- > Nicolas George
> -----Original Message----- > From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf Of Gyan > Sent: Wednesday, July 10, 2019 7:33 AM > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter > > > > On 10-07-2019 07:51 PM, Eoff, Ullysses A wrote: > >> -----Original Message----- > >> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf Of Hendrik Leppkes > >> Sent: Wednesday, July 10, 2019 4:13 AM > >> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> > >> Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter > >> > >> ... > >> I believe using -reinit_filter 0 with ffmpeg can achieve such a > >> result., as long as you make sure all filtering done (preferably none) > >> is capable of on-the-fly changes. > >> > > Excellent! I wouldn't have thought to try -reinit_filter 0 for such a scenario. I > > just tried it and it achieves the exact result we're looking for. But it's unfortunate > > that it generates a warning message for every frame processed. Is there a simple > > way to silence that message, yet still get other verbose logging (I don't want to > > flood our automation logs)? > > No. You'll have to upgrade the level in libavfilter/buffersrc.c > I see. Would anyone object if I sent a patch to upgrade the level to AV_LOG_DEBUG? > Gyan > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
On 10-07-2019 10:15 PM, Eoff, Ullysses A wrote: >> -----Original Message----- >> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf Of Gyan >> Sent: Wednesday, July 10, 2019 7:33 AM >> To: ffmpeg-devel@ffmpeg.org >> Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter >> >> >> >> On 10-07-2019 07:51 PM, Eoff, Ullysses A wrote: >>>> -----Original Message----- >>>> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf Of Hendrik Leppkes >>>> Sent: Wednesday, July 10, 2019 4:13 AM >>>> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> >>>> Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter >>>> >>>> ... >>>> I believe using -reinit_filter 0 with ffmpeg can achieve such a >>>> result., as long as you make sure all filtering done (preferably none) >>>> is capable of on-the-fly changes. >>>> >>> Excellent! I wouldn't have thought to try -reinit_filter 0 for such a scenario. I >>> just tried it and it achieves the exact result we're looking for. But it's unfortunate >>> that it generates a warning message for every frame processed. Is there a simple >>> way to silence that message, yet still get other verbose logging (I don't want to >>> flood our automation logs)? >> No. You'll have to upgrade the level in libavfilter/buffersrc.c >> > I see. Would anyone object if I sent a patch to upgrade the level to AV_LOG_DEBUG? Yes, I would. A video stream with changing frame properties is atypical, so the user should be warned about it. Your specific use case specifically seems to involve regularly, and perhaps purposely, varying prop changes, so I understand you find these messages to be bloat. An acceptable middle ground would be to add three additional state variables (called, say, last_w, last_h, last_pix_fmt) which prints the warning only when the props change relative to the last time it changed. Gyan
> -----Original Message----- > From: Eoff, Ullysses A > Sent: Tuesday, July 09, 2019 6:45 PM > To: ffmpeg-devel@ffmpeg.org > Cc: Eoff, Ullysses A <ullysses.a.eoff@intel.com> > Subject: [PATCH] avfilter: add rawdump filter > > This filter enables raw frames to be dumped to a > file before they are sent through the auto-inserted > scaler filter and useful when you want unscaled > raw frames in an output file. > The primary goal that I'm trying to achieve here is dump raw "unscaled" yuv to an output file while decoding a multi-resolution video. Unfortunately, the ffmpeg utility auto-inserts a scaler into the filter graph, so -f rawvideo doesn't suffice here since the decoded data passes through the scaler before it's handed off to the rawvideo filter. I experimented with the alternative methods suggested in earlier feedback. More specifically, "reinit_filter" and "split" were suggested. For "split" filter, I couldn't find a way that it could bypass the auto-inserted scaler. Although -reinit_filter 0 works in some cases, it is quite verbose. And I have found many other cases where it doesn't work when we need to specify additional filters (e.g. hwupload, hwdownload when doing qsv or vaapi accelerated decoding with hw output formats). So, afaict, this patch is the only reliable method I can find to intercept the decoded data before it reaches the scaler for various use-cases (although the patch still needs a little bit of work as pointed out in previous replies). For added context, my organizations team and I contribute to both msdk/qsv and vaapi plugins for ffmpeg and gstreamer development. The idea is we want a way to validate that direct decoder output is an exact bitmatch across every decoder solution that we contribute to (to provide a better and more consistent end-user experience regardless of end-user choice). But since ffmpeg auto-inserts this "scaler" and not all scaling algo's are equal, it poses a challenge to verify. Regards, U. Artie
On 7/10/19, Eoff, Ullysses A <ullysses.a.eoff@intel.com> wrote: >> -----Original Message----- >> From: Eoff, Ullysses A >> Sent: Tuesday, July 09, 2019 6:45 PM >> To: ffmpeg-devel@ffmpeg.org >> Cc: Eoff, Ullysses A <ullysses.a.eoff@intel.com> >> Subject: [PATCH] avfilter: add rawdump filter >> >> This filter enables raw frames to be dumped to a >> file before they are sent through the auto-inserted >> scaler filter and useful when you want unscaled >> raw frames in an output file. >> > > The primary goal that I'm trying to achieve here is > dump raw "unscaled" yuv to an output file while > decoding a multi-resolution video. Unfortunately, > the ffmpeg utility auto-inserts a scaler into the filter > graph, so -f rawvideo doesn't suffice here since the > decoded data passes through the scaler before it's > handed off to the rawvideo filter. > > I experimented with the alternative methods suggested > in earlier feedback. More specifically, "reinit_filter" > and "split" were suggested. > > For "split" filter, I couldn't find a way that it could bypass > the auto-inserted scaler. > > Although -reinit_filter 0 works in some cases, it is quite > verbose. And I have found many other cases where it > doesn't work when we need to specify additional filters > (e.g. hwupload, hwdownload when doing qsv or vaapi > accelerated decoding with hw output formats). > > So, afaict, this patch is the only reliable method I can > find to intercept the decoded data before it reaches > the scaler for various use-cases (although the patch still > needs a little bit of work as pointed out in previous > replies). > > For added context, my organizations team and I contribute > to both msdk/qsv and vaapi plugins for ffmpeg and > gstreamer development. The idea is we want a way to > validate that direct decoder output is an exact bitmatch > across every decoder solution that we contribute > to (to provide a better and more consistent end-user > experience regardless of end-user choice). But since > ffmpeg auto-inserts this "scaler" and not all scaling > algo's are equal, it poses a challenge to verify. You can use this in your own branch. I see no valid usecase except in this testing scenario. > > Regards, > U. Artie > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
On Wed, Jul 10, 2019 at 07:54:32PM +0000, Eoff, Ullysses A wrote: > > -----Original Message----- > > From: Eoff, Ullysses A > > Sent: Tuesday, July 09, 2019 6:45 PM > > To: ffmpeg-devel@ffmpeg.org > > Cc: Eoff, Ullysses A <ullysses.a.eoff@intel.com> > > Subject: [PATCH] avfilter: add rawdump filter > > > > This filter enables raw frames to be dumped to a > > file before they are sent through the auto-inserted > > scaler filter and useful when you want unscaled > > raw frames in an output file. > > > > The primary goal that I'm trying to achieve here is > dump raw "unscaled" yuv to an output file while > decoding a multi-resolution video. Unfortunately, > the ffmpeg utility auto-inserts a scaler into the filter > graph, so -f rawvideo doesn't suffice here since the > decoded data passes through the scaler before it's > handed off to the rawvideo filter. > > I experimented with the alternative methods suggested > in earlier feedback. More specifically, "reinit_filter" > and "split" were suggested. > > For "split" filter, I couldn't find a way that it could bypass > the auto-inserted scaler. > > Although -reinit_filter 0 works in some cases, it is quite > verbose. And I have found many other cases where it > doesn't work when we need to specify additional filters > (e.g. hwupload, hwdownload when doing qsv or vaapi > accelerated decoding with hw output formats). can you fix the cases which do not work so the code works with -reinit_filter 0 ? Thanks [...]
> -----Original Message----- > From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf Of Michael Niedermayer > Sent: Friday, July 12, 2019 11:21 AM > To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add rawdump filter > > > On Wed, Jul 10, 2019 at 07:54:32PM +0000, Eoff, Ullysses A wrote: > > Although -reinit_filter 0 works in some cases, it is quite > > verbose. And I have found many other cases where it > > doesn't work when we need to specify additional filters > > (e.g. hwupload, hwdownload when doing qsv or vaapi > > accelerated decoding with hw output formats). > > can you fix the cases which do not work so the code works with > -reinit_filter 0 ? > Linjie's patch should fix it: https://patchwork.ffmpeg.org/patch/13905/ > Thanks > > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > Democracy is the form of government in which you can choose your dictator
diff --git a/Changelog b/Changelog index 86167b76a13c..7fdd3789f26d 100644 --- a/Changelog +++ b/Changelog @@ -35,6 +35,7 @@ version <next>: - IFV demuxer - derain filter - deesser filter +- rawdump filter version 4.1: diff --git a/doc/filters.texi b/doc/filters.texi index b0c49265e296..710100486e14 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -14631,6 +14631,26 @@ less than @code{0}, the filter will try to use a good random seed on a best effort basis. @end table +@anchor{rawdump} +@section rawdump + +Dump raw video frames to a file. + +The filter is especially useful when you want to dump raw frames to a file +before scaling is applied by the auto-inserted scaler in the graph (e.g. for +multi-resolution input streams). + +The input must be in non-hardware format. It may be necessary to insert an +additional @option{format} filter immediately preceding in the graph to get +the input in a supported format for dumping to the file. + +The following parameters are required: + +@table @option +@item file @var{filename} +Specify the filename to dump the data to. +@end table + @section readeia608 Read closed captioning (EIA-608) information from the top lines of a video frame. diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 455c809b151e..f8e02f382af9 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -334,6 +334,7 @@ OBJS-$(CONFIG_PSNR_FILTER) += vf_psnr.o framesync.o OBJS-$(CONFIG_PULLUP_FILTER) += vf_pullup.o OBJS-$(CONFIG_QP_FILTER) += vf_qp.o OBJS-$(CONFIG_RANDOM_FILTER) += vf_random.o +OBJS-$(CONFIG_RAWDUMP_FILTER) += vf_rawdump.o OBJS-$(CONFIG_READEIA608_FILTER) += vf_readeia608.o OBJS-$(CONFIG_READVITC_FILTER) += vf_readvitc.o OBJS-$(CONFIG_REALTIME_FILTER) += f_realtime.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 04a3df7d56d6..565e2a73cc82 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -317,6 +317,7 @@ extern AVFilter ff_vf_psnr; extern AVFilter ff_vf_pullup; extern AVFilter ff_vf_qp; extern AVFilter ff_vf_random; +extern AVFilter ff_vf_rawdump; extern AVFilter ff_vf_readeia608; extern AVFilter ff_vf_readvitc; extern AVFilter ff_vf_realtime; diff --git a/libavfilter/version.h b/libavfilter/version.h index 5bf37fa8b407..cc5b23b70bbe 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -30,8 +30,8 @@ #include "libavutil/version.h" #define LIBAVFILTER_VERSION_MAJOR 7 -#define LIBAVFILTER_VERSION_MINOR 56 -#define LIBAVFILTER_VERSION_MICRO 101 +#define LIBAVFILTER_VERSION_MINOR 57 +#define LIBAVFILTER_VERSION_MICRO 100 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ diff --git a/libavfilter/vf_rawdump.c b/libavfilter/vf_rawdump.c new file mode 100644 index 000000000000..fe8a8a692603 --- /dev/null +++ b/libavfilter/vf_rawdump.c @@ -0,0 +1,157 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/buffer.h" +#include "libavutil/imgutils.h" +#include "libavutil/opt.h" + +#include "avfilter.h" +#include "formats.h" +#include "internal.h" +#include "video.h" + +typedef struct RawDumpContext { + const AVClass *class; + FILE *rawdump_file; + char *rawdump_file_str; +} RawDumpContext; + +static int rawdump_query_formats(AVFilterContext *avctx) +{ + AVFilterFormats *formats = NULL; + const AVPixFmtDescriptor *desc; + int err; + + for (desc = av_pix_fmt_desc_next(NULL); desc; + desc = av_pix_fmt_desc_next(desc)) { + if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL) + continue; + err = ff_add_format(&formats, av_pix_fmt_desc_get_id(desc)); + if (err < 0) + return err; + } + + return ff_set_common_formats(avctx, formats); +} + +static int rawdump_filter_frame(AVFilterLink *inlink, AVFrame *frame) +{ + AVFilterContext *avctx = inlink->dst; + RawDumpContext *ctx = avctx->priv; + uint8_t *buffer = NULL; + int size, err; + + size = av_image_get_buffer_size(frame->format, frame->width, + frame->height, 1); + buffer = av_malloc(size); + + err = av_image_copy_to_buffer(buffer, size, + (const uint8_t * const *) frame->data, + (const int *) frame->linesize, frame->format, + frame->width, frame->height, 1); + if (err < 0) { + av_log(ctx, AV_LOG_ERROR, "Failed to copy image to buffer: %d.\n", err); + goto fail; + } + + err = fwrite(buffer, 1, size, ctx->rawdump_file); + if (err < 0) { + av_log(ctx, AV_LOG_ERROR, "Failed to dump buffer to file: %d.\n", err); + goto fail; + } + + av_log(ctx, AV_LOG_DEBUG, "Dumped %d bytes to file.\n", size); + + av_freep(&buffer); + + return ff_filter_frame(inlink->dst->outputs[0], frame); + +fail: + av_freep(&buffer); + return err; +} + +static av_cold int rawdump_init(AVFilterContext *avctx) +{ + RawDumpContext *ctx = avctx->priv; + static char *mode = "w"; + + ctx->rawdump_file = fopen(ctx->rawdump_file_str, mode); + + if (ctx->rawdump_file == NULL) { + int err = AVERROR(errno); + char buf[128]; + av_strerror(err, buf, sizeof(buf)); + av_log(ctx, AV_LOG_ERROR, "Failed to open %s for dumping: %s\n", + ctx->rawdump_file_str, buf); + return err; + } + + av_log(ctx, AV_LOG_DEBUG, "Opened %s (mode:%s) for dumping.\n", + ctx->rawdump_file_str, mode); + + mode = "a"; + + return 0; +} + +static av_cold void rawdump_uninit(AVFilterContext *avctx) +{ + RawDumpContext *ctx = avctx->priv; + + if (ctx->rawdump_file != NULL) + fclose(ctx->rawdump_file); +} + +#define OFFSET(x) offsetof(RawDumpContext, x) +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM +static const AVOption rawdump_options[] = { + {"file", "Set file where to dump raw frames", OFFSET(rawdump_file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, + { NULL } +}; + +AVFILTER_DEFINE_CLASS(rawdump); + +static const AVFilterPad rawdump_inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .filter_frame = rawdump_filter_frame, + }, + { NULL } +}; + +static const AVFilterPad rawdump_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + }, + { NULL } +}; + +AVFilter ff_vf_rawdump = { + .name = "rawdump", + .description = NULL_IF_CONFIG_SMALL("Dump frames to file"), + .init = rawdump_init, + .uninit = rawdump_uninit, + .query_formats = rawdump_query_formats, + .priv_size = sizeof(RawDumpContext), + .priv_class = &rawdump_class, + .inputs = rawdump_inputs, + .outputs = rawdump_outputs, +};
This filter enables raw frames to be dumped to a file before they are sent through the auto-inserted scaler filter and useful when you want unscaled raw frames in an output file. Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com> --- Changelog | 1 + doc/filters.texi | 20 +++++ libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/version.h | 4 +- libavfilter/vf_rawdump.c | 157 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 182 insertions(+), 2 deletions(-) create mode 100644 libavfilter/vf_rawdump.c