対応するファイルまたはディレクトリエラーはありません。

対応するファイルまたはディレクトリエラーはありません。

私が作成しているシェルスクリプトは次のとおりです。

#FOR YOUTUBE-DL COMMAND
read -r -p "Do you want to download a link? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
    read -e -p "Enter Youtube link: " youtube_link
    youtube-dl $youtube_link -o "/home/tex/catkin_ws/youtube_videos/%(title)s%(ext)s" -f mp4
fi

#FOR FFMPEG COMMAND 
read -e -p "Enter video file dir: " video_dir
video_dir="${video_dir/#\~/$HOME}"
echo $video_dir
read -e -p "Enter fps: " fps
read -e -p "Enter video file image destination: " image_destination
image_destination="${image_destination/#\~/$HOME}"
image_format="image-%04d.jpeg"
image_destination=$(echo ${image_destination}${image_format})   
ffmpeg -i $video_dir -r $fps $image_destination

簡単です。いくつかのコマンドを繰り返し作成するのではなく、自動化したいだけです。

しかし、奇妙なエラーが発生します。これは私の最初のシェルスクリプトなので、何が間違っているのかわかりません。

最後の行に達すると:

ffmpeg -i $video_dir -r $fps $image_destination

$video_dirffmpegコマンドに問題があります。まず、私は:

echo $video_dir13行目で私は以下を得る:

/home/usr/ws/youtube_videos/AIRSOFT - 4 Player Split Screenmp4

しかし、

ffmpegはエラーを返します:

/home/usr/ws/youtube_videos/AIRSOFT: No such file or directory

これは最初の部分(AIRSOFT)のみを読み、残りの部分(AIRSOFT - 4....)は読み取らないのと同じです。

理由がありますか?

ベストアンサー1

Bashは、ファイル名の残りの部分にスペースを使用する方法を知りません。 Bashがフルファイル名を使用するように指定(エスケープ)する必要があります。

だからあなたはできます

  1. 「AIRSOFT - 4 Player Split Screen.mp4」を「AIRSOFT\ -\ 4 \ Player Split \ Screen.mp4」に変更します。
  2. 引用符を追加します$video_dir。 (?)
  3. bashが簡単に解析できるように、ファイル名をスペースなしで別の名前に変更します。

あなたの場合は、3番目のオプションが最も簡単です。

おすすめ記事