[FFmpeg-user] How to get he total number of frames

Peter White peter.white at posteo.net
Tue Mar 9 15:03:55 EET 2021


On Tue, Mar 09, 2021 at 11:26:49PM +1030, Rodney Baker wrote:
> On Tuesday, 9 March 2021 23:17:34 ACDT Peter White wrote:
> > On Tue, Mar 09, 2021 at 01:07:41PM +0100, Nicolas George wrote:
> > > Peter White (12021-03-09):
> > > > ffmpeg -i input.mkv -an -sn -c copy -f null -
> > > 
> > > -c copy tells ffmpeg to dispense with the decoder, which means it does
> > > not count frames but packets. Have you tried telling ffprobe to count
> > > packets?
> > 
> > I have now, but it returns 'N/A'. Now that I see that, I might have
> > tried it way back when, even, and have forgotten about it.
> > 
> > ffprobe -count_packets -select_streams v:0 -show_entries
>  [...]
> >     Stream #0:0: Video: hevc (Main 10), yuv420p10le(tv, bt709), 768x432 [SAR
> > 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc (default) Metadata:
> >       BPS-eng         : 1021384
> >       DURATION-eng    : 00:21:40.716000000
> >       NUMBER_OF_FRAMES-eng: 31186
> 
> Isn't this exactly what you're looking for? 
> [...]

Yes, in this particular case the frame count was written to the metadata
but one cannot rely on that as was established previously. A universal
solution is the aim.
Plus, I tend not to trust metadata that can be arbitrarily manipulated.


Peter


More information about the ffmpeg-user mailing list