Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expanding variables in an ffmpeg command

Tags:

bash

ffmpeg

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?

like image 295
Gwynn Avatar asked Sep 18 '25 04:09

Gwynn


1 Answers

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
like image 120
Raptor Avatar answered Sep 20 '25 18:09

Raptor