我有一个这样的输出字符串
ffmpeg version 0.8.8-4:0.8.8-0ubuntu0.12.04.1, Copyright (c) 2000-2013 the Libav developers
built on Oct 22 2013 12:31:55 with gcc 4.6.3
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
[flv @ 0x23307a0] Estimating duration from bitrate, this may be inaccurate
Seems stream 0 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 25.00 (25/1)
Input #0, flv, from '307263_191.flv':
Metadata:
metadatacreator : Yet Another Metadata Injector for FLV - Version 1.4
hasKeyframes : true
hasVideo : true
hasAudio : true
hasMetadata : true
canSeekToEnd : true
datasize : 42773717
videosize : 40350092
audiosize : 2403669
lasttimestamp : 107
lastkeyframetimestamp: 107
lastkeyframelocation: 42758866
Duration: 00:01:47.18, start: 0.000000, bitrate: 3186 kb/s
Stream #0.0: Video: flv, yuv420p, 1024x576, 3009 kb/s, 25 tbr, 1k tbn, 1k tbc
Stream #0.1: Audio: adpcm_swf, 22050 Hz, 2 channels, s16, 176 kb/s
At least one output file must be specified
我必须从字符串中获取一些信息,例如持续时间、视频比特率、音频比特率以及视频和音频的大小。一种方法是用explode来做,但是字符串的重要部分之前和之后的文本不在我的控制范围内,并且可能会在每个输入上发生变化
有什么方法可以匹配字符串中的任何键和值:
更新:我需要这些
videosize : 40350092
audiosize : 2403669
Duration: 00:01:47.18
和
Stream #0.0: Video: flv, yuv420p, 1024x576, 3009 kb/s, 25 tbr, 1k tbn, 1k tbc
Stream #0.1: Audio: adpcm_swf, 22050 Hz, 2 channels, s16, 176 kb/s