我試圖用ffmpeg來獲取視頻的尺寸。我用命令ffprobe video.mov
得到以下數據:管道和正則表達式bash輸入
ffprobe version 1.0 Copyright (c) 2007-2012 the FFmpeg developers
built on Jan 14 2013 10:18:07 with Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/1.0 --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --cc=cc --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
libavutil 51. 73.101/51. 73.101
libavcodec 54. 59.100/54. 59.100
libavformat 54. 29.104/54. 29.104
libavdevice 54. 2.101/54. 2.101
libavfilter 3. 17.100/3. 17.100
libswscale 2. 1.101/2. 1.101
libswresample 0. 15.100/0. 15.100
libpostproc 52. 0.100/52. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'linebubble.mov':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2013-03-12 02:59:34
Duration: 00:00:14.05, start: 0.050000, bitrate: 135 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1/0x31637661), yuv420p, 502x288 [SAR 1:1 DAR 251:144], 137 kb/s, 7.84 fps, 60 tbr, 6k tbn, 12k tbc
Metadata:
creation_time : 2013-03-12 02:59:34
handler_name : Core Media Data Handler
現在我要管的是成正則表達式只得到502x288在第四最後一行。
我已經看到了一些python和perl的解決方案,但我希望這是純粹的bash。我將如何去做這件事?
'grep | awk'是grep的無用之處。更好地使用'awk'/ Stream/{print $ 10}'' – 2013-03-12 14:49:55
@sputnick是的,這也可以。 – trojanfoe 2013-03-12 14:50:17
這仍然顯示我沒有過濾任何它的所有信息http://wes.io/NVsY – wesbos 2013-03-12 15:59:51