ffprobe - Streams - Get the number of available streams

ffprobe <input> -show_entries format=nb_streams -v 0 -of csv=p=0
 
or 
 
ffprobe <input> -show_entries format=nb_streams -v 0 -of compact=p=0:nk=1

NOTE: This can be filtered for only video or audio streams by adding -select_streams v or -select_streams a, respectively.

  • -v 0 only show fatal errors which could lead the process to crash, such as an assertion failure.
    • This hides “info” output (version info, etc) which makes parsing easier.
  • -show_entries format=nb_streams shows the number of streams.
  • -of csv=p=0 sets the output formatting. In this case it hides the descriptions and only shows the value.

References

https://trac.ffmpeg.org/wiki/FFprobeTips

https://ffmpeg.org/ffprobe.html#Writers