I try to write a simple transcoding script for VHS backups with ffmpeg. But I fail to handle spaces in filenames.
I build my ffmpeg command together in the script and echo it and when I copy paste the echoed command it works, but not diretcly from the script.
Has anayone a idea whats wrong with my script?
Script:
#!/bin/bash
# VHStoMP4Backup Script
INPUT=$1
OUTPUT="/Volumes/Data/oliver/Video/Encodiert/${2}"
command="ffmpeg \
    -i \"$INPUT\" \
    -vcodec copy \
    -acodec copy \
    \"$OUTPUT\""
if [ ! -z "$1" ] && [ ! -z "$2" ] ;
then
    echo ${command}$'\n'
    ${command}
else
    echo "missing parameters"
    echo "Usage: script INPUT_FILENAME OUTPUT_FILENAME"
fi
exit
Script calling:
./VHStoMP4Backup.sh /Volumes/Data/oliver/Video/RAW\ Aufnahmen/Ewelina\ -\ Kasette\ 1.dv ewe.mp4
Commandline output
olivers-mac-pro:Desktop oliver$ ./VHStoMP4Backup.sh /Volumes/Data/oliver/Video/RAW\ Aufnahmen/Ewelina\ -\ Kasette\ 1.dv ewe.mp4
    ffmpeg -i "/Volumes/Data/oliver/Video/RAW Aufnahmen/Ewelina - Kasette 1.dv" -vcodec copy -acodec copy "/Volumes/Data/oliver/Video/Encodiert/ewe.mp4"
    ffmpeg version git-2016-04-16-60517c3 Copyright (c) 2000-2016 the FFmpeg developers
      built with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
      configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-libfreetype --enable-libvorbis --enable-libvpx --enable-librtmp --enable-libfaac --enable-libass --enable-libssh --enable-libspeex --enable-libfdk-aac --enable-openssl --enable-libopus --enable-libvidstab --enable-libx265 --enable-nonfree --enable-vda
      libavutil      55. 22.100 / 55. 22.100
      libavcodec     57. 34.102 / 57. 34.102
      libavformat    57. 34.101 / 57. 34.101
      libavdevice    57.  0.101 / 57.  0.101
      libavfilter     6. 42.100 /  6. 42.100
      libavresample   3.  0.  0 /  3.  0.  0
      libswscale      4.  1.100 /  4.  1.100
      libswresample   2.  0.101 /  2.  0.101
      libpostproc    54.  0.100 / 54.  0.100
    "/Volumes/Data/oliver/Video/RAW: No such file or directory
 
    