gpt4 book ai didi

regex - Grep 获取某个范围内的数字 - 检查 WAV 质量

转载 作者:行者123 更新时间:2023-12-03 02:09:48 25 4
gpt4 key购买 nike

我正在尝试编写一个正则表达式(与 ffmpeg 结合使用,它可以检查 WAV 文件是否超过一定质量。

最小值应该是:

音频 channel : 2(立体声)
音频采样率: 44,100 赫兹
音频比特率: 1411 Kbps
音频位深度: 16 位

所以到目前为止我已经尝试了以下命令:

  • /usr/local/bin/ffmpeg -i "/path/to/file.wav" 2>&1 | egrep 'stereo|2 channels'

  • 这可以很好地获得立体声(2 声道)WAV。我在下一部分遇到问题,在一系列数字之间进行搜索。
  • /usr/local/bin/ffmpeg -i "/path/to/file.wav" 2>&1 | egrep 'stereo|2 channels' | egrep '[41000-196000] Hz'

  • 显然,这只是单独搜索每个数字,所以如果有 4 OR 1 OR 0 OR 0 OR 0 等,它就会找到结果......

    比特率和比特深度只需分别超过 1411 和 16。

    谢谢

    编辑-
    这是应拒绝的低质量 WAV 的 ffmpeg 输出:
    ffmpeg version git-2012-05-22-27127eb Copyright (c) 2000-2012 the FFmpeg developers
    built on May 22 2012 12:27:21 with gcc 4.6.1
    configuration: --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab
    libavutil 51. 53.100 / 51. 53.100
    libavcodec 54. 21.101 / 54. 21.101
    libavformat 54. 6.100 / 54. 6.100
    libavdevice 53. 4.100 / 53. 4.100
    libavfilter 2. 75.100 / 2. 75.100
    libswscale 2. 1.100 / 2. 1.100
    libswresample 0. 15.100 / 0. 15.100
    libpostproc 52. 0.100 / 52. 0.100
    [wav @ 0x355b140] max_analyze_duration 5000000 reached at 5056000
    Guessed Channel Layout for Input Stream #0.0 : stereo
    Input #0, wav, from '/path/to/file.wav':
    Duration: 00:02:28.47, bitrate: 512 kb/s
    Stream #0:0: Audio: pcm_u8 ([1][0][0][0] / 0x0001), 32000 Hz, stereo, u8, 512 kb/s

    最佳答案

    在你的 egrep 中试试这个:

    egrep '( 4[1-9][0-9][0-9][0-9] Hz| [5-9][0-9][0-9][0-9][0-9] Hz| 19[0-6][0-9][0-9][0-9] Hz| 1[0-8][0-9][0-9][0-9][0-9] Hz)'

    关于regex - Grep 获取某个范围内的数字 - 检查 WAV 质量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25202990/

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