且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ffmpeg实现SupeSite/X-Space6 影音格式转换

更新时间:2022-09-18 12:29:23

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
                                fi
#                                rm $FullFile
                fi
                done
done

加入cron就可以定时把用户上传的视频转换成FLV 并包含有截图。这样就可以观看了。

SupeSite/X-Space 7  取消了这项功能。不知道为什么? 


本文转自守住每一天51CTO博客,原文链接:http://blog.51cto.com/liuyu/198944,如需转载请自行联系原作者