Monday, July 14, 2014


VstatsReader is a simple CLI app which reads ffmpeg-generated video statistics logs (vstats_*.log) and retrieves information like peak q, peak bitrate, etc.  It generates an ini file which will be located in the same folder as the vstats log file (same file name with an 'ini' extension).

Here's a sample of a generated ini file:


VstatsLogFile=D:\SEKI APPS\Work-In-Progress\VstatsReader\sample.log





start=2014/07/10 19:50:59
end=2014/07/10 19:51:13
elapsed=0h 0m 14s

; bitrates are in 'kbits/s'.

Q stands for quantizer.  "ApproximatePositionOfPeakBitrateAlongTimeline" (yeah, I know it's a mouthful) shows a number which you can use to compute when or where along the timeline of the video the peak bitrate occurred.  If this value is 0.5 and video duration is 2 hours, then the peak occurred at 3600 seconds or at 1 hour, 0 minutes and 0 seconds.  This is, of course, just an approximate.  The reason why I elected to use a number (instead of time/PTS) is that vstats logs seem to show erroneous data when "-f rawvideo NUL" was used (even average bitrate seems to be off).

1.  In Windows Explorer, you can drag & drop a vstats log file onto the file "VstatsReader.exe".
2.  In a batch file:

@echo off

set vstatsreader="C:\VstatsReader\VstatsReader.exe"
set vstatslogfile="E:\Video Processing\Output\Logs\Debbie went to Dallas (2014).log"

%vstatsreader% %vstatslogfile%

Here's an example of an ffmpeg command that will generate a vstats log file:

%ffmpeg% -i "E:\MOVIES\Tiktik - The Aswang Chronicles (2012) [Tagalog].mp4" -vf "scale=640:360, setsar=1, format=pix_fmts=yuv420p" -vtag xvid -g 300 -qscale:v 4 -vstats -vstats_file "E:\~ VidProkEnMasse\OUTPUT\Logs\Tiktik - The Aswang Chronicles (2012) [Tagalog]_FMP4_vstats.log" -c:v mpeg4 -r 29.97 -c:a libmp3lame -b:a 96k -ar 48000 -ac 2 "E:\~ VidProkEnMasse\OUTPUT\Tiktik - The Aswang Chronicles (2012) [Tagalog]_FMP4.avi"

Other files included:
'sample.log' - you can drop this file onto the file 'VstatsReader.exe' to test.
'VstatsReader.au3' - source code (AutoIt).


No comments:

Post a Comment