这是打印视频的帧速率的bash脚本,它所需的参数可能包含空格。这个参数也将被用在脚本内的命令中。bash |在转义空间时为变量分配参数
#!/bin/bash
inputVid="$*"
#checking if $inputVid has full path
echo $inputVid
frames=`ffmpeg -i $inputVid 2>&1 | sed -n "s/.*, \(.*\) fp.*/\1/p"`
echo $frames
当我执行
$./frameRate.sh ../Downloads/FlareGet/Videos/Why\ .mp4
输出为:
../Downloads/FlareGet/Videos/Why .mp4
这样的文件名是越来越正确传递,但空间没有得到来自FFmpeg的
被转义,因此没有输出有什么办法解决这个问题?
用双引号括起文件名? – codeforester
@codeforester我也将从另一个python脚本作为变量传递参数,所以引用文件名不是我的选择! –