Gwynn
Gwynn

Reputation: 43

Expanding variables in an ffmpeg command

I'm trying to pass codecs to ffmpeg via variables in a bash script, such as

VIDEO='libvpx-vp9'
AUDIO='libopus'

ffmpeg -i name.ext \
-c:v "$VIDEO" \
-c:a "$AUDIO" \
name.webm

But if I try to pass any options for the codecs, such as

AUDIO='libopus -ac 1 -b:a 32k'

It throws this error:

Unknown encoder 'libopus -ac 1 -b:a 32k'

How do I pass codecs + their options to ffmpeg?

Upvotes: 4

Views: 1150

Answers (1)

Raptor
Raptor

Reputation: 54212

As mentioned in the comment above, since the command should be:

 ffmpeg -i name.ext -c:v libvpx-vp9 -c:a libopus -ac 1 -b:a 32k name.webm

The double quotes should be removed:

VIDEO='libvpx-vp9'
AUDIO='libopus -ac 1 -b:a 32k'

ffmpeg -i name.ext \
-c:v $VIDEO \
-c:a $AUDIO \
name.webm

Upvotes: 2

Related Questions