JulianJ
JulianJ

Reputation: 1315

Why isn't my bash script working?

I'm trying to get this bash script to work but am at a loss. I have a text file that contains a list of frame numbers line by line. ffmpeg reports the error:

Undefined constant or missing '(' in '$name)'

The script

#!/bin/bash
source text.txt
while read name
do
 ffmpeg -i result.mp4 -vf "setpts=N+1,select='eq(n,\$name)'" -vframes 1 frame-$i.jpg
done <text.txt

Upvotes: 1

Views: 152

Answers (1)

heemayl
heemayl

Reputation: 42017

You are escaping the $ before variable name i.e. $name, so the $name will be treated literally without any variable expansion being done.

Do:

ffmpeg -i result.mp4 -vf "setpts=N+1,select='eq(n,$name)'" -vframes 1 frame-$i.jpg

Upvotes: 2

Related Questions