0
我嘗試使用ffmpeg爲VHS備份編寫簡單的轉碼腳本。但是我無法處理文件名中的空格。bash中ffmpeg的文件名空間
我在腳本中一起構建了我的ffmpeg命令並對其進行了回顯,並且在複製時粘貼了它的回顯命令,但並非直接來自腳本。
有沒有一個想法我的腳本怎麼了?
腳本:
#!/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