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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM