使用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

 这个可以了。

感谢

 

出处:http://www.cnblogs.com/farewell-farewell/p/6111756.html

posted on   jack_Meng  阅读(5554)  评论(0编辑  收藏  举报

编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
历史上的今天:
2015-03-13 学习动态性能表(22)V$resource_limit
2015-03-13 学习动态性能表(21)v$lincense
2015-03-13 学习动态性能表(20)--v$waitstat
2015-03-13 学习动态性能表(19)--v$undostat
2015-03-13 学习动态性能表(18)--v$system_event
2015-03-13 学习动态性能表(17)--v$segstat&v$segment_statistics
2015-03-13 学习动态性能表(16)--v$rowcache

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示

喜欢请打赏

扫描二维码打赏

支付宝打赏

主题色彩