[FFmpeg-user] FFprobe scripting question
Clément Bœsch
ubitux at gmail.com
Sat Jun 16 15:10:48 CEST 2012
On Sat, Jun 16, 2012 at 03:04:28PM +0200, Clément Bœsch wrote:
> On Sat, Jun 16, 2012 at 11:48:38AM +0930, Rodney Baker wrote:
> > On Sat, 16 Jun 2012 08:33:11 Stefano Sabatini wrote:
> > > -show_streams -print_format default=nk=1:nw=1 | sed -n 9p
> >
> > Thanks Adam, Clement and Stefano. This produces the required result (but I
> > still need to redirect stderr to /dev/null to get just the numeric answer that
> > I'm looking for).
> >
> > A slight modification to sed -n 8,9p prints both horizontal and vertical
> > pixels which is even better. :-)
> >
>
> This is not reliable if we add entries.
>
> > Now I just need to learn how to do arrays in bash (or learn another
> > programming language other than Visual Basic) so I can do something useful
> > with the rest of the output that I'm currently throwing away. :-)
> >
>
> If you're scripting with bash I would suggest something like this:
>
> % ./ffprobe -v 0 INPUT -show_streams -of flat=s=_:h=0 | grep -E '(width|height)'
> stream_0_width=1280
> stream_0_height=720
>
> And eval that output, so you can directly access the information with
> $stream_0_width and $stream_0_height.
>
Complete example:
% cat res.sh
#!/bin/bash
eval $(ffprobe -v 0 $1 -show_streams -of flat=s=_:h=0 | grep -E 'width|height')
printf "${stream_0_width}x${stream_0_height}\n"
% ./res.sh big_buck_bunny_1080p_h264.mov
1920x1080
Note: flat output is fairly recent and you may need to upgrade your
FFmpeg.
--
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-user/attachments/20120616/ad52d21e/attachment.asc>
More information about the ffmpeg-user
mailing list