I would like to find all mp4
files that is 1920x1080.
If I do
find . -type f -name \*.mp4 -exec ffprobe '{}' \; 2>&1
it will find all mp4
files and show the video info. E.g. will the output 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 are
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 figure out how to incorporate if grep -q 1920x1080
and in the first, and in the second white spaces in filenames messes the output up.
Question
How do I output only the filename with path if the output matches 1920x1080
?
You probably want to exec a shell. Something like:
find . -type f -name \*.mp4 -exec sh -c 'ffprobe "$0" 2>&1 |
grep -q 1920x1080 && echo "$0"' {} \;
Something like this:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With