gpt4 book ai didi

macos - 管道和正则表达式 bash 输出

转载 作者:行者123 更新时间:2023-12-04 23:04:29 25 4
gpt4 key购买 nike

我正在尝试使用 ffmpeg 获取视频的尺寸。我使用命令 ffprobe video.mov获取以下数据:

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。我该怎么办?

最佳答案

你可以用 2 打方法做到这一点。这里是使用 grepawk :

ffprobe video.mov 2>&1 | grep 'Stream #0' | awk '{print $10}'

关于macos - 管道和正则表达式 bash 输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15364358/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com