[FFmpeg-user] FFprobe scripting question

Rodney Baker rodney.baker at iinet.net.au
Sat Jun 16 16:26:06 CEST 2012


On Sat, 16 Jun 2012 22:40:48 Clément Bœsch wrote:
[...]
> > 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.


Excellent, thanks Clement. I usually keep within a couple of weeks of git head 
so should be OK there. My bash scripting skills are very basic - I've only 
just learned how to do command line parameter parsing (and even then only 
using short options so far) so the example is much appreciated. 

FWIW, here is the script in its current form (testing it as I type this).

Regards,
Rodney.
-- 
======================================================
Rodney Baker
rodney at jeremiah31-10.net
web: www.jeremiah31-10.net
======================================================

-- 
==========================================================================
Rodney Baker VK5ZTV
rodney.baker at iinet.net.au
==========================================================================
-------------- next part --------------
A non-text attachment was scrubbed...
Name: convert_video_files
Type: application/x-shellscript
Size: 4474 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-user/attachments/20120616/435c1973/attachment.bin>


More information about the ffmpeg-user mailing list