zoukankan      html  css  js  c++  java
  • 使用ffmpeg录音

    官方教程:http://ffmpeg.org/ffmpeg.html

    录音方法:

    开始找到了这个方法,但是不行呀,好像是没有这个oss吧。

    oss 是linux 下的声音相关的东西,与alsa 一样,不过oss 是商业的, 而/dev/dsp 是oss 用到的麦克的设备吧

    ffmpeg -f oss -i /dev/dsp wheer.mp3
    
    ffmpeg -f oss -i /dev/dsp -ar 8000 -ab 10200 wheer.amr

    采用 alsa-oss 录制,就可以啦

    ffmpeg -f alsa -ac 2 -i hw:0,0 out.mp3
    
    ffmpeg -f alsa -ac 2 -i hw:0,0 out.wav

    科大讯飞的合成或者识别,保存成的音频文件格式是16k或者8k,16bit,单声道pcm格式的音频。采用以下方式录音

     ffmpeg -f alsa  -ar 16000 -ac 1 -i hw:0 lib.wav

    q——停止

    但是 我使用以上命令时,提示说

    cannot set channel count to 1 (Invalid argument)
    hw:0: Input/output error

    最后查阅资料,发现以下参数设置:

    -ab bitrate 设置音频码率
    
    -ar freq 设置音频采样率
    
    -ac channels 设置通道 缺省为1
    
    -an 不使能音频纪录
    
    -acodec codec 使用codec编解码

    如此按理说,去掉 -ac通道设置即可,运行以下命令:

     ffmpeg -f alsa  -ar 16000 -i hw:0 lib.wav
    -acodec pcm_s16le

    但还是无法识别,最后问了一下,是这样录音的:
    ffmpeg -y -f alsa -i pluse -t 00:00:06 -ar 16000 -ac 1 lib.wav

    其中

    -y (global)
      Overwrite output files without asking.
    
    -f fmt (input/output)
       Force input or output file format. The format is normally auto detected for input files and guessed from the file extension
       for output files, so this option is not needed in most cases.
    
    -i url (input)
       input file url
    
    -t duration (input/output)
    
       When used as an input option (before -i), limit the duration of data read from the input file.
    
       When used as an output option (before an output url), stop writing the output after its duration reaches duration.
    
       duration must be a time duration specification, see (ffmpeg-utils)the Time duration section in the ffmpeg-utils(1) manual.
    
       -to and -t are mutually exclusive and -t has priority.

    //试试改改他的用法
    ffmpeg -y -f alsa -i hw:0 -t 00:00:06 -ar 16000 -ac 1 lib.wav

     这个可以了。

    感谢

  • 相关阅读:
    POJ3189 Steady Cow Assignment(二分图多重匹配)
    POJ2112 Optimal Milking(二分图多重匹配)
    POJ2289 Jamie's Contact Groups(二分图多重匹配)
    安装jhipster
    AngularJS版本下载
    业务平台技术架构一些注意事项
    反向数据库表
    近期需要关注的内容
    一些不太常见但很有用的java类
    文件复制
  • 原文地址:https://www.cnblogs.com/farewell-farewell/p/6111756.html
Copyright © 2011-2022 走看看