5

So I have the following video example

    Stream #0:0(jpn): Video: h264 (High 10), yuv420p10le(progressive), 1920x1036 [SAR 1:1 DAR 480:259], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Stream #0:1(eng): Audio: ac3, 48000 Hz, 5.0(side), fltp, 640 kb/s (default)
    Stream #0:2(jpn): Audio: ac3, 48000 Hz, 5.0(side), fltp, 640 kb/s
    Stream #0:3(eng): Subtitle: ass (default)
    Metadata:
      title           : English Signs & Songs
    Stream #0:4(eng): Subtitle: ass
    Metadata:
      title           : English Subtitles
    Stream #0:5: Attachment: ttf
    Metadata:
      filename        : PutoInsanity.ttf
      mimetype        : application/x-truetype-font

I want to use ffprobe to count the amount of video streams and audio streams, which in this case should give me 1 and 2 resp. How can this be achieved?

llogan
  • 63,280
YTZ
  • 325

1 Answers1

4

No such feature, but you can use ffprobe plus additional tools such as uniq (and sort if desired) to process the output.

List number of stream types

ffprobe -v error -show_entries stream=codec_type -of default=nw=1:nk=1 input.mkv | uniq -c
      1 data
      1 video
      1 attachment
      8 subtitle
      6 audio

Just output number for specific stream type

Or a piecemeal method. This example shows how many audio streams there are:

ffprobe -v error -select_streams a -show_entries stream=index -of csv=p=0 input.mkv | wc -w
2

Accepted values for -select_streams:

  • v video
  • V video (excluding attached pictures, video thumbnails or cover art).
  • a audio
  • s subtitles
  • d data
  • t attachments
llogan
  • 63,280