0

I am trying to extract parameters from video files with ffprobe and process depding on these results. However i am not able to pass the files properly to ffprobe if they contain whitespaces.

echo $1

inputfile=$(printf '%q' "$1") #inputfile=${1@Q}

echo $inputfile

ffprobeout= ffprobe -v error -select_streams v:0 -show_entries stream=width,height,bit_rate -of csv=s=x:p=0 $inputfile

when i now call a smaple file with files2reenc.sh "test file with spaces.mp4" it results

test file with spaces.mp4
test\ file\ with\ spaces.mp4

Argument 'file' provided as input filename, but 'test' was already specified.

So ffprobe sees every part of the name as seperate file and does not recognize it as one parameter. I'm not sure how to pass/escape my input so it would work as expected. I'm not sure if the problem is already when invoking my bash script or with the way i try to handle input paramter. I also tried using echo $inputfile | xargs -0 ffprobe ... with no success.

2 Answers2

0

Thanks to rAlen for the quick hint - I needed to use the unchanged input and simply quote it.

inputfile=$1
ffprobeout= ffprobe -v error -select_streams v:0 -show_entries stream=width,height,bit_rate -of csv=s=x:p=0 "$inputfile"
0

apropos of nothing, line continuations can aid readability for long lines:

ffprobeout= ffprobe -v error \
                    -select_streams v:0 \
                    -show_entries stream=width,height,bit_rate \
                    -of csv=s=x:p=0 \
                    "$inputfile"
glenn jackman
  • 85,964