YUv-使用Shell脚本将文件转换为YUV-图像

时间:2016-03-17 14:26:45

标签: bash shell

我想用这个shellcript将yuv-Sequence分成单个图像:

#!/bin/bash
# Input Parameter: YUV-Sequenz
FILESIZE=22118400 # size of a single image
NUMIM=10 # number of images in input file
for i in `seq 0 $(($NUMIM-1))`
do   
  dd if=$1 skip=$((i*FILESIZE)) bs=$FILESIZE count=1 of=$1.frame$i.yuv
done

我总是收到这个错误:

dd: invalid number ‘’

你能告诉我我做错了吗?

1 个答案:

答案 0 :(得分:0)

尝试使用echo运行循环,看看它是否正确:

FILESIZE=22118400
NUMIM=10
for i in `seq 0 $(($NUMIM-1))`; do
    echo "dd if=$1 skip=$((i*FILESIZE)) bs=$FILESIZE count=1 of=$1.frame$i.yuv"
done

将打印:

dd if= skip=0 bs=22118400 count=1 of=.frame0.yuv
dd if= skip=22118400 bs=22118400 count=1 of=.frame1.yuv
dd if= skip=44236800 bs=22118400 count=1 of=.frame2.yuv
dd if= skip=66355200 bs=22118400 count=1 of=.frame3.yuv
dd if= skip=88473600 bs=22118400 count=1 of=.frame4.yuv
dd if= skip=110592000 bs=22118400 count=1 of=.frame5.yuv
dd if= skip=132710400 bs=22118400 count=1 of=.frame6.yuv
dd if= skip=154828800 bs=22118400 count=1 of=.frame7.yuv
dd if= skip=176947200 bs=22118400 count=1 of=.frame8.yuv
dd if= skip=199065600 bs=22118400 count=1 of=.frame9.yuv

这看起来不正确。您的意思是$i不是$1吗?