1

这是我的 shell 脚本,但它给出了错误:

#!/bin/sh

while getopts "i:o:" flag
do
   case $flag in
   i) file_input=$OPTARG
   ;;
   o) file_output=$OPTARG
   ;;
   esac
done

mplayer -nosound -benchmark -vo yuv4mpeg:file=>(x264 --demuxer y4m \
              --crf 20 --threads auto --output $file_output - ) $file_input

错误信息是:

无法获取要写入的内存或文件句柄 ">(x264 --demuxer y4m --crf 20 --threads auto --output video.264 - )"!致命:无法初始化视频驱动程序。

当我在腻子上运行这个 cmd 时:

mplayer -nosound -benchmark -vo yuv4mpeg:file=>(x264 --demuxer y4m \
              --crf 20 --threads auto --output video.264 - ) video.wmv

它完美地工作..

我究竟做错了什么?

4

3 回答 3

4

您正在使用的命令使用复杂的 bash管道流到子外壳语法,即>()实现您想要的。可能你的/bin/sh(你在shebang中作为这个脚本的shell调用)与你交互使用的shell(即bash)不同?

于 2011-01-21T13:35:30.920 回答
1

进程替换运算符是特定于>(...)Bash 的。如果 Bash 被称为 as ,它也不可用/bin/sh,因为在这种情况下,Bash 将自己限制在其功能的更兼容的子集上。

只需在脚本开头使用#!/bin/bash而不是。#!/bin/sh

于 2011-01-21T13:38:23.307 回答
0

我建议你添加一些'来保护你的特殊字符:

mplayer -nosound -benchmark -vo 'yuv4mpeg:file=>(x264 --demuxer y4m --crf 20 --threads auto --output $file_output - )' $file_input
于 2011-01-21T13:37:56.170 回答