[FFmpeg-user] Why Does ffprobe Report an Incorrect Number of Frames?

John G skeeve99 at yahoo.com.au
Thu May 8 02:59:54 CEST 2014



> Something like this is relatively quick:
> 
> time ffprobe -select_streams v -count_frames -show_entries stream=nb_read_frames test.flv 2>/dev/null
>> [STREAM]
> nb_read_frames=167325
> [/STREAM]

For my applications, it would be Ok, as the file sizes are generally 150MB or less...  but trying this command on the sample (~7MB) .avi file seems to have the same problem as before in that the frame count is still incorrect:-

c:\> ffprobe -select_streams v -count_frames -show_entries stream=nb_read_frames sample.avi


ffprobe version N-62509-g97751e1 Copyright (c) 2007-2014 the FFmpeg developers
  built on Apr 17 2014 22:01:31 with gcc 4.8.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads 
                 --enable-avisynth --enable-bzlib --enable-fontconfig 
                 --enable-frei0r --enable-gnutls --enable-iconv --enable-libass 
                 --enable-libbluray --enable-libcaca --enable-libfreetype 
                 --enable-libgsm --enable-libilbc --enable-libmodplug 
                 --enable-libmp3lame --enable-libopencore-amrnb 
                 --enable-libopencore-amrwb --enable-libopenjpeg 
                 --enable-libopus --enable-librtmp --enable-libschroedinger 
                 --enable-libsoxr --enable-libspeex --enable-libtheora 
                 --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc 
                 --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx 
                 --enable-libwavpack --enable-libx264 --enable-libx265 
                 --enable-libxavs --enable-libxvid --enable-decklink --enable-zlib
  libavutil      52. 77.100 / 52. 77.100
  libavcodec     55. 58.103 / 55. 58.103
  libavformat    55. 37.100 / 55. 37.100
  libavdevice    55. 13.100 / 55. 13.100
  libavfilter     4.  4.100 /  4.  4.100
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
Input #0, avi, from 'sample.avi':
  Metadata:
    encoder         : Lavf55.37.100
  Duration: 00:00:35.00, start: 0.000000, bitrate: 1707 kb/s
    Stream #0:0: Video: msmpeg4v3 (MP43 / 0x3334504D), yuv420p, 639x361, 1668 kb/s, 200 fps, 200 tbr, 200 tbn, 200 tbc
    Metadata:
      title           : ~temp.avi Video #1
[STREAM]
nb_read_frames=1619
[/STREAM]

...which is not the 6999 or so.

IF! I convert the video into a basic MPEG format though:-

c:\> ffmpeg -i sample.avi -c:v mpeg4 -q:v 2.0     new.mpg

ffmpeg version N-62509-g97751e1 Copyright (c) 2000-2014 the FFmpeg developers
  built on Apr 17 2014 22:01:31 with gcc 4.8.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads 
                 --enable-avisynth --enable-bzlib --enable-fontconfig 
                 --enable-frei0r --enable-gnutls --enable-iconv 
                 --enable-libass --enable-libbluray --enable-libcaca 
                 --enable-libfreetype --enable-libgsm --enable-libilbc 
                 --enable-libmodplug --enable-libmp3lame 
                 --enable-libopencore-amrnb --enable-libopencore-amrwb 
                 --enable-libopenjpeg --enable-libopus --enable-librtmp 
                 --enable-libschroedinger --enable-libsoxr --enable-libspeex 
                 --enable-libtheora --enable-libtwolame --enable-libvidstab 
                 --enable-libvo-aacenc --enable-libvo-amrwbenc 
                 --enable-libvorbis --enable-libvpx --enable-libwavpack 
                 --enable-libx264 --enable-libx265 --enable-libxavs 
                 --enable-libxvid --enable-decklink --enable-zlib
  libavutil      52. 77.100 / 52. 77.100
  libavcodec     55. 58.103 / 55. 58.103
  libavformat    55. 37.100 / 55. 37.100
  libavdevice    55. 13.100 / 55. 13.100
  libavfilter     4.  4.100 /  4.  4.100
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
Input #0, avi, from 'sample.avi':
  Metadata:
    encoder         : Lavf55.37.100
  Duration: 00:00:35.00, start: 0.000000, bitrate: 1707 kb/s
    Stream #0:0: Video: msmpeg4v3 (MP43 / 0x3334504D), yuv420p, 639x361, 1668 kb/s, 200 fps, 200 tbr, 200 tbn, 200 tbc
    Metadata:
      title           : ~temp.avi Video #1
[mpeg @ 02caca20] VBV buffer size not set, using default size of 130KB
If you want the mpeg file to be compliant to some specification
Like DVD, VCD or others, make sure you set the correct buffer size
Output #0, mpeg, to 'new.mpg':
  Metadata:
    encoder         : Lavf55.37.100
    Stream #0:0: Video: mpeg4, yuv420p, 639x361, q=2-31, 200 kb/s, 90k tbn, 200 tbc
    Metadata:
      title           : ~temp.avi Video #1
Stream mapping:
  Stream #0:0 -> #0:0 (msmpeg4 -> mpeg4)

...and then try the command:-

c:\> ffprobe -select_streams v -count_frames -show_entries stream=nb_read_frames new.mpg

ffprobe version N-62509-g97751e1 Copyright (c) 2007-2014 the FFmpeg developers
  built on Apr 17 2014 22:01:31 with gcc 4.8.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads 
                 --enable-avisynth --enable-bzlib --enable-fontconfig 
                 --enable-frei0r --enable-gnutls --enable-iconv --enable-libass 
                 --enable-libbluray --enable-libcaca --enable-libfreetype 
                 --enable-libgsm --enable-libilbc --enable-libmodplug 
                 --enable-libmp3lame --enable-libopencore-amrnb 
                 --enable-libopencore-amrwb --enable-libopenjpeg 
                 --enable-libopus --enable-librtmp --enable-libschroedinger 
                 --enable-libsoxr --enable-libspeex --enable-libtheora 
                 --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc 
                 --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx 
                 --enable-libwavpack --enable-libx264 --enable-libx265 
                 --enable-libxavs --enable-libxvid --enable-decklink --enable-zlib
  libavutil      52. 77.100 / 52. 77.100
  libavcodec     55. 58.103 / 55. 58.103
  libavformat    55. 37.100 / 55. 37.100
  libavdevice    55. 13.100 / 55. 13.100
  libavfilter     4.  4.100 /  4.  4.100
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mpeg, from 'new.mpg':
  Duration: 00:00:34.99, start: 0.500000, bitrate: 3247 kb/s
    Stream #0:0[0x1e0]: Video: mpeg4 (Simple Profile), yuv420p, 639x361 [SAR 1:1 DAR 639:361], 200 fps, 200 tbr, 90k tbn, 200 tbc
[STREAM]
nb_read_frames=6999
[/STREAM]

...which is the correct frame count.

So, to use ffprobe successfully, it seems that I might need to convert all the videos (!!!) into a format that ffmprobe "likes"!?


-John


More information about the ffmpeg-user mailing list