linux - bash 脚本中转义字符的问题

标签 linux bash ffmpeg

我对 bash 脚本真的很陌生,我正在尝试创建一个 shell 脚本来使用 cron 处理视频,但我真的不知道发生了什么

#!/bin/bash

args=("$@")
count=0
startingfrom=5

args1="-r 29.97 -t 00:13:30 -vsync 0 -vpre libx264-medium -i"
args2='-vf "[in] scale=580:380 [T1],[T1] pad=720:530:0:50 [out] "'
args12="-r 29.97 -ss 00:40:30 -vsync 0 -vpre libx264-medium -i"
args3="-vcodec libx264 -acodec libfaac"

for file in /home/allen/s/
do


eppart1 = "$args[0]_$startingfrom_01_01_02.mp4"
eppart2 = "$args[0]_$startingfrom_01_02_02.mp4"

/usr/local/bin/ffmpeg $args1 "$file"  $args2 $args3 "${args[0]}_${startingfrom}_01_01_02.mp4"

mv "${args[0]}_${startingfrom}_01_01_02.mp4" upload/

/usr/local/bin/ffmpeg $args12 "$file" $args2 $args3 "${args[0]}_${startingfrom}_01_02_02.mp4"

mv "${args[0]}_${startingfrom}_01_02_02.mp4" upload/



let "count += 1"
let "startingfrom +=1"
echo "$count"

echo ${args[0]}
echo ${args[1]}

done

/usr/local/bin/python2.5 /home/allen/s/process.py

问题始于此争论

args2='-vf "[in] scale=580:380 [T1],[T1] pad=720:530:0:50 [out] "'

我不知道是否是因为特殊字符,通常如果我输入整个命令它就可以工作,但在 bash 脚本中它是不同的

它给我的输出

Unable to find a suitable output format for 'scale=580:380'

尽管就像我说的,如果我运行整个命令它就会起作用

最佳答案

在将要执行的内容前面添加回显,这样您就可以看到将传递给命令的内容;

           something $args2

将扩展为

           something -vf "[in] scale=580:380 [T1],[T1] pad=720:530:0:50 [out] "

即使用两个参数调用某个东西,一个是一个选项(或 2 个选项),另一个是“单个”字符串;我想您不需要双引号。

关于linux - bash 脚本中转义字符的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5766121/

相关文章:

linux - WebDriverError错误: Chrome failed to start: exited abnormally

bash - 如何在 Bash 中重复一个字符?

bash - docker中的文件描述符重定向

FFMPEG 没有声音

php - 对操作系统进行编程以执行文件

linux - xwininfo 将选定的窗口置于最前面

python - Matplotlib 无法保存动画

android - 如何在 android 中使用 ffmpeg 从具有任何幻灯片效果(如淡入淡出、交叉淡入淡出、幻灯片)的图像创建视频

linux - kubernetes 和 cron 之间的关系

linux - 如何计算平面文件的单个列中每个术语的出现次数?