Results 1 to 2 of 2
hi guys,
can you help me in this part of code.
if i do:
mplayer -vo null -nosound -vf cropdetect Filename.mp4
the output is...
Audio: no sound
Starting playback...
Movie-Aspect ...
- 06-05-2011 #1Just Joined!
- Join Date
- Jun 2011
- Posts
- 1
awk assign output to variable
hi guys,
can you help me in this part of code.
if i do:
mplayer -vo null -nosound -vf cropdetect Filename.mp4
the output is...
Audio: no sound
Starting playback...
Movie-Aspect is 1.50:1 - prescaling to correct movie aspect.
VO: [null] 720x480 => 720x480 Planar YV12
[CROP] Crop area: X: 719..0 Y: 479..0 (-vf crop=706:469:14:80).
[CROP] Crop area: X: 719..0 Y: 479..0 (-vf crop=705:467:14:80).
[CROP] Crop area: X: 719..0 Y: 479..0 (-vf crop=704:464:14:80).
[CROP] Crop area: X: 719..0 Y: 479..0 (-vf crop=704:464:14:80).
I just wanna get the "704" and "464" of the last line and i do:
mplayer -vo null -nosound -vf cropdetect Filename.mp4 | grep 'vf crop\=' | tail -1 | awk -F\= '{print $2}' | awk -F\: '{print $1, $2 }'
i get: 704 464
but i want to get assigned as a variable to be used in bash for continuing the script like: w=704 and h=464.
how i do? do you have a better and easy way to do it?
thanks!
- 06-07-2011 #2Linux Guru
- Join Date
- May 2011
- Posts
- 1,838
you've done all the hard work. there are several ways to do this. one would be to just make the output of your command a variable, then split that variable up:
Code:out=`mplayer -vo null -nosound -vf cropdetect Filename.mp4 | grep 'vf crop\=' | tail -1 | awk -F\= '{print $2}' | awk -F\: '{print $1, $2 }'` varA=`echo $out|awk '{print $1}'` varB=`echo $out|awk '{print $2}'`


Reply With Quote