私はffmpegを使ってVHSバックアップ用の簡単なトランスコーディングスクリプトを書こうとしています。しかし、私はファイル名のスペースを扱わない。bashのffmpegのファイル名のスペース
私はffmpegコマンドをスクリプトに組み込んでエコーし、エコーされたコマンドをコピーして貼り付けると、それは動作しますが、スクリプトからはdiretclyではありません。
私のスクリプトには何の問題がありますか?
スクリプト:
#!/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
スクリプトを呼び出す:
./VHStoMP4Backup.sh /Volumes/Data/oliver/Video/RAW\ Aufnahmen/Ewelina\ -\ Kasette\ 1.dv ewe.mp4
コマンドライン出力
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
参照http://stackoverflow.com/questions/12136948/in-bash-why-do-shell-commands-ignore-quotes-in-arguments-when-the-引数は〜です – tripleee