How to do "for everyone" at the end of the search?

I would like to find all mp4 files of size 1920x1080.

If i do

 find . -type f -name \*.mp4 -exec ffprobe '{}' \; 2>&1 

he will find all mp4 files and show video information. For instance. whether the output will contain (among other lines)

 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './5432223.mp4': Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 1744 kb/s, 29.97 fps, 29.97 tbr, 60k tbn, 59.94 tbc 

My current ideas

 find . -type f -name \*.mp4 -print0|xargs -0 -n1 echo for f in $(find . -type f -name \*.mp4); do ffprobe $f 2>&1 | grep 1920x1080;done 

where I can’t understand how to enable if grep -q 1920x1080 , and in the first and second white spaces in the file names the output is placed up.

Question

How can I display only the file name with the path if the result matches 1920x1080 ?

+4
source share
2 answers

You probably want to execute a shell. Sort of:

 find . -type f -name \*.mp4 -exec sh -c 'ffprobe "$0" 2>&1 | grep -q 1920x1080 && echo "$0"' {} \; 
+2
source

Something like that:

 find -type f -name "*.mp4" -print0 | while read -d $'\0' file do ffprobe "$file" 2>&1 | grep -q 1920x1080 # grep will return zero if the pattern was found: if [ $? = 0 ] ; then echo "$file" fi done 
+3
source

Source: https://habr.com/ru/post/1480333/


All Articles