-2

I want to go through a bunch of files in various sub folders within a root directory quickly to get the video and audio format type.

I can get the information I need from a single file using:

ffprobe file.mp4 2>&1 >/dev/null | grep "Stream"

I can run ffprobe for each file inside the root folder using

find . -name "*.mp4" -execdir ffprobe "{}" \;

What I am struggling with is to use grep with the second command to filter the output I want (as per the first command) and pipe the entire output into a file. What is the missing link/s here?

pasan
  • 13
  • 1
  • What is the `>/dev/null` for may I ask? – Jetchisel May 30 '21 at 06:40
  • 1
    Grep is not necessary there, ffprobe can extract that information on its own. Though we need to know the specifics of the output you expect to answer this. – oguz ismail May 30 '21 at 06:55
  • Note that on Unix, BSD--and Linux, too--they are "directories" and not the Windows concept of "folders" which is not the same thing. – Rob May 30 '21 at 10:59

1 Answers1

0

Something like this should work:

find . -name "*.mp4" -execdir ffprobe "{}" \; 2>&1 | grep "Stream" > some_file.txt

The principle is the same really, it can be generalized as

some_command 2>&1 | grep "Stream"

where some_command in this case is

find . -name "*.mp4" -execdir ffprobe "{}" \;
Artornico
  • 1
  • 1