I usually use midentify, which spits out a nicely formatted string, that is easy to preg_match
It however, fails sometimes, so I wanna do a fall-back method via ffmpeg. ffmpeg -i hello.avi spits this out:
Input #0, avi, from 'hello.avi':
Metadata:
encoder : Nandub v1.0rc2
Duration: 01:11:16.56, start: 0.000000, bitrate: 1202 kb/s
Stream #0.0: Video: mpeg4, yuv420p, 640x336 [PAR 1:1 DAR 40:21], 25 tbr, 25 tbn, 25 tbc
Stream #0.1: Audio: mp3, 48000 Hz, 2 channels, s16, 117 kb/s
At least one output file must be specified
I need the width and height of the actual frame size, as well as the duration.
What would be the best way to extract this from here? Im not that familiar with regex.
Duration is easy:
The size is harder. I’m going to guess that any set of numbers separated by nothing except an
xcharacter will be the dimensions: