I am trying to parse some output from the ffmpeg -i command. Some of the output may look like this:
libavutil 50. 8. 0 / 50. 8. 0
libavcodec 52.52. 0 / 52.52. 0
libavformat 52.50. 0 / 52.50. 0
libavdevice 52. 2. 0 / 52. 2. 0
libswscale 0.10. 0 / 0.10. 0
libpostproc 51. 2. 0 / 51. 2. 0
Input #0, avi, from '/my/folder/clip.mpeg':
Duration: 00:05:25.00, start: 0.000000, bitrate: 554 kb/s
Stream #0.0: Video: msvideo1, rgb555le, 160x100, 10 tbr, 10 tbn, 10 tbc
How can I parse out the bitrate value on the second last line? I cannot make a static parser that just picks the value at position x in the String because the output differs from time to time, so I have to make it dynamic in some way.
But how?
You can use regular expressions.
Try something like this :
More on Java and regular expressions : http://docs.oracle.com/javase/tutorial/essential/regex/