天天看點

ffmpeg實作SupeSite/X-Space6 影音格式轉換

SupeSite/X-Space6 個人空間裡有影音可以上傳分享

但需要實作格式的轉換,換成FLV 

但是目前隻能是半自動的。呵呵。

腳本如下:

#!/bin/bash

Extension="mpg 3gp mov mpeg vod mp4 m4v avi wmv mpe"

#INPUT YOUR SUPESITE PATH

SiteRoot="/usr/local/apache2/htdocs/xs6"

for e in $Extension; do

                FullFiles=`find $SiteRoot/video/temp -name "*.$e" -exec ls {} \;`

                for FullFile in $FullFiles;do

                if [ -f $FullFile ];then

                                a=`basename $FullFile | awk -F "." '{print $1}'`

                                b=`echo    $a | cut -d_ -f 2 | cut -c-6`

                                if [ ! -d $SiteRoot/video/$b ]; then

                                                mkdir $SiteRoot/video/$b

                                                chown -R nobody:huaxia $SiteRoot/video/$b

                                fi

                                ffmpeg -i $FullFile -y -ab 56 -ar 11025 -ac 2 -qscale 9 -r 15 -s 480*360 $SiteRoot/video/$b/$a.flv

                                chown nobody:huaxia $SiteRoot/video/$b/$a.flv

                                ffmpeg -i $FullFile -y -f image2 -ss 8 -sameq -t 0.001 -s 480*360 $SiteRoot/video/$b/$a.jpg

                                chown nobody:huaxia $SiteRoot/video/$b/$a.jpg

                                if [ -f $SiteRoot/video/$b/$a.flv ]; then

                                                rm $FullFile

#                                rm $FullFile

                fi

                done

done

加入cron就可以定時把使用者上傳的視訊轉換成FLV 并包含有截圖。這樣就可以觀看了。

SupeSite/X-Space 7  取消了這項功能。不知道為什麼? 

本文轉自守住每一天51CTO部落格,原文連結:http://blog.51cto.com/liuyu/198944,如需轉載請自行聯系原作者