0

When I run this like this, it works:

ffmpeg -re -y -i /home/video.webm -ss 2 \
-i /home/audio.ogg -map 0:0 -map 1:0  \
-c:v libx264 -preset veryfast -b:v 3000k -maxrate 3000k \
-bufsize 6000k -pix_fmt yuv420p -g 50 -c:a aac -b:a 160k -ac 2 -ar 44100 -async 1 \
-f flv "rtmps://live-api-s.facebook.com:443/rtmp/xxx"

However, when I introduce a variable I have a problem:

STREAM=-f flv \"rtmps://live-api-s.facebook.com:443/rtmp/xxx\"

ffmpeg -re -y -i /home/video.webm -ss 2 \
-i /home/audio.ogg -map 0:0 -map 1:0  \
-c:v libx264 -preset veryfast -b:v 3000k -maxrate 3000k \
-bufsize 6000k -pix_fmt yuv420p -g 50 -c:a aac -b:a 160k -ac 2 -ar 44100 -async 1 \
$STREAM

When I run this, I get:

At least one output file must be specified

I've tried a number of different ways of doing this, but they all have errors.

0

1 Answer 1

2

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .