Trying to finish up my script that automates some video encoding work.
Situation: There is an MKV file to be transcoded.
Problem: MKVINFO will give a bunch of output about an MKV file, included in that output are two lines I am interested in:
| + Default duration: 41.708ms (23.976 fps for a video track)
| + Pixel width: 1280
Is there some way of echoing the output of from MKVINFO, and parsing down the two bits of information that I am looking for: fps (23.976) and pixel width (1280). I get the impression that this is doable, but I have only learned what little Bash I know from googling for examples, but I haven't found something similar to this in my looking.
Thanks, appreciate any help.
I'm on Mac OS X Snow Leopard 10.6.3. the command to run with mkvinfo is simply:
$ mkvinfo mkvfile.mkv
ballpark figure of about 100 lines of output from this command.
So far this is awesome! Going to have to run it against a few test MKV's to see that it's reliably getting that correct information - thank you so much!
# Adding a little routine to check the Pixel Width and Frames Per Second
MKVFPS=$( mkvinfo "$i" | awk -F "[ (]" '/Default duration:/ { print $(NF-5)}')
echo " *** Test MKV Information ***"
echo "MKVFPS: $MKVFPS"
MKVWIDTH=$( mkvinfo "$i" | awk -F "[ (]" '/Pixel width:/ {print $NF}')
echo "MKVWIDTH: $MKVFPS"
I was looking to leverage this to a very similar situation, in this other situation the pattern I am trying to match shows up in the information multiple times. Is there a way I can tell it to only return the 1st time after the pattern match and not continue to show the ones that show up afterwards.