I believe that can be achieved with [ffprobe][1]. 

You can see example of getting json format from it [here][2]


  [1]: https://www.ffmpeg.org/ffprobe.html
  [2]: http://stackoverflow.com/questions/7708373/get-ffmpeg-information-in-friendly-way