So i've written a bash script to take newly written to video files and transcode them for playback and streaming in my server here is the script
while true; do
printf -v filename '%q' "$(inotifywait --format "%w""%f" -r -e close_write /var/$
echo $filename
if [[ $filename == *".mp4"* ]]; then
echo "1"
avconv -i "$filename" "`echo ${filename%.mp4}.webm`"
fi
if [[ $filename == *".mkv"* ]]; then
echo "2"
avconv -i "$filename" "`echo ${filename%.mkv}.mp4`"
avconv -i "$filename" "`echo ${filename%.mkv}.webm`"
fi
if [[ "$filename" == *".avi"* ]]
then echo "3"
avconv -i "$filename" "`echo ${filename%.avi}.mp4`" &
avconv -i "$filename" "`echo ${filename%.avi}.webm`"&
fi
done
The script works fairly well however if the $filename contains spaces avconv breaks and the script returns:
Watches established.
/var/www/media2net/tv/The\ Daily.mkv
2
avconv version 0.8.4-4:0.8.4-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav s
built on Nov 6 2012 16:51:33 with gcc 4.6.3
/var/www/media2net/tv/The\: No such file or directory
avconv version 0.8.4-4:0.8.4-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav
built on Nov 6 2012 16:51:33 with gcc 4.6.3
/var/www/media2net/tv/The\ Daily.mkv: No such file or directory
Setting up watches. Beware: since -r was given, this may take a while!
Watches established.
however this is not correct as I can view the said file inside it's respective directory, I also have tested avconv with the following in the shell and everything works properly and avconv transcodes video
avconv -i /var/www/media2net/The\ Daily.mkv /var/www/media2net/tv/The\ Daily.webm
Basically I am wondering what I am doing wrong in my script or if anyone else has experienced a similar problem using avconv or ffmpeg (as the 2 are fairly similar and avconv is ubuntu's fork of the project) any help would be greatly appreciated! Thanks in advance -brendan