Revision f801d8aa

View differences:

doc/ffmpeg-doc.texi
585 585
Calculate PSNR of compressed frames.
586 586
@item -vstats
587 587
Dump video coding statistics to @file{vstats_HHMMSS.log}.
588
@item -vstats_file file
589
Dump video coding statistics to @var{file}.
588 590
@item -vhook module
589 591
Insert video processing @var{module}. @var{module} contains the module
590 592
name and its parameters separated by spaces.
ffmpeg.c
166 166
static int do_hex_dump = 0;
167 167
static int do_pkt_dump = 0;
168 168
static int do_psnr = 0;
169
static int do_vstats = 0;
170 169
static int do_pass = 0;
171 170
static char *pass_logfilename = NULL;
172 171
static int audio_stream_copy = 0;
......
177 176
static int copy_ts= 0;
178 177
static int opt_shortest = 0; //
179 178
static int video_global_header = 0;
179
static FILE *fvstats= NULL;
180 180

  
181 181
static int rate_emu = 0;
182 182

  
......
841 841
static void do_video_stats(AVFormatContext *os, AVOutputStream *ost,
842 842
                           int frame_size)
843 843
{
844
    static FILE *fvstats=NULL;
845
    char filename[40];
846
    time_t today2;
847
    struct tm *today;
848 844
    AVCodecContext *enc;
849 845
    int frame_number;
850 846
    int64_t ti;
851 847
    double ti1, bitrate, avg_bitrate;
852 848

  
853
    if (!fvstats) {
854
        today2 = time(NULL);
855
        today = localtime(&today2);
856
        snprintf(filename, sizeof(filename), "vstats_%02d%02d%02d.log", today->tm_hour,
857
                                               today->tm_min,
858
                                               today->tm_sec);
859
        fvstats = fopen(filename,"w");
860
        if (!fvstats) {
861
            perror("fopen");
862
            exit(1);
863
        }
864
    }
865

  
866 849
    ti = INT64_MAX;
867 850
    enc = ost->st->codec;
868 851
    if (enc->codec_type == CODEC_TYPE_VIDEO) {
......
1197 1180
                        case CODEC_TYPE_VIDEO:
1198 1181
                            do_video_out(os, ost, ist, &picture, &frame_size);
1199 1182
                            video_size += frame_size;
1200
                            if (do_vstats && frame_size)
1183
                            if (fvstats && frame_size)
1201 1184
                                do_video_stats(os, ost, frame_size);
1202 1185
                            break;
1203 1186
                        case CODEC_TYPE_SUBTITLE:
......
3449 3432
    }
3450 3433
}
3451 3434

  
3435
static void opt_vstats_file (const char *arg)
3436
{
3437
    if (!fvstats)
3438
    {
3439
        fvstats = fopen(arg ,"w");
3440
        if (!fvstats) {
3441
            perror("fopen");
3442
            exit(1);
3443
        }
3444
    }
3445
}
3446

  
3447
static void opt_vstats (void)
3448
{
3449
    if (!fvstats) {
3450
        char filename[40];
3451
        time_t today2 = time(NULL);
3452
        struct tm *today = localtime(&today2);
3453

  
3454
        snprintf(filename, sizeof(filename), "vstats_%02d%02d%02d.log", today->tm_hour,
3455
                                               today->tm_min,
3456
                                               today->tm_sec);
3457
        opt_vstats_file(filename);
3458
    }
3459
}
3460

  
3452 3461
static void opt_video_bsf(const char *arg)
3453 3462
{
3454 3463
    AVBitStreamFilterContext *bsfc= av_bitstream_filter_init(arg); //FIXME split name and args for filter at '='
......
3610 3619
    { "deinterlace", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&do_deinterlace},
3611 3620
      "deinterlace pictures" },
3612 3621
    { "psnr", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&do_psnr}, "calculate PSNR of compressed frames" },
3613
    { "vstats", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&do_vstats}, "dump video coding statistics to file" },
3622
    { "vstats", OPT_EXPERT | OPT_VIDEO, {(void*)&opt_vstats}, "dump video coding statistics to file" },
3623
    { "vstats_file", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_vstats_file}, "dump video coding statistics to file", "file" },
3614 3624
    { "vhook", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)add_frame_hooker}, "insert video processing module", "module" },
3615 3625
    { "intra_matrix", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_intra_matrix}, "specify intra matrix coeffs", "matrix" },
3616 3626
    { "inter_matrix", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_inter_matrix}, "specify inter matrix coeffs", "matrix" },

Also available in: Unified diff