ffmpeg -i test.wav
input #0, wav, from 'test.wav': Duration: 00:00:16.31, bitrate: 256 kb/s Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 16000 Hz, mono, s16, 256 kb/s
ffmpeg -i examples_sample.wav
input #0, wav, from 'examples_sample.wav': Duration: 00:00:03.42, bitrate: 1572 kb/s Stream #0:0: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 65536 Hz, mono, s32 (24 bit), 1572 kb/s
参数简要说明-i
设定输入流-f
设定输出格式-ar
设定采样率-ac
设定声音的channel数-acodec
设定声音解码器
相同的输出设置:
ffmpeg命令行:ffmpeg -i example.wav -acodec pcm_s16le -ar 16000 -ac 1 out.wav
ffmpeg-python代码:
@R_419_5565@ ffmpeginput_file='./examples_sample.wav' # 'test.wav'( ffmpeg .input(input_file) .output('./testout1.wav',**{'ar':'16000','ac':'1','acodec':'pcm_s16le'}) .run())
aftertest.wav
似乎没什么变化..前后格式一致
input #0, wav, from './test.wav': Duration: 00:00:16.31, bitrate: 256 kb/s Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 16000 Hz, mono, s16, 256 kb/sStream mapPing: Stream #0:0 -> #0:0 (pcm_s16le (native) -> pcm_s16le (native))Press [q] to stop, [?] for helpOutput #0, wav, to './testout.wav': Metadata: ISFT : Lavf58.76.100 Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 16000 Hz, mono, s16, 256 kb/s Metadata: encoder : Lavc58.134.100 pcm_s16lesize= 510kB time=00:00:16.25 bitrate= 256.9kbits/s speed=1.07e+03xvIDeo:0kB audio:510kB subTitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.014943%
examples_sample.wav
可以观察到采样率有变化了... 文件大小位107kb
input #0, wav, from './examples_sample.wav': Duration: 00:00:03.42, bitrate: 1572 kb/s Stream #0:0: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 65536 Hz, mono, s32 (24 bit), 1572 kb/sStream mapPing: Stream #0:0 -> #0:0 (pcm_s24le (native) -> pcm_s16le (native))Press [q] to stop, [?] for helpOutput #0, wav, to './testout1.wav': Metadata: ISFT : Lavf58.76.100 Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 16000 Hz, mono, s16, 256 kb/s Metadata: encoder : Lavc58.134.100 pcm_s16lesize= 107kB time=00:00:03.42 bitrate= 256.3kbits/s speed= 252xvIDeo:0kB audio:107kB subTitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.071170%
改一下采样率为18000,可以发现文件大小为120kb,相同时间,更高的采样率,音频更大
stream = ffmpeg.input(input_file)#stream = ffmpeg.hflip(stream)stream = ffmpeg.output(stream, './testout2.wav',**{'ar':'18000','ac':'1','acodec':'pcm_s16le'})ffmpeg.run(stream)
run
input #0, wav, from './examples_sample.wav': Duration: 00:00:03.42, bitrate: 1572 kb/s Stream #0:0: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 65536 Hz, mono, s32 (24 bit), 1572 kb/sStream mapPing: Stream #0:0 -> #0:0 (pcm_s24le (native) -> pcm_s16le (native))Press [q] to stop, [?] for helpOutput #0, wav, to './testout2.wav': Metadata: ISFT : Lavf58.76.100 Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 18000 Hz, mono, s16, 288 kb/s Metadata: encoder : Lavc58.134.100 pcm_s16lesize= 120kB time=00:00:03.42 bitrate= 288.3kbits/s speed= 258xvIDeo:0kB audio:120kB subTitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.063262%
上面的内容,主要还是一些知识点整理和个人的一些思考,权当参考,如有错误或者更好的建议,可以在评论区指正,不胜感激!
总结以上是内存溢出为你收集整理的ffmpeg & ffmpeg-python 试用(音频)全部内容,希望文章能够帮你解决ffmpeg & ffmpeg-python 试用(音频)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)