ffmpeg よりも Hand Brake の方がよさげ → Fedora13 HandBrake へ
# yum -y install ffmpeg必要なモノはインストールされた
$ sudo rpm -ivh http://downloads.sourceforge.net/zenlib/libzen0-0.4.14-1.i386.Fedora_12.rpm $ sudo rpm -ivh http://downloads.sourceforge.net/mediainfo/libmediainfo0-0.7.33-1.i386.Fedora_12.rpm $ sudo rpm -ivh http://downloads.sourceforge.net/mediainfo/mediainfo-0.7.33-1.i386.Fedora_12.rpm※ 現時点(2010-07-10)では Fedora 13 向けのモノは公開されていない
#!/bin/bash VIDEO_SRC="/var/video/src" VIDEO_ORIGINAL="/var/video/original" VIDEO_DEST="/var/video/h264" LOCK_FILE="/tmp/toH264.lock" if [ -f $LOCK_FILE ]; then echo "This process is running." exit fi echo $$ > $LOCK_FILE # ---------- MAIN PROCEDURE ---------- cd $VIDEO_SRC for FILE_SRC in *.mpg *.avi do echo "-------------------------" # 1) Analyze source aspect ratio echo "SOURCE FILE : "$FILE_SRC ASPECT_RATIO=`/usr/bin/mediainfo $FILE_SRC | grep aspect | cut -c 36-` echo "SOURCE ASPECT : "$ASPECT_RATIO # 2) Decide dest resolution # 16:9 -> 704x396 # 4:3 or unknown -> 640x480 DEST_RESOLUTION="640x480" if [ $ASPECT_RATIO = "16:9" ]; then DEST_RESOLUTION="704x396" fi echo "DEST RESOLUTION : "$DEST_RESOLUTION # 3) Convert to H.264 FILE_DEST=${FILE_SRC%.mpg} FILE_DEST=${FILE_DEST%.avi} FILE_DEST=$FILE_DEST".mp4" echo "DEST FILE : "$FILE_DEST /usr/bin/ffmpeg -y -i "$FILE_SRC" -vcodec libx264 -vpre hq -vpre ipod640 \ -s $DEST_RESOLUTION -cqp 25 -aq 500 -async 100 -threads 2 \ "$VIDEO_DEST/$FILE_DEST" < /dev/null # 4) Reserve original file mv "$FILE_SRC" "$VIDEO_ORIGINAL" done # ---------- MAIN PROCEDURE ---------- rm $LOCK_FILE
unite.sh を作った
#!/bin/sh tmps="" for file in $* do ffmpeg -y -i "$file" -b 2048k -r 24 "${file}.mpg" tmps="$tmps ${file}.mpg" done echo $tmps cat $tmps > tmp.mpg ffmpeg -i tmp.mpg -y -sameq -dts_delta_threshold 1 ${1%.*}.mpg rm tmp.mpg for file in $tmps do rm $file done
./unite.sh a.wmv b.wmv c.wmvで
a.wmv.mp4ができる。