Bash command syntax, help, input filename with spaces No such file or directory

Hello, i am having issue where i am running command:

echo "Input video filename or path to convert and hit enter:" 
read -r i 
echo "Quality: 25=identic, 30=a bit worse but small file size, or other numbers:" 
read -r q 
ffmpeg -vaapi_device /dev/dri/renderD128 -i "$i" -vf 'format=nv12,hwupload' -c:v hevc_vaapi -f mp4 -rc_mode 1 -qp "$q" "$i.hevc.mp4"

It asks to input the file name or path to file, i add it in various ways:

"/home/me/file name.mp4"
'/home/me/file name.mp4'
/home/me/file name.mp4
"file name.mp4"
file*

etc. but it always says: “…”: No such file or directory

yet. when i copy and paste the path it says does not exist and do stat or ls, it is found, so i really do not know how that command and input should look like?

When i rename the file to file.mp4, then the ffmpeg accept it. So what is the universal input format to use no matter which characters and spaces the file name contains?

GNU bash, version 5.1.0(1)-release (x86_64-pc-linux-gnu); Arch Linux

Before first echo add:

SAVEIFS=$IFS
IFS=$(echo -en "\n\b")

After last ffmpeg add:

IFS=$SAVEIFS

Does that helps?

It started working, i think it can also be about the quotation marks around the variables. Or trying with/out -r switch.


Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki