0

This works in command line for a sequence of jpg to convert to a video.

cat *.jpg  | ffmpeg -f image2pipe -framerate 5 -i - -s 1280x720  ./HD720_out.mp4    

but doesn't work (except for first jpg) in a executable script temp.sh containing:

eval  cat "$1"  | ffmpeg -f image2pipe -framerate 5 -i - -s 1280x720  "./HD720_out.mp4" 

e.g. ./temp.sh *.jpg gives only the first file to video, not the sequence. What am I doing wrong? The command line works perfectly.

HBruijn
  • 77,029
  • 24
  • 135
  • 201
Richard L
  • 33
  • 6

1 Answers1

2

Simplified: $1 gets expanded to the first commandline argument of a script.

But before your script interprets the shell running temp.sh will first expand the asterisk * in ./temp.sh *.jpg, effectively resulting a in a commandline:

./temp.sh first.jpg second.jpg third.jpg 
            \
             \_  $1

You have two options to get around this. The first (and preferred):

cat "$@" | ... 

will just use all command line paramters, not only the first one. You don't need eval for this one and shouldn't use it.

The second (where eval comes into play):

eval cat "$1"  |  

while calling the script with quoted parameters to avoid expansion:

 ./temp.sh '*.jpg' 
Sven
  • 98,649
  • 14
  • 180
  • 226
HBruijn
  • 77,029
  • 24
  • 135
  • 201