Skip to main content
more concise command
Source Link
slhck
  • 1.1k
  • 1
  • 10
  • 25

If you have ffprobe installed:

ffprobe -loglevel quiet -show_streams<input> -show_entries stream=indexformat=nb_streams -of csv <input> |v wc0 -lof compact=p=0:nk=1

This will output one line per stream, and count the number of lines with wc. You can also filter for video or audio streams by adding -select_streams v or -select_streams a, respectively. See the manual for more details.

If you do not have ffprobe, ffmpeg can be used too, but in a slightly less robust way (i.e., this may break if the output format changes or something contains the words "Stream #" in the output):

ffmpeg -i <input> 2>&1 | grep "Stream #" | wc -l

If you have ffprobe installed:

ffprobe -loglevel quiet -show_streams -show_entries stream=index -of csv <input> | wc -l

This will output one line per stream, and count the number of lines with wc. You can also filter for video or audio streams by adding -select_streams v or -select_streams a, respectively. See the manual for more details.

If you do not have ffprobe, ffmpeg can be used too, but in a slightly less robust way (i.e., this may break if the output format changes or something contains the words "Stream #" in the output):

ffmpeg -i <input> 2>&1 | grep "Stream #" | wc -l

If you have ffprobe installed:

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

You can also filter for video or audio streams by adding -select_streams v or -select_streams a, respectively. See the manual for more details.

If you do not have ffprobe, ffmpeg can be used too, but in a slightly less robust way (i.e., this may break if the output format changes or something contains the words "Stream #" in the output):

ffmpeg -i <input> 2>&1 | grep "Stream #" | wc -l
Source Link
slhck
  • 1.1k
  • 1
  • 10
  • 25

If you have ffprobe installed:

ffprobe -loglevel quiet -show_streams -show_entries stream=index -of csv <input> | wc -l

This will output one line per stream, and count the number of lines with wc. You can also filter for video or audio streams by adding -select_streams v or -select_streams a, respectively. See the manual for more details.

If you do not have ffprobe, ffmpeg can be used too, but in a slightly less robust way (i.e., this may break if the output format changes or something contains the words "Stream #" in the output):

ffmpeg -i <input> 2>&1 | grep "Stream #" | wc -l