0

I'm looking for a way to get only the lines that contains a specified word, in this case all lines that contains the word Stream from an output

I've tried;

streams=$(ffprobe -i  "movie.mp4"  | grep "Stream")

but that didn't get any results..

or do I need to output it to a file and then try to extract the lines I'm looking for?

JoBe
  • 407
  • 2
  • 14
  • 2
    "grep" should be what you're looking for. Q: What does `ffprobe -i "movie.mp4" | grep "Stream"` look like when you run it from the command line? Perhaps "ffprobe" isn't writing to stdout? Or "Stream" is spelled differently? – paulsm4 Oct 12 '20 at 20:12

2 Answers2

3

@paulsm4 was spot on ... the output goes to STDERR.

streams=$(ffprobe -i  "movie.mp4"  |& grep "Stream")

Note the &

tink
  • 14,342
  • 4
  • 46
  • 50
  • 1
    Yes @JoBe ... unix/linux tools typically implement both standard output and standard error as separate streams, in short STDOUT/STDERR ... for some reason the developer of `ffprobe` seems to think of their output as "error" rather than "output", the reason for this I can't quite fathom. – tink Oct 12 '20 at 21:24
  • The ffmpeg tools have a common logging API. Since ffmpeg can pipe media data over stdout, logs are sent to stderr. – Gyan Oct 15 '20 at 18:59
1

No need for grep. Just use ffprobe directly to get whatever info you need.

Output all info

ffprobe -loglevel error -show_format -show_streams input.mp4

Video info only

ffprobe -loglevel error -show_streams -select_streams v input.mp4

Audio info only

ffprobe -loglevel error -show_streams -select_streams a input.mp4

Width x height

See Getting video dimension / resolution / width x height from ffmpeg

Duration

See How to get video duration?

Format / codec

Info on frames

See Get video frames information with ffmpeg

More info and examples

See FFmpeg Wiki: ffprobe

llogan
  • 121,796
  • 28
  • 232
  • 243