Trying to use simple variables with my bash script for ffmpeg but getting errors
This line:
STREAM=-f flv \"rtmps://live-api-s.facebook.com:443/rtmp/xxx\"
tries to run flv \"rtmps://live-api-s.facebook.com:443/rtmp/xxx\"
with STREAM
environment variable set to -f
. Didn't you get bash: flv: command not found
?
Compare STREAM=-f env
.
The variable is not set for the current shell and $STREAM
expands to an empty string later. But even if you did:
# but don't
STREAM='-f flv "rtmps://live-api-s.facebook.com:443/rtmp/xxx"'
it wouldn't work. Unquoted $STREAM
later undergoes word splitting and filename generation and quotes that appear from variable expansion are not special to the shell that expanded the variable.
See this: How can we run a command stored in a variable? In your case a solution with an array is like:
STREAM=(-f flv "rtmps://live-api-s.facebook.com:443/rtmp/xxx")
ffmpeg … "${STREAM[@]}"
Also consider lowercase names for variables.