1
我不知道用我的bash腳本來選擇命令的數組。在bash腳本中輸入命令選項的數組輸出
我使bash腳本從mkv文件中提取附件,並在最後在視頻/音頻編碼後再次將附件合併到mkv文件。
這是提取附件
#find the total of attachment
A=$(mkvmerge -i input.mkv | grep -i attachment
| awk '{printf $3 "\n"}'
| sed 's;\:;;'
| awk 'END { print NR }')
#extract it
for ((i=1; i<=$A; i++))
do
font[${i}]="$(mkvmerge -i input.mkv | grep -i attachment
| awk '{for (i=11; i <= NF; i++) printf($i"%c" , (i==NF)?ORS:OFS) }'
| sed "s/'//g"
| awk "NR==$i")"
mkvextract attachments input.mkv $i:"${font[${i}]}"
done
現在的合併再次附着
for ((i=1; i<=$A; i++))
do
#seach for space between file name and and '\' before
#the space because some attachment has space in filename
font1[${i}]=$(echo ${font[${i}]} | sed 's/ /\\ /g')
#make option for add attachment
attachment[${i}]=$"--attach-file ${font1[${i}]}"
done
mkvmerge -o output.mkv -d 1 -S test.mp4 sub.ass ${attachment[*]}
的問題,仍然無法爲文件名與空間工作。 當我試圖呼應${attachment[*]}
,似乎沒事
--attach-file Beach.ttf --attach-file Candara.ttf
--attach-file CASUCM.TTF
--attach-file Complete\ in\ Him.ttf
--attach-file CURLZ_.TTF
--attach-file Frostys\ Winterland.TTF
--attach-file stilltim.ttf
但產量仍然承認的文件名與空間只有第一個字。
mkvmerge v3.0.0 ('Hang up your Hang-Ups') built on Dec 6 2010 19:19:04
Automatic MIME type recognition for 'Beach.ttf': application/x-truetype-font
Automatic MIME type recognition for 'Candara.ttf': application/x-truetype-font
Automatic MIME type recognition for 'CASUCM.TTF': application/x-truetype-font
Error: The file 'Complete\' cannot be attached because it does not exist or cannot be read.
感謝簡化了劇本,但對於A = $(-i了mkvmerge輸入.mkv | WC-1),你缺少的grep -i附件,整條生產線應該是A = $(了mkvmerge - 我輸入.mkv | grep -i附件| wc -l) – dewaforex 2011-03-03 07:21:23
@dewaforex:哎呀,對不起。我過分熱心了。 – 2011-03-03 07:23:39
不,問題。現在它更簡單了,但仍然無法弄清楚當把雙重qoute放在Ignacio的回答指向的「$ {attachment [*]}」時的最後一個錯誤 – dewaforex 2011-03-03 07:36:00