Vadim Kantorov
Vadim Kantorov

Reputation: 1144

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'

Upvotes: 0

Views: 1268

Answers (1)

Gyan
Gyan

Reputation: 93221

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.

Upvotes: 1

Related Questions