简体   繁体   中英

How to set audio format from an ffmpeg filter?

Is it possible to set the audio format just with an ffmpeg filter?

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. -f needs to be set for output file format.

The aformat filter deals only with format of audio samples in a frame, and not with output file format.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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