3

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?

1 Answer 1

3

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
3
  • FYI, this also works for subtitles, such as: ffprobe -v error -show_entries stream=codec_type input.mkv | grep "codec_type=subtitle" | wc -w) Sep 25, 2020 at 12:33
  • 1
    @MrPotatoHead Reminded me of uniq. Answer updated.
    – llogan
    Sep 25, 2020 at 18:45
  • ffmpeg.org/ffprobe.html and here, but probably can only specify 1 stream type at a time =/
    – Pysis
    Dec 5, 2023 at 22:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .