トップ «前の日(07-03) 最新 次の日(07-05)» 追記

Masa's blog

検索キーワード:

2009年07月04日 DVD-VIDEO焼きスクリプト on Libretto U100

_ DVD-VIDEO焼きスクリプト on Libretto U100

念願のDVD-VIDEO焼きスクリプト完成。AUDIO_TSディレクトリ以下が空っぽは問題なかった。

dvd2dvd.sh

#! /bin/sh
if [ "X$1" = "X-h" -o "X$1" = "X--help" ]
then
    echo "Usage : dvd2dvd.sh [-sp speed] [-rw] [-2] [-s hh:mm:ss] [ -e hh:mm:ss] [-t title] [-c chapter] [-a aspect] [-vb vbitrate] [-ab abitrate] [-f fps] [-al audio_lang] [-sl subtitle_lang]"
    echo ""
    echo "  -sp speed           : write power (default 4)"
    echo "  -rw                 : DVD-RW"
    echo "  -2                  : 2-pass"
    echo "  -s start_time       : start position time"
    echo "  -e end_time         : pass time"
    echo "  -t title            : title number (default 1)"
    echo "  -c chapter          : chapter (default 1)"
    echo "  -a aspect           : aspect 16/9 or 4/3 (default 16/9)"
    echo "  -vb vbitrate        : video bitrate (kbit) (default 5000)"
    echo "  -ab abitrate        : audio bitrate (kbit) (default 192)"
    echo "  -f fps              : frame per second 30000/1001 or 24000/1001 (default 30000/1001)"
    echo "  -al audio_lang      : audio language (default ja,en)"
    echo "  -ai audio_id        : audio id"
    echo "  -sl subtitle_lang   : subtitle language (default none)"
    echo "  -si subtitle_id     : subtitle id "
    exit 0
fi
#
speed="4"
rw=no
pass="1"
start=""
end=""
title="1"
chapter="1"
aspect=16/9
vbitrate=5000
abitrate=192
ofps=30000/1001
alang="ja"
aid=""
slang=""
sid=""
#
while [ $# != 0 ]
do
    case $1 in
    -sp )
        shift
        speed="$1"
        ;;
    -rw )
        rw=yes
        ;;
    -2 )
        pass=2
        ;;
    -s )
        shift
        start="-ss $1"
        ;;
    -e )
        shift
        end="-endpos $1"
        ;;
    -t )
        shift
        title="$1"
        ;;
    -c )
        shift
        chapter="$1"
        ;;
    -a )
        shift
        aspect=$1
        ;;
    -vb )
        shift
        vbitrate="$1"
        ;;
    -ab )
        shift
        abitrate="$1"
        ;;
    -f )
        shift
        ofps="$1"
        ;;
    -al )
        shift
        alang="$1"
        ;;
    -ai )
        shift
        aid="$1"
        ;;
    -sl )
        shift
        slang="$1"
        ;;
    -si )
        shift
        sid="$1"
        ;;
    esac
    shift
done
#
if [ "X${alang}" = "X" ]
then
    alang_opt=""
else
    alang_opt="-alang ${alang}"
fi
#
if [ "X${aid}" = "X" ]
then
    aid_opt=""
else
    aid_opt="-aid ${aid}"
fi
#
if [ "X${slang}" = "X" ]
then
    slang_opt=""
else
    slang_opt="-slang ${slang}"
fi
#
if [ "X${sid}" = "X" ]
then
    sid_opt=""
else
    sid_opt="-sid ${sid}"
fi
#
function menc() {
	pass=$1
	filename=$2

	if [ "X${pass}" = "X0" ]
	then
		vpass=""
	else
		vpass="vpass=${pass}:"
	fi

	mencoder dvd://${title} -chapter ${chapter} \
		${start} ${end} \
		${alang_opt} ${aid_opt} \
		${slang_opt} ${sid_opt} \
		-oac lavc \
		-ovc lavc \
		-of mpeg \
		-mpegopts format=dvd:tsaf \
		-vf scale=720:480,harddup \
		-srate 48000 \
		-af lavcresample=48000 \
		-lavcopts ${vpass}vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=${vbitrate}:keyint=18:vstrict=0:acodec=ac3:abitrate=${abitrate}:aspect=${aspect} \
		-ofps ${ofps} \
		-o ${filename}
}
#
if [ "X${pass}" = "X1" ]
then
	menc 0 dvd2dvd.mpg.tmp
else
	menc 1 /dev/null
	menc 2 dvd2dvd.mpg.tmp
fi
#
cat >dvd2dvd.xml.tmp <<_EOF_
<dvdauthor>
    <vmgm />
    <titleset>
        <titles>
            <pgc>
                <vob file="dvd2dvd.mpg.tmp" chapters="0,5:00,10:00,15:00,20:00,25:00,30:00,35:00,40:00,45:00,50:00,55:00,1:00:00,1:05:00,1:10:00,1:15:00,1:20:00,1:25:00,1:30:00,1:35:00,1:40:00,1:45:00,1:50:00,1:55:00,2:00:00,2:05:00,2:10:00,2:15:00,2:20:00,2:25:00,2:30:00,2:35:00,2:40:00,2:45:00,2:50:00,2:55:00,3:00:00" />
            </pgc>
        </titles>
    </titleset>
</dvdauthor>
_EOF_
dvdauthor -o dvd2dvd.dir.tmp -x dvd2dvd.xml.tmp
#
mkisofs -o dvd2dvd.img.tmp -dvd-video dvd2dvd.dir.tmp/
#
eject /dev/dvd
echo ""
echo ================================================
echo Change to BLANK DVD-R and hit ENTER to continue.
echo ================================================
read
#
if [ "X${rw}" = "Xyes" ]
then
	dvdrecord dev=2,0,0 speed=${speed} blank=fast
fi
dvdrecord -v dev=2,0,0 speed=${speed} -dao dvd2dvd.img.tmp
eject /dev/dvd
#
rm -fr dvd2dvd.*.tmp

参考 :


2011年07月04日 ruby-1.9.x と for hoge in

_ ruby-1.9.x と for hoge in

ruby-1.8.xだとStringクラスがeachメソッドを実装していたので、以下のように記述できた。

str = "ABCD\nEFGH\nIJKL"
for i in str
	puts "Line is #{i}"
end

ruby-1.9.xではStringクラスからeachメソッドが廃止されたので、以下のように記述する必要がある。

str = "ABCD\nEFGH\nIJKL"
str.each_line do |i|
	puts "Line is #{i}"
end