display only lines from output that contains a specified word

826 views Asked by At

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?

2

There are 2 answers

2
tink On BEST ANSWER

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

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

Note the &

0
llogan On

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