简体   繁体   English

如何从 ffmpeg 过滤器设置音频格式?

[英]How to set audio format from an ffmpeg filter?

Is it possible to set the audio format just with an ffmpeg filter?是否可以仅使用 ffmpeg 过滤器设置音频格式?

My usecase is programmatic usage, so if it's possible to do with filters, that would simplify everything.我的用例是编程使用,所以如果可以使用过滤器,那将简化一切。

# create sample s16 audio
ffmpeg -f lavfi -i "sine=frequency=1000:duration=5" -c:a pcm_s16le -ar 8000 test.wav

# works
ffmpeg -i test.wav -y -af 'aresample=osf=flt,aformat=sample_fmts=flt' -f f32le test_f32.raw

# fails
ffmpeg -i test.wav -y -af 'aresample=osf=flt,aformat=sample_fmts=flt' test_f32.raw
# [NULL @ 0x56042863d980] Unable to find a suitable output format for 'test_f32.raw'

Your 'works' command is how it should be done.您的“工作”命令是应该如何完成的。 .raw is not a generic extension so ffmpeg can't guess the format you want. .raw不是通用扩展名,因此 ffmpeg 无法猜测您想要的格式。 -f needs to be set for output file format. output文件格式需要设置-f

The aformat filter deals only with format of audio samples in a frame, and not with output file format. aformat 过滤器仅处理帧中音频样本的格式,而不处理 output 文件格式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM