I have a .bash_profile script that uses FFMPEG to create a ProRes file from an image sequence. The name of the FFMPEG output file is taken from the current working directory. I'm fine taking the name from the parent directory because After Effects is set to create a folder for each image sequence render that has the same the name as the sequence.
This works fine if there's no spaces in the name. Example: My_Movie/My_Movie_00001.tif
, etc gives me My_Movie_ProRes.mov
But I'd like to have it also work for folders with spaces in the name. I've tried adding quotes to various places but it just either fails or outputs as _ProRes.mov with no folder name at all.
pro () {
OUTPUT_NAME=${PWD##*/}
local fps=24;
local filename="${OUTPUT_NAME}"_ProRes.mov;
local ext=tif;
while test $# -gt 0; do
case "$1" in
-fps)
shift
fps=$1
shift
;;
-filename)
shift
filename=$1
shift
;;
-quality)
shift
quality=$1
shift
;;
*)
echo "$1 is not a recognized flag!"
return 0;
;;
esac
done
/usr/local/bin/ffmpeg -r $fps \
-f image2 -pattern_type glob \
-i "*?$ext" \
-codec:v prores_ks \
-pix_fmt yuva444p10le \
-vf scale=out_color_matrix=bt709 \
-profile:v 4444 \
$filename
}
SUCCESS! Thanks for your insight, especially John1024 and Jesse_b!
pro () {
OUTPUT_NAME="${PWD##*/}"
local fps=24;
local filename="${OUTPUT_NAME}"_ProRes.mov;
local ext=tif;
while test $# -gt 0; do
case "$1" in
-fps)
shift
fps=$1
shift
;;
-filename)
shift
filename=$1
shift
;;
*)
echo "$1 is not a recognized flag!"
return 0;
;;
esac
done
/usr/local/bin/ffmpeg -r $fps \
-f image2 -pattern_type glob \
-i "*?$ext" \
-codec:v prores_ks \
-pix_fmt yuva444p10le \
-vf scale=out_color_matrix=bt709 \
-profile:v 4444 \
"$filename"
}
$filename
with"$filename"
. Also, whenever you have a shell script error, a good first step is to cut and paste your code into shellcheck.net and correct the errors (important) and warnings (might be important) that it identifies. If you have trouble understanding its messages, then come here and ask. – John1024 Sep 27 '19 at 17:52OUTPUT_NAME=${PWD##*/}
line the following:echo "OUTPUT_NAME is: $OUTPUT_NAME"
– jesse_b Sep 27 '19 at 18:05bash -x scriptname
which will print debugging info so that you can see exactly where the code went wrong. – John1024 Sep 27 '19 at 18:06set -x; pro ...
. Thenset +x
to disable debugging. – jesse_b Sep 27 '19 at 18:08echo "OUTPUT_NAME is: $OUTPUT_NAME"
. same result :( – markpaterson Sep 27 '19 at 18:08OUTPUT_NAME
is not being set at all you might have a syntax error in your actual code that is not reflected here. – jesse_b Sep 27 '19 at 18:09+ pro
+ 'OUTPUT_NAMEMy Movie v4'
-bash: OUTPUT_NAMEMy Movie v4: command not found
+ local fps=24
+ local filename=_ProRes.mov
+ local ext=tif
+ test 0 -gt 0
+ /usr/local/bin/ffmpeg -r 24 -f image2 -pattern_type glob -i '*?tif' -codec:v prores_ks -pix_fmt yuva444p10le -vf scale=out_color_matrix=bt709 -profile:v 4444 _ProRes.mov
– markpaterson Sep 27 '19 at 18:16=
betweenOUTPUT_NAME
and${PWD##*/}
. You wrote this in a comment above but I assumed it was just a typo. It's very important that you paste your code into the question exactly as it is being run for us to help you. – jesse_b Sep 27 '19 at 18:16