avfilter/vf_psnr: Add support for writing stats to stdout

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Tobias Rapp 2015-10-20 15:02:21 +02:00 committed by Michael Niedermayer
parent 451b6a990a
commit 1ec8c1554e
2 changed files with 6 additions and 3 deletions

View File

@ -8939,7 +8939,8 @@ The description of the accepted parameters follows.
@table @option
@item stats_file, f
If specified the filter will use the named file to save the PSNR of
each individual frame.
each individual frame. When filename equals "-" the data is sent to
standard output.
@end table
The file printed if @var{stats_file} is selected, contains a sequence of

View File

@ -193,7 +193,9 @@ static av_cold int init(AVFilterContext *ctx)
s->min_mse = +INFINITY;
s->max_mse = -INFINITY;
if (s->stats_file_str) {
if (!strcmp(s->stats_file_str, "-")) {
s->stats_file = stdout;
} else if (s->stats_file_str) {
s->stats_file = fopen(s->stats_file_str, "w");
if (!s->stats_file) {
int err = AVERROR(errno);
@ -334,7 +336,7 @@ static av_cold void uninit(AVFilterContext *ctx)
ff_dualinput_uninit(&s->dinput);
if (s->stats_file)
if (s->stats_file && s->stats_file != stdout)
fclose(s->stats_file);
}