读书人

asp调用mencoder 生成FLV 的命令?解决

发布时间: 2012-03-09 21:42:54 作者: rapoo

asp调用mencoder 生成FLV 的命令?
<%
'///////////////////对上传文件进行格式的转换
mencoder=server.MapPath( "mencoder.exe ")
ffmpeg=server.MapPath( "ffmpeg.exe ")

'///////////////////产生随机数
randomize
ranNum=int(900*rnd)+100

'//////////////////路径
videoPath1=server.MapPath(session( "videoPath1 "))
flvPath1=server.MapPath(session( "SavePath "))& "\ "&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum& ".flv "

FileExt1=session( "FileExt ")

Set WshShell1 = server.CreateObject( "Wscript.Shell ")
'/////////////ffmpeg处理部分
if FileExt1= "wmv " or FileExt1= "asf " or FileExt1= "avi " then
str1=ffmpeg& " -i "&videoPath1& " -ab 16 -ar 22050 -b 150 -r 15 -s 320x240 "&flvPath1& " "
fileName=session( "SavePath ")&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum
Isffmpeg1=WshShell1.Run(str1,1,ture)

'//////////////mencoder处理部分
elseif FileExt1= "3gp " or FileExt1= "rm " or FileExt1= "rmvb " or FileExt1= "mp4 " then
fileName=session( "SavePath ")&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum
str1=mencoder& " "&videoPath1& " -o "&flvPath1& " -of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=150:mbd=2:mv0:trell:v4mv:cbp:last_pred=3:dia=4:cmp=6:vb_strategy=1 -vf scale=370:355 -ofps 12 -srate 22050 "
Isffmpeg1=WshShell1.Run(str1,1,ture)

else
fileName=session( "fileName ")
end if


Set WshShell1 = Nothing
session( "fileName1 ")=fileName
response.write fileName
response.redirect "mvplay.asp "
'//////////////////对上传文件进行格式转换结束
%>


转换wmv格式时是调用ffmpeg没问题。但转换rm或rmvb时 生成的FLV文件只有0K,
直接在翕令提示符下输入命令,出现的错误为:connot initialize muxer

哪位高手用过mencoder帮忙分析一下,或者给段参数吧!!
如果谁有好的源码 发一份给我可以吗? email: swboy@126.com

[解决办法]
今年最火的就是在线视频网站了。

这些网站都是.flv文件。.flv文件可以支持边下载边播放,而且占用空间比较小。

现在就有一个问题,如何让网站用户 不论上传什么文件,都自动转换为.flv文件?

我前几天稍微学习了一点点这方面的东西。

转换主要用到了两个控件。

1:mEncoder。2:ffmpeg

ffmpeg可以很方便的把大部分视频格式转换为.flv格式的。但是不支持.rm,.rmvb的。所以需要用mEncoder把.rm或者.rmvb直接转换为.flv的。但是我没有转换成功过,所以我只能先转换为.avi的,然后再用ffmpeg转换为.flv。

ffmpeg.asp
:

<%
Server.ScriptTimeout=0
str=server.MapPath( "ffmpeg1.exe ")
video=server.MapPath( "xyx.AVI ")
flv=server.MapPath( "xyx.flv ")
Set WshShell = server.CreateObject( "Wscript.Shell ")
str=str& " -i "&video& " -ab 56 -ar 22050 -b 500 -r 15 -s 320x240 "&flv


Isffmpeg = WshShell.Run(str,1,false)
if Isffmpeg = 0 Then
Response.Write str& " <br> "
end if
Set WshShell = Nothing
%>



mEncoder.asp:

<%
tools=Server.mapPath( "mencoder.exe ")
comeFile=Server.MapPath( "xyx.wmv ")
toFile=Server.MapPath( "rmvb.avi ")
Set Shell = Server.CreateObject( "wScript.Shell ")
str=tools & " "&comeFile& " -oac mp3lame -lameopts preset=64 -ovc xvid -xvidencopts bitrate=600 -of avi -o " & toFile
i_certify_that_my_video_stream_does_not_use_b_frames -ovc lavc -lavcopts vcodec=flv:vbitrate=200 -srate 22050 -oac lavc -lavcopts acodec=mp3:abitrate=56 ok \ "&comeFile& " -o ok \ " & toFile
IsMenCoder = Shell.run(str,1,false)
if IsMenCoder = 0 Then
Response.Write( "成功! ")
response.write( " <br /> " & str)
end if
Set Shell = Nothing

%>



参考资料:

http://hi.baidu.com/injava/blog/item/84c01a3356f395f81b4cff3d.html

http://www.hkepc.com/bbs/viewthread.php?tid=346269&extra=page%3D1

http://www2.flash8.net/teach/5411.htm

读书人网 >ASP

热点推荐